Skip to content

Instantly share code, notes, and snippets.

name: Stefan Nuxoll
age: 17
require 'ruby-event'
# General purpose wrapper for network connections
class NetworkConnection
attr_reader :hostname, :port, :thread
# Create a new event to be fired when we recieve data
# from the server
event :data_received
require 'network_connection'
conn = NetworkConnection.new('irc.freenode.net', 6667)
# Create a new handler for the event
conn.data_received + lambda do |server, text|
if text =~ /^PING/
server.send(text.gsub(/^PING/, "PONG"))
end
end
module YCombinator
def y_comb(&generator)
proc { |x|
proc { |*args|
generator.call(x.call(x)).call(*args)
}
}.call(proc { |x|
proc { |*args|
generator.call(x.call(x)).call(*args)
}
#!/usr/bin/env ruby
total = 0
STDIN.each_line do |line|
total += line.split(" ").inject(0) { |sum, x| sum + x.to_i }
end
puts "GRAND TOTAL: #{total}"
using GLib;
namespace snuxoll {
class StdinReader : Object {
public StdinReader () {
}
public bool eof() {
to compile:
valac -o sum --pkg vala-1.0 stdin_reader.vala sum_application.vala
require 'ftools'
require "vala"
require "pkg_config"
require "source_modules"
desc "Compile droppit"
task :default => [:build]
task :build => [:check_deps, :droppit]
desc "Regenerate code and build"
task :rebuild => [:generate, :build]
using GLib;
namespace SoupServer {
class ServerApplication : Object {
private Soup.Server server;
public ServerApplication() {
server = new Soup.Server(Soup.SERVER_PORT, 8000, null);
@snuxoll
snuxoll / shop.rb
Created October 15, 2012 07:49
Stupid Basic LDAP Authentication+Authorization
module Shop
module Config
LDAP_HOST = ENV["LDAP_HOST"]
LDAP_BIND_DN = ENV["LDAP_BIND_DN"]
LDAP_BIND_PASS = ENV["LDAP_BIND_PASS"]
LDAP_SEARCH_BASE = ENV["LDAP_SEARCH_BASE"]
LDAP_SEARCH_PROPERTY = ENV["LDAP_SEARCH_PROPERTY"]
LDAP_SECURITY_GROUP = ENV["LDAP_SECURITY_GROUP"]
end