Skip to content

Instantly share code, notes, and snippets.

View ik5's full-sized avatar
🎯
Focusing

ik5 ik5

🎯
Focusing
View GitHub Profile
CREATE TABLE posts (
id BIGINT NOT NULL PRIMARY KEY,
name VARCHAR(255),
title VARCHAR(255),
content VARCHAR(255),
timestamps timestamp
);
CREATE GENERATOR POSTS_SEQ;
@ik5
ik5 / daemon.rb
Created June 22, 2010 18:43
a quick and dirty jruby daemon based on basic_daemon
#!/usr/bin/env jruby
#
#
require 'rubygems'
require 'spoon'
EXEC = '/tmp/exec.rb'
PID_PATH = '/tmp/exec.pid'
WORK_PATH = '/tmp/'
#!/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'
@ik5
ik5 / test_of_labels.pas
Created September 7, 2010 22:10
A test in Pascal (FPC) for some low level. I'm looking to know how to translate it into C and _asm
{$IFDEF FPC}{$GOTO ON}{$asmmode att}{$ENDIF}
program asm_code;
label a_label;
label _end;
var i : integer;
begin
writeln('a_label address: ', HexStr(PtrUInt(@a_label), 32));
i := -10;
@ik5
ik5 / cli output
Created May 25, 2011 13:28
Something wrong with pacman
ldconfig: File /usr/lib/libsolidcontrolnm09ifaces.so.4.6.0 is empty, not checked.
ldconfig: File /usr/lib/libknmservice.so is empty, not checked.
ldconfig: File /usr/lib/libsolidcontrolnm09.so.4.6.0 is empty, not checked.
ldconfig: File /usr/lib/libknmservice.so.4 is empty, not checked.
ldconfig: File /usr/lib/libsolidcontrolnm09.so is empty, not checked.
ldconfig: File /usr/lib/libknmservice.so.4.6.0 is empty, not checked.
ldconfig: File /usr/lib/libsolidcontrolnm09.so.4 is empty, not checked.
ldconfig: File /usr/lib/libknminternals.so.4 is empty, not checked.
ldconfig: File /usr/lib/libsolidcontrolfuture.so is empty, not checked.
ldconfig: File /usr/lib/libknm_nm.so is empty, not checked.
@ik5
ik5 / watchdog.rb
Created November 16, 2011 17:13
A watchdog for ahn v0.1
#!/usr/bin/env ruby
require 'rubygems'
require 'mail' # gem install mail
require 'fileutils' # for 1.8
BASE_PATH = '' # Place your path here for ahn
DEAMON = '' # Place the deamon path and name here
def send_email
@ik5
ik5 / archlinux signing
Created January 24, 2012 10:19
archlinux package signing - FAILS !
error: freeglut: signature from "Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>" is unknown trust
error: iproute2: signature from "Ionut Biru <ibiru@archlinux.org>" is unknown trust
error: lib32-kmod: signature from "Laurent Carlier <lordheavym@gmail.com>" is unknown trust
error: lib32-udev: signature from "Laurent Carlier <lordheavym@gmail.com>" is unknown trust
error: libgee: signature from "Ionut Biru <ibiru@archlinux.org>" is unknown trust
error: linux: signature from "Pierre Schmitz <pierre@archlinux.de>" is unknown trust
error: linux-headers: signature from "Pierre Schmitz <pierre@archlinux.de>" is unknown trust
error: sdl: signature from "Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>" is unknown trust
error: failed to commit transaction (invalid or corrupted package (PGP signature))
Errors occurred, no packages were upgraded.
@ik5
ik5 / nested multibulk
Created February 8, 2012 21:01
Redis nested multibulk
1) 1) (integer) 0
2) (integer) 1328734844
3) (integer) 14
4) 1) "CONFIG"
2) "SET"
3) "slowlog-log-slower-than"
4) "1"
@ik5
ik5 / is_internal_ip.rb
Created March 6, 2012 11:02
function to detect if an IPv4 address should be considered local
def internal_ip?(s)
s =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/
# based on http://www.ietf.org/rfc/rfc3330.txt
return case $1
when '0', '10', '127'
true
when '169'
# link local Zero Conf
(('16'..'31').include? $2) || ($2.eql? '254')
@ik5
ik5 / dynamic_method.pas
Created June 18, 2012 21:17
How dynamically execute a method in Object Pascal Class
{$mode objfpc}{$M+}
program test;
type
TMyClass = class
procedure SayHi;
end;
procedure TMyClass.SayHi;
begin