Skip to content

Instantly share code, notes, and snippets.

sudo openssl req -new -x509 -keyout dev.pem -out dev.pem -days 3650 -nodes
CmdUtils.CreateCommand({
names: ["ruby search"],
icon: "http://www.ruby-doc.org/favicon.ico",
description: "search ruby-doc.org using google",
help: "ruby <keyword>.",
author: {name: "joel hansson", email: "joel.hansson'at'gmail.com"},
license: "GPL",
homepage: "http://gottfolk.se",
arguments: [{role: 'object', nountype: noun_arb_text}],
preview: function preview(pblock, args) {
class Foo
def self.set(params)
puts "setting myparams = #{params}"
@my_params = params
end
def self.save_str
puts "my_param: '#{@my_params}'"
sleep(1)
#!/usr/bin/env python
import serial
import struct
from optparse import OptionParser
parser = OptionParser(usage="hurra")
parser.add_option("-p",default="hello world")
def sanitize_xml(str)
replaces = [
["<","&lt;"],
[">","&gt;"],
["\"","&quot;"],
["\'","&apos;"],
["&","&amp;"]
]
replaces.each{|e| str.gsub!(e[1],e[0]) }
replaces.reverse.each{|e| str.gsub!(e[0],e[1])}
php > $d = new DateTime();
php > $d->setTimestamp(1288565940);
php > echo $d->format('Y/m/d H:i');
2010/10/31 23:59
php > $d->modify('-1 month');
php > echo $d->format('Y/m/d H:i');
2010/10/01 23:59
@qzio
qzio / gist:737634
Created December 11, 2010 20:33
padrino_rack_env_issues
qzio@saito:~/public/notr[master]$ export RACK_ENV=production
qzio@saito:~/public/notr[master]$ echo $RACK_ENV
production
qzio@saito:~/public/notr[master]$ irb
ruby-1.9.2-p0 > ENV["RACK_ENV"]
=> "production"
ruby-1.9.2-p0 > quit
qzio@saito:~/public/notr[master]$ echo $PADRINO_ENV
qzio@saito:~/public/notr[master]$ RACK_ENV=production padrino console
@qzio
qzio / gist:1293347
Created October 17, 2011 18:19
validator api
<?php
$a = array("name" => "simon", "email" => "simon@noona.se", "homepage" => "http:////**sunet.se", "age" => "twentynine");
$validate = new Validator($a);
$validate->ensure("name", "")->isLen(5)->isAlpha();
$validate->ensure("email")->isEmail();
$validate->ensure("homepage", "Homepage is wr00ng!")->isUrl();
$validate->ensure("age")->isInt();
@qzio
qzio / gist:1670601
Created January 24, 2012 15:04
gearman-manager pecl-manager output when using a bad autoloader
$ ./pecl-manager.php -c config-single.ini -w ./worker-classes-ext -vvv
PID Type Message
27106 INFO Loading workers in ./worker-classes-ext
27107 PROC Helper forked
27107 INFO Loading workers in ./worker-classes-ext
27106 PROC Started with pid 27106
27106 PROC Started child 27108 (another_test_job,test_job)
27108 WORKER Adding server 127.0.0.1
27108 WORKER Adding job another_test_job
27108 WORKER Adding job test_job
@qzio
qzio / say-all-voices.sh
Last active September 28, 2016 14:28
Script to loop through all the voices for the osx/macos `say` command, and make them say their "sample-string", as well as their name.
#!/bin/sh
for v in $( say -v '?' | awk '{print $1}') ; do
echo "voice $v"
mystring="$(say -v '?' | grep "$v" | awk '{$1=$2=$3="";print}')"
say -v "$v" "Hello, my name is ${v}. $mystring"
sleep 0.5
done