CategoryUncategorized

Restrict /manage or /admin in Rails

You can do it from the Ruby on Rails application or even better way is to do it where you define your infrastructure and configure your proxy/loadbalancer etc. to allow it.

constrains manage
  class Whitelist
    def matches?(request)
      vpn = IPAddr.new("10.1.0.0/16")
      return true if Rails.env.development? || vpn.include?(request.remote_ip)

      Rails.logger.info("Blocking access for #{request.remote_ip} to #{rifiniti_vpn}")
      false
    end
  end

  constraints Whitelist.new do
    namespace :manage do
	...protected
    end
  end

 

Run kitchen with vaults

Way of testing kitchen with vaults

608bhtga3m_5v2so6hi74_vc102292

suites:
  - name: default
    run_list:
      - recipe[....
    data_bags_path: ../../data_bags_test
    attributes:
      chef-vault:
        databag_fallback: true

copy your data_bags/ and decrypted vaults/ content in a new folder containing the merged content from both folders.

Do not forget to add data_bags_test folder in .git_ignore.

 

image from www.wannapik.com

Online conference software aka meetings

If you want your developers and stuff to be happy please AVOID webex !

Webex is bad service

It has bad International connection. It doesn’t run on linux or unix and can’t be run in a browser. The IOS application is bad and doesn’t integrate with the links. The integration with the website and the calendars is bad. The website is slow and buggy and you can’t see the meeting on which you are invited. It is the worst of the software out there.

Zoom – It is like the webex. They look and feel the same one idea better, because it has client which can run in linux

Good one

https://www.bluejeans.com/ – works perfectly!

http://appear.in – free and great!

 

Sending a bunch of data to Zabbix with one request

One can send a bunch of key => values to zabbix with the zabbix-trapper items.

Using this nice article  as a base I have packed everthing in a class so that you can use it:

Example usage:

values = {
  total_ram: 0,
  wrong_data_center: 0,
  linode_hosts: 0,
  missing_from_zabbix: 0,
  missing_from_graylog: 0,
}

zabbix_sender = ZabbixSender.new(Figaro['zabbix_server'])
zabbix_sender.message('super_druper_hostname', values)
require 'json'

class ZabbixSender

  def initialize zabbix_host
    @zabbix_host = zabbix_host
  end

  def message hostname, values
    values_with_host = with_host(hostname, values)

    params = {
      "request" => "sender data",
      "data" => values_with_host,
    }

    body = JSON.generate params
    data_length = body.bytesize
    data_header = "ZBXD\1".encode("ascii") + \
    [data_length].pack("i") + \
    "\x00\x00\x00\x00"
    data_to_send = data_header + body

    send data_to_send
  end

  private

  def with_host hostname, hash
    values = []

    hash.each_pair do |key, value|
      values << {
        key: key,
        value: value,
        host: hostname,
      }
    end
    values
  end

  def send data_to_send
    socket = TCPSocket.new(@zabbix_host, 10051)
    socket.write data_to_send.to_s
    response_header = socket.recv(5)
    if not response_header == "ZBXD\1"
      puts "response: #{response_header}"
      raise 'Got invalid response'
    end

    response_data_header = socket.recv(8)
    response_length = response_data_header[0,4].unpack("i")[0]
    response_raw = socket.recv(response_length)
    socket.close
    response = JSON.load(response_raw)
  end

end

 

Tired of the old Rails scaffold?

Why Rails scaffold doesn’t work

The need to write a replacement of the Rails scaffold was because the build in one in Ruby on Rails:

  • Does not support namespaces on the controllers and the models it generates funny paths in the views and/or controllers
  • The native way to extend the Rails scaffold was changed frequently I have to spend hours tracing github issues
  • It uses the ugly scaffold.css and it generates it all the time breaking my styles
  • Does some freaky copy/paste optimizations in the controller to get the model. Scaffold should be a starting point from where with few deletes or add few lines of codes to make a usable screen.

The new approach

With scaffold_pico you can create your own pretty administration in a second.

  • No learning curve – if you know Rails you know it.
  • No 3rd party gems slowing your development/production startup times.
  • Clean code
  • Supports namespaces in the models and the controllers

There is also some sugar. With the pico_scaffold you can generate from the beginning fabricators and take care of N+1 by specifying joins/includes clauses. There is separation of the fields for index and editing. There is a search – almost every screen now days has search.

Supports Zurb Foundation, Materializecss CSS frameworks

Here is the github: https://github.com/gudata/scaffold_pico

Learning programming languages

learn programming

challenges


mentoring

Optimizations

Algorithms

Функционално програмиране

Academies

Online help

Conferences

quizes

  • https://projecteuler.net/

 

Remove the mysql root password on development

The world is going crazy. The mysql manual for 5.7.3 is not working.

Here is how to remove the password…

Continue reading

Jailbreak 9.3.3 and afterwards

imageIt is easy. You have to do it! Just save the jailbreak and the Cydia impactor so that you can do the Jailbrake in April 2017.

What I have installed again and is working was:

Name What it does? From repo
Activator Shortcuts everywhere
OpenSSH
iCleaner Pro 7.3.0 Claims it free disks space http://exile90software.com/cydia/beta
FlipControlCenter Manage shortcut icons
AppCake Download pirate games http://cydia.iphonecake.com/
AudioRecorder 2 $ call recorder http://limneos.net/repo
Alternative apps:
Call Recorder
http://hacx.org/repo/
dnscrypt-proxy  crypt your dns  http://limneos.net/repo
 albumshot Smart albums for all apps  http://limneos.net/repo
 SpringBoard  move fast through the screens  http://limneos.net/repo

Thireus Extra Recommended Tools

 http://limneos.net/repo
 IPPeek  show the IP on the clock. Use it from activator
 Aquaboard  Fencypency effects  http://limneos.net/repo
Spоtilife
alternatives:
SpotiuM
BDaySpotify 2
Unlocks some features on the spotify app http://repo.hackyouriphone.org/
GameGem
and
GamePlayer
Game cheating tool  research more here
 SystemSoundDisabler Disable all kind of anoying sounds
 LocalIAPStore iOS 9  Inapp purchases for free  Canolli
Minimal hosts blocker  Ads blocker  https://reddestdream.github.io/

No time to install

Bridge – import music to Music from http://canolli.yourepo.com/
from: https://cydia.angelxwind.net/
https://www.yourepo.com/repo/canolli/pack/bridge – tring now and want to try those also
AppSync Unified – you need this to install unsinged ipa files.

iFile – from here http://www.sinfuliphonerepo.com/
PhotosLive from http://limneos.net/repo

https://appaddict.org/ios-app/ – trying now

TERMINALS

it has nice list of shortcuts, works bad on ios 9.3.3
MobileTerminal (mine bad choice)  from Karens repo https://cydia.angelxwind.net/    which is on the same code base iOS Terminal form BigBoss

MTerminal works good –  from the BigBoss repo.

http://repo.thireus.com – install recommended ios9/ios8/ios7 hacker tools, this includes “newterm” which is updated through ios9. The hacker package installs a bunch of command line utilities like ping, nmap, get, top wget, etc as well. otherwise if you just want terminal just install newterm.

Tried but not using

vShare
killbackground8
BioProtect – protect apps with the touch ID
Cameratweak4 http://repo.hackyouriphone.org/ (the release there is not properly cracked)

Filesystem

How to clean your photos:

  1. Backup/Delete /private/var/mobile/Media/DCIM
  2. Delete /private/var/mobile/Media/PhotoData

SQLite

Emails database:  /private/var/mobile/Library/Mail/Envelope Index 
  sqlite> pragma table_info(messages);

Calendar database: /private/var/mobile/Library/Calendar/Calendar.sqlitedb
  pragma table_info(ABPerson);

Phone numbers database: /private/var/mobile/Library/AddressBook/AddressBook.sqlitedb 
  pragma table_info(event);

Call History database: /private/var/mobile/Library/CallHistory/call_history.db 
  sqlite> pragma table_info(call);

SMS database: /private/var/mobile/Library/SMS/sms.db
  sqlite> pragma table_info(message);

More on this on limneos blog

plutil from Erica Utillities – is used to modify the .plist files

Links

https://twitter.com/limneos – the author of audiorecord2

http://dantheman827.github.io/ios-app-signer/

http://iphone.mob.org/ nice source of game downloads

Pirate Sources

http://quanganh9x.info/quanganh9x.php

Latest iphones jailbrake

https://github.com/axi0mX/ipwndfu

https://github.com/LukeZGD/Legacy-iOS-Kit

case vs if

I notice that a lot of people are writing tons of ifs instead of use the case operator.

The case operator is much more readable. It can do more work than the ifs. And it should be faster by definition. Unfortunately in ruby it is faster only in > 2.x

With case you compare objects and match multiple values.

Continue reading

Good readings for today

https://github.com/karldray/quantum




© 2025 Gudasoft

Theme by Anders NorénUp ↑