Skip to content

Instantly share code, notes, and snippets.

View ik5's full-sized avatar
🎯
Focusing

ik5 ik5

🎯
Focusing
View GitHub Profile
@ik5
ik5 / fragment_count.go
Last active August 29, 2015 14:26
Calculating how many SMS fragments will a message have
package main
import (
"fmt"
"math"
"os"
"unicode/utf8"
)
func calculateSmsFragments(message string) uint64 {
@ik5
ik5 / rabbit_dispatcher.go
Created July 5, 2015 14:52
attempted load on rabbit
package main
import (
"flag"
"fmt"
"log"
"github.com/streadway/amqp"
)
@ik5
ik5 / append_list.go
Last active August 29, 2015 14:18
Example on how to add items to a list based on struct
package main
import "fmt"
type SiteList struct {
Title string
Address string
FeedAddress string
Author string
}
@ik5
ik5 / optimize_jpg.sh
Last active August 29, 2015 14:13
Optimize big jpg scans using imagemagic and jpgoptim programs
#/usr/bin/env bash
shopt -s nocasematch
function exec_code() {
file=$1
ext=${file: -4}
if [[ $ext == '.jpg' ]]; then
echo ', a jpeg file, working on it'
mv "$file" "old_$file"
@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
@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 / 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 / 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 / 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 / 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'