This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if "foo@example.com" =~ /@(.*)/ | |
$1 | |
else | |
raise "bad email" | |
end | |
# => "example.com" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Reasonably efficient pagination without OFFSET | |
-- SQLite version (Adapted from MS SQL syntax) | |
-- Source: http://www.phpbuilder.com/board/showpost.php?p=10376515&postcount=6 | |
SELECT foo, bar, baz, quux FROM table | |
WHERE oid NOT IN ( SELECT oid FROM table | |
ORDER BY title ASC LIMIT 50 ) | |
ORDER BY title ASC LIMIT 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'socket' | |
gs = TCPServer.open(0) | |
socks = [gs] | |
addr = gs.addr | |
addr.shift | |
puts "server is on #{addr.join(':')}" | |
while true | |
nsock = select(socks) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#### Contents of the preconfiguration file (for lenny) | |
### Localization | |
# Locale sets language and country. | |
d-i debian-installer/locale string en_US.UTF-8 | |
# Keyboard selection. | |
#d-i console-tools/archs select at | |
d-i console-keymaps-at/keymap select us | |
# Example for a different keyboard architecture | |
#d-i console-keymaps-usb/keymap select mac-usb-us |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Converts an InnoDB database that uses a shared InnoDB tablespace file (e.g. ibdata1) to use | |
# a separate file per table. | |
# | |
# - First change your my.cnf file to use separate files by adding "innodb_file_per_table" to | |
# the [mysqld] section. (This is safe: MySQL will revert to the giant file if it cannot find | |
# the per table file.) | |
# - Restart the MySQL server | |
# - cd to the directory of your database (cd /opt/mysql/data/mydb) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'eventmachine' | |
require 'net/dns' | |
require 'net/dns/resolver' | |
module EM # :nodoc: | |
module Protocols | |
include Logger::Severity | |
class AsyncResolver < Net::DNS::Resolver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shift + middle click! | |
when set mouse=a is on, vim grabs all the mouse action, so in order to let X in on the fun use shift. in order to copy something from one part of the document use shift+highlight, and in order to paste, enter insert mode, toggle paste mode and shift+middle click. Very fun, quite a few steps to get a handle on though. | |
Alternatively, use 'set mouse=' (no a) to turn the mouse off and then just the X mouse will be functioning in vim. no shift is required, but make sure to still be pasting in insert mode and with paste on (without paste, autoindent ruins your day, without insert mode the stuff you're pasting will be interpreted as commands) | |
Finally, turn off bullshit flow control with | |
stty -ixon in your bashrc. Then you can properly get Ctrl+{S,V,X,Z,C} etc working but BE IN COMMAND MODE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "java" | |
require "netty-3.2.4.Final.jar" | |
# HELLO JAVA. I MISSED U. | |
java_import java.net.InetSocketAddress | |
java_import java.util.concurrent.Executors | |
java_import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory | |
java_import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory | |
java_import org.jboss.netty.channel.ChannelFactory | |
java_import org.jboss.netty.channel.ChannelPipelineFactory |
OlderNewer