Skip to content

Instantly share code, notes, and snippets.

View ik5's full-sized avatar
🎯
Focusing

ik5 ik5

🎯
Focusing
View GitHub Profile
@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
@ik5
ik5 / daemon.go
Created October 11, 2014 11:39
testing a daemon tool
package main
import (
"errors"
"fmt"
"github.com/takama/daemon"
"log"
"os"
"os/signal"
"syscall"
@ik5
ik5 / consumer.go
Created October 16, 2014 10:18
beanstalk example in go
package main
import (
"fmt"
"github.com/kr/beanstalk"
"os"
"time"
)
func main() {
@ik5
ik5 / binder.js
Last active August 29, 2015 14:08
attempt to create simple data binder
// based based on
// http://www.lucaongaro.eu/blog/2012/12/02/easy-two-way-data-binding-in-javascript/
function PropBack() {
var prop = [
{ name: 'value', callback: function(obj, content) { jQuery(obj).val(content); } },
{ name: 'html', callback: function(obj, content) { jQuery(obj).html(content); } },
{ name: 'text', callback: function(obj, content) { jQuery(obj).text(content); } },
{ name: 'title', callback: function(obj, content) { jQuery(obj).attr('title', content); } },
{ name: 'name', callback: function(obj, content) { jQuery(obj).attr('name', content); } },
@ik5
ik5 / puma-logrotate
Created November 16, 2014 19:30
general rack based server configuration
/path/to/log/file.log {
daily
compress
postrotate
kill -HUP `cat /path/to/app/tmp/puma/puma.pid`
endscript
}
@ik5
ik5 / ugly :(
Last active August 29, 2015 14:09 — forked from bararchy/ugly :(
def check_s_client
server = 'Generel Settings: '
renegotiation = 'Insecure Renegotiation'.colorize(:red)
crime = 'SSL Compression Enabled <= CRIME - CVE-2012-4929'.colorize(:red)
results = %x(echo "q" | openssl s_client -host #{@server} -port #{@port} 2> /dev/null) # why ?
case results.downcase
when 'secure renegotiation is supported'
renegotiation = 'Secured Renegotiation'.colorize(:green)
when 'compression: none'
@ik5
ik5 / yield_example.rb
Last active August 29, 2015 14:09
simple example for yielding in ruby
def to_file(*block)
raise ArgumentError.new('You must use block') unless block_given?
f = open('/tmp/to_file', 'a+')
yield f
f.close
end
to_file do |f|
f.puts 'Hello World'
end