Skip to content

Instantly share code, notes, and snippets.

import java.io.IOException;
import java.io.PrintStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
class Handler implements Runnable {
private final Socket request;
public Handler(final Socket request) {
this.request = request;
# Build an inverted index for a full-text search engine with Redis.
# Copyright (C) 2009 Salvatore Sanfilippo. Under the BSD License.
# USAGE:
#
# ruby invertedindex.rb add somedir/*.c
# ruby invertedindex.rb add somedir/*.txt
# ruby search your query string
require 'rubygems'
require 'redis'
require 'rubygems'
require 'sinatra'
require 'redis'
# To use, simply start your Redis server and boot this
# example app with:
# ruby example_note_keeping_app.rb
#
# Point your browser to http://localhost:4567 and enjoy!
#
require 'digest/sha1'
class Invite < ActiveRecord::Base
validates_presence_of :email, :on => :save, :message => "can't be blank"
validates_uniqueness_of :email, :on => :save, :message => "is already registered"
named_scope :unsent_invitations, :conditions => {:redeemed_at => nil, :invite_code => nil}
def invited?
require 'test_helper'
module Clearance
module Shoulda
def should_create_user_successfully
# Don't need this test.
end
end
end
class UsersController < ApplicationController
include Clearance::App::Controllers::UsersController
# Override and add in a check for invitation code
def create
@user = User.new params[:user]
invite_code = params[:invite_code]
@invite = Invite.find_redeemable(invite_code)
if invite_code && @invite
require 'rubygems'
require 'net/ldap'
# sudo gem install ruby-net-ldap
HOSTNAME = "foo.local"
BASENAME = "dc=openrain,dc=com"
PORT = 389
puts "What's your username"
username = STDIN.readline.chomp
inputs = args
spec = Gisting::Spec.new
inputs.each do |file_input|
input = spec.add_input
input.file_pattern = file_input
input.map do |map_input|
# 2722 mailbox 2006-05-23 00:08:39
# 217 - 2006-05-23 15:41:48
# 1326 www.crazyradiodeals.com 2006-05-23 18:00:30
# 2722 mailbox 2006-05-23 00:08:39
class Selfoo
# bar # Why doesn't this work?
def self.foo
puts "foo"
end
class << self
# puts foo # Why doesn't this work?
document.write("oh hai")