This file contains hidden or 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
>> @r=Redis.new | |
#<Redis client v2.1.1 connected to redis://localhost:6379/0 (Redis v2.1.12)> | |
>> @r.set Digest::SHA1.digest('foo'), 'bar' | |
=> "OK" | |
>> @r.get Digest::SHA1.digest('foo') | |
=> "bar" |
This file contains hidden or 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
class MyModel | |
attribute :complex_object_store | |
def complex_object=(object) | |
self.complex_object_store = Base64.encode64(Marshal.dump(object)) | |
end | |
def complex_object | |
Marshal.load(Base64.decode64(self.complex_object_store)) | |
end |
This file contains hidden or 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 | |
ALPHABET = ['a'..'z', 'A'..'Z', '0'..'9'].collect { |range| range.to_a }.flatten | |
class Array; def random; self[rand(self.length)]; end; end | |
length = (ARGV.shift || 10).to_i | |
puts Array.new(length) { ALPHABET.random }.join |
This file contains hidden or 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
describe 'categorizer command-line stuff' do | |
it 'should write entity ids to case files' do | |
fake_suggestions = { | |
:jp2 => ['/foo/XX00000011.xml', '/bar/YY00000022.xml'], | |
:tiff => ['/bar/zz.xml', '/foo/abc.xml'] | |
} | |
mock_jp2_output = mock('file') | |
mock_tiff_output = mock('file') |
This file contains hidden or 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
# ripoff of jreese.zsh-theme | |
if [ "$(whoami)" = "root" ]; then NCOLOR="red"; fi | |
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" | |
PROMPT='%m \ | |
$(git_prompt_info)\ | |
%(!.#.%%) ' | |
#PROMPT='%{%{$fg[green]%}%m%{$reset_color%} \ | |
#$(git_prompt_info)\ |
This file contains hidden or 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
# put this in ~/.irbrc | |
def h(html) | |
File.open('/tmp/irb.html', 'w') { |f| f.write html } | |
`chromium /tmp/irb.html` | |
end | |
Example: | |
% irb |
This file contains hidden or 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' | |
listener = TCPServer.new(8888) | |
loop do | |
puts 'waiting for connection...' | |
sock = listener.accept | |
fork do | |
puts 'i am child' | |
filename = sock.gets.split[1] | |
begin |
This file contains hidden or 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
escape ^]] | |
startup_message off | |
defflow auto | |
defscrollback 5000 | |
altscreen on | |
autodetach on | |
msgwait 3 | |
#change the hardstatus settings to give an window list at the bottom of the | |
#screen, with the time and date and with the current window highlighted |
This file contains hidden or 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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <sys/types.h> | |
#include <sys/stat.h> | |
#include <fcntl.h> | |
#include <unistd.h> | |
#include <openssl/evp.h> | |
// compile with: gcc -lssl find.c |
This file contains hidden or 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
<?php | |
require "inc/mysql.inc.php"; | |
?> | |
<html> | |
<head><title>Oh, Those Admins!</title></head> | |
<body><center><h1>Oh, hi!</h1> | |
<?php | |
if (isset($_GET['password'])) { | |
$r = mysql_query("SELECT login FROM admins WHERE password = '" . md5($_GET['password'], true) . "'"); | |
if (mysql_num_rows($r) < 1) |