Skip to content

Instantly share code, notes, and snippets.

View ik5's full-sized avatar
🎯
Focusing

ik5 ik5

🎯
Focusing
View GitHub Profile
@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 / fs.go
Last active November 23, 2017 19:07
example of calculating quota of a directory, given a known maxiumum size
package main
import (
"fmt"
"os"
"path/filepath"
)
//
const (
@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();
@ik5
ik5 / email.go
Last active August 29, 2015 14:06
Sending email using Go
package main
import (
"fmt"
"github.com/alexcesaro/mail/gomail"
"net/smtp"
)
type Email struct {
From string
@ik5
ik5 / pubsub_redis.go
Last active August 29, 2015 14:06
Testing pub/sub for go, using Redis
package main
import (
"fmt"
"gopkg.in/redis.v2"
"time"
)
const (
Subscription int = iota
@ik5
ik5 / ini.go
Created September 27, 2014 16:42
Example on scanning INI file with github.com/vaughan0/go-ini
package main
import (
"fmt"
ini "github.com/vaughan0/go-ini"
"os"
)
const File = "test.ini"
@ik5
ik5 / kernel.rb
Created October 6, 2014 18:34
rack log format
module Kernel
def suppress_warnings
original_verbosity = $VERBOSE
$VERBOSE = nil
result = yield
$VERBOSE = original_verbosity
return result
end
end