Skip to content

Instantly share code, notes, and snippets.

View ik5's full-sized avatar
🎯
Focusing

ik5 ik5

🎯
Focusing
View GitHub Profile
@ik5
ik5 / to_config.rb
Created January 31, 2014 15:22
Converting planet's html to planets.ini file
#!/usr/bin/env ruby
# encofing: utf-8
require 'rubygems'
require 'nokogiri'
page = Nokogiri::HTML(open('/tmp/planetfossil.htm'))
feeds = Hash.new
@ik5
ik5 / comparing_content.rb
Created March 16, 2014 07:51
Hetz request to compare two files with different lengths
#!/usr/bin/env ruby
output = open('output', 'w+')
lines = open('logfile').readlines
open('shortfile').each_line do |l|
name = l.chomp
output.puts name if lines.include? name
end
# run with: rvmsudo god -c /srv/phone/phonzy/current/ahn/config/god/adhearsion.god
# debug with: rvmsudo god quit && rvmsudo god -c /srv/phone/phonzy/current/ahn/config/god/adhearsion.god -D
@deploy_path = '/srv/phone/phonzy'
@shared_path = File.join @deploy_path, 'shared'
@app_path = File.join @deploy_path, 'current', 'ahn'
@log_path = File.join @shared_path, 'log'
@pid_path = File.join @shared_path, 'pids'
@pid_file = File.join @pid_path, 'adhearsion.pid'
@god_env = YAML.load_file("#{@shared_path}/config/god_environment.yml")
@ik5
ik5 / defer.go
Created May 28, 2014 10:12
defer in go
func open_file {
f, err := os.Open("/tmp/a_file")
if err != nil {
log.Fatal("Unable to open a_file")
}
defer f.Close()
// do something here
}
@ik5
ik5 / firebird.vim
Created June 13, 2014 19:53
Firebird SQL syntax for VIM - http://pastebin.com/DNag96VC
" Vim syntax file
" Language: SQL
" Maintainer: Scott Morgan < blumf7 at gmail dot com >
" Last Change: 2014-06-13
" Version: 1.0
" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
if version < 600
syntax clear
@ik5
ik5 / redalarm.rb
Last active August 29, 2015 14:04
log alarms of rocket attacks on Israel using Ruby
#!/usr/bin/env ruby
require 'open-uri'
require 'json'
PKR_URL = 'http://www.oref.org.il/WarningMessages/alerts.json'
AREA_FMT = 'מרחב: %s, קוד מרחב: %s'
LOG_FMT = '[%s] id: %s, %s'
def to_json
@ik5
ik5 / ard_red.ino
Last active August 29, 2015 14:04
arduino based red color alarm for israeli missiles alert - a PoC video: http://youtu.be/AdF2AGIjtvY
int led = 13;
int in = 0;
void setup() {
pinMode(led, OUTPUT);
Serial.begin(9600);
}
void loop() {
if (Serial.available() == 0) {
@ik5
ik5 / maildir.rb
Last active August 29, 2015 14:04
moving maildir from disorgenized method to an orginized method.
#!/usr/bin/env ruby
require 'fileutils'
SOURCE = '/tmp/mbox/'
DESTINATION = '/tmp/maildir/domain.com/'
def is_maildir(path)
dirs = Dir[File.join(path, '*')]
dirs.select {|name| File.directory?(File.join(path, name)) &&
@ik5
ik5 / Gemfile
Created August 21, 2014 14:06
Example for simple usage of Grape
source "https://rubygems.org"
gem 'grape'
gem 'rack'
@ik5
ik5 / uuid-pg.sql
Created September 20, 2014 10:24
how to add the uuid-ossp extension
/* install postgresql-contrib */
CREATE EXTENSION "uuid-ossp";
select uuid_generate_v4();