Skip to content

Instantly share code, notes, and snippets.

View ik5's full-sized avatar
🎯
Focusing

ik5 ik5

🎯
Focusing
View GitHub Profile
@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 / 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 / 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 / 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 / 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 / gsm0338.go
Created August 18, 2015 09:46
Functions to convert between UTF8 and GSM 03.38 in go
package main
import (
"fmt"
"regexp"
"strings"
)
var utf8GsmChars = map[string]string{
`@`: "\x00", `£`: "\x01", `$`: "\x02",
CREATE TABLE posts (
id BIGINT NOT NULL PRIMARY KEY,
name VARCHAR(255),
title VARCHAR(255),
content VARCHAR(255),
timestamps timestamp
);
CREATE GENERATOR POSTS_SEQ;
#!/usr/bin/env ruby
# gem install ruby-filemagic
# please note that this program works only on Unix based systems and Linux.
# It uses the "file command" library (and information) in a native code to validate file content (rather then extension).
# Important note: It only read the *header* of the files rather the whole, content so we might still have malicious content ... :(
require 'rubygems'
require 'filemagic'