Skip to content

Instantly share code, notes, and snippets.

View ik5's full-sized avatar
🎯
Focusing

ik5 ik5

🎯
Focusing
View GitHub Profile
@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
@ik5
ik5 / fiddle.rb
Created November 17, 2014 13:15
require 'fiddle'
openssl = Fiddle.dlopen('/usr/lib/libssl.so')
SSL_library_init = Fiddle::Function.new(
openssl['SSL_library_init'],
[],
Fiddle::TYPE_INT
)
SSL_library_init.call # no parameters so no () requires
@ik5
ik5 / sshsock.rb
Last active August 29, 2015 14:10 — forked from bararchy/sshsock.rb
require 'rubygems'
require 'ffi'
module SSHSocket
extend FFI::Library
ffi_lib_flags :now, :global
ffi_lib 'libssh'
attach_function :ssh_init, [], :int
attach_function :ssh_bind_new, [], :pointer
@ik5
ik5 / random.sh
Created December 4, 2014 10:07
random password generator in shell
genpasswd() {
local l=$1
[ "$l" == "" ] && l=20
tr -dc "A-Za-z0-9_%^&*()\`/[]{}|" < /dev/urandom | head -c ${l} | xargs
}
genpasswd 52
@ik5
ik5 / ruby22.spec
Last active May 16, 2016 18:49
A ruby 2.2.x rpm spec file
%define rubyver 2.2.0
%define debug_package %{nil}
Name: ruby
Version: %{rubyver}
Release: 1%{?dist}
License: Ruby License/GPL - see COPYING
URL: http://www.ruby-lang.org/
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: readline-devel ncurses-devel gdbm-devel glibc-devel tcl-devel unzip openssl-devel db4-devel byacc make libyaml-devel valgrind-devel gmp-devel clang