Skip to content

Instantly share code, notes, and snippets.

View ivyl's full-sized avatar
🙃

Arek Hiler ivyl

🙃
View GitHub Profile
@ivyl
ivyl / rt.c
Created October 27, 2012 13:18
Blog
#include <linux/init.h>
#include <linux/module.h>
#include <linux/proc_fs.h>
#include <linux/string.h>
#include <linux/cred.h>
#include <linux/fs.h>
//typesafe macro for getting minimum value
#define MIN(a,b) \
({ typeof (a) _a = (a); \
@ivyl
ivyl / passgen.rb
Created April 8, 2012 01:00
easy to remember password generator
#!/usr/bin/env ruby
# Usage: __FILE__ number_of_passwords words_in_password
#
# https://xkcd.com/936/
# This method is great, but people tend to chose only
# certain subset of words. This is solution.
#
# Generate set of X passwords and choose one.
#
# To dump dictionary (change pl to preferred language):
@ivyl
ivyl / vpn.sh
Created October 21, 2011 21:03
vpn automation
#!/bin/sh
DIR=$(dirname "$0")
CONF=$1.conf
cd $DIR
if [ ! -f $CONF ]; then
echo "Unknown VPN $1!"
exit 1
@ivyl
ivyl / motd.sh
Created August 14, 2011 00:07
MOTD Debian goodie
#!/bin/bash
NAME=servergroupnameororganization
URL1=http://test.com
URL2=http://example.com
UPTIME=`cat /proc/uptime |grep -E -o '^[0-9]*'`
UPTIME_SEC=$((UPTIME%60))
UPTIME=$((UPTIME/60))
UPTIME_MIN=$((UPTIME%60))
UPTIME=$((UPTIME/60))
@ivyl
ivyl / README.rdoc
Created July 28, 2011 11:09
Errornomous Response Generator
@ivyl
ivyl / db4o.scala
Created March 22, 2011 12:46
useful things for using db4o in scala, need to be reviewed
implicit def toPredicate[T](predicate: T => Boolean) =
new Predicate[T]() {def `match`(entry: T): Boolean = {predicate(entry)}}
class RichObjectSet[T](objectSet:ObjectSet[T]) extends Iterator[T] {
def hasNext:Boolean = objectSet.hasNext()
def next:T = objectSet.next()
}
implicit def toRichObjectSet[T](objectSet: ObjectSet[T] ) =
@ivyl
ivyl / math.rb
Created December 13, 2008 21:09
#PI 1 + 1000 numbers
p -4*(0..10**9).inject{|r,e|r+(10**1000*(-1)**e/(2*e-1))}
#E 1 + 1000 numbers
p (1..10**3).inject(0){|r,e|r+(e==1?2:1)*(10**1000)/(1..e).inject{|r,e|r*e}}
@ivyl
ivyl / drivingpwpw.rb
Created December 5, 2008 18:09
Some useful stuff.
#!/usr/bin/env ruby
require 'net/http'
require 'uri'
#set those varibles to your personal info
pesel = XXXXXXXXXX
imie = 'John'
nazwisko = 'Doe'
wait = 3600 #seconds
@ivyl
ivyl / 11.rb
Created November 23, 2008 14:01
Python Challange solutions in Ruby
#!/usr/bin/env ruby
require 'rubygems'
require 'open-uri'
require 'RMagick'
pixel = [Magick::Pixel.new(0, 0, 0)]
path = open('http://www.pythonchallenge.com/pc/return/cave.jpg', :http_basic_authentication => ["huge", "file"]).path
cat = Magick::ImageList.new(path).first
cat.columns.times do |column|
cat.rows.times do |row|