Skip to content

Instantly share code, notes, and snippets.

View addisaden's full-sized avatar
🔍
Research Trip

addisaden addisaden

🔍
Research Trip
View GitHub Profile
@addisaden
addisaden / genChoices.rb
Created October 23, 2011 21:32
Rubyfunktion, welche alle Kombinationsmöglichkeiten der Argumentenliste zurück gibt
#
# genChoices | Gibt alle Kombinationsmöglichkeiten der Argumentenliste zurück. @ writedown.eu
#
def genChoices(*args)
choices = []
return args if args.length <= 1
(0...args.length).each { |pos|
if pos > 0
temp = choices.dup
temp.each { |e|
@addisaden
addisaden / node-and-npm-in-30-seconds.sh
Created November 12, 2011 12:59 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/v0.6.1/node-v0.6.1.tar.gz | tar xz --strip-components=1
sudo apt-get install libssl-dev
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl http://npmjs.org/install.sh | sh
@addisaden
addisaden / lookup-server.js
Created November 12, 2011 16:47
node.js - Http Server for ip lookup from domain
var http = require("http");
var dns = require("dns");
var u = require("util");
var urls = { length: 0 }
http.createServer(function(req,res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
var url = req.url.replace(/^\/(https?:\/\/)?/i,"");
url = url.split("/")[0];
@addisaden
addisaden / tictactoe.hs
Created December 16, 2011 16:24
My first haskell app - another TicTacToe ;)
import System.IO
main = tictactoe
tictactoe = do
hSetBuffering stdin NoBuffering
play " " "qweasdyxc" 0
drawTTT ttt = [
@addisaden
addisaden / EchoClient.rb
Created August 24, 2012 11:51
Simple DRb Client + Echoserver (localhost)
require "drb/drb"
print "port: "
port = gets.strip
raise "port is no valid" unless /^\d+$/ =~ port
there = DRbObject.new_with_uri("druby://localhost:#{ port }")
loop {
@addisaden
addisaden / client.rb
Created August 31, 2012 14:23
A Simple Server-Client Chat with dRuby.
require "drb/drb"
print "Bitte geben Sie die IP des Servers ein: "
ip = gets.strip
print "Bitte geben Sie den Port des Servers ein: "
port = gets.strip.to_i
port = 3000 if port == 0
server = DRbObject.new_with_uri("druby://#{ ip }:#{ port }")
@addisaden
addisaden / evaluator.rb
Created September 7, 2012 12:46
Evaluator - A small Sandbox in Ruby - key => Sandbox
require "drb/drb"
require "digest"
class Client
def get_binding
return binding
end
end
class Evaluator
@addisaden
addisaden / webAnalyze.rb
Created September 8, 2012 13:07
Ein Skript, was ich vor nem Jahr als Prototyp entworfen habe um Webseiten zu analysieren
#!/usr/bin/env ruby
# encoding: utf-8
require "net/http"
require "readline"
class Website
############---------------------------------------------------------- CLASS
@@hosts ={} # "www.23g.eu" => WebsiteObj
@@sessionname = nil
@addisaden
addisaden / durchsuche_pdfs.rb
Created September 14, 2012 12:06
search keywords in a lot of Pdfs
require "pdf-reader"
dateiname = []
print "Bitte geben Sie die zu suchenden Worte ein: "
words = gets.strip.split(/\s+/mi).collect { |w|
dateiname << w
Regexp.new(w.to_s, Regexp::MULTILINE + Regexp::IGNORECASE)
}
@addisaden
addisaden / play_cards.rb
Created October 23, 2012 08:10
A Rubyclass to get some cards
# encoding: utf-8
class Cards
def initialize(*signs)
@colors = [:♥, :♠, :♦, :♣]
@valid_signs = [2, 3, 4, 5, 6, 7, 8, 9, 10, :J, :Q, :K, :A]
if signs.empty? then
signs = @valid_signs
end
signs.each { |s|