Skip to content

Instantly share code, notes, and snippets.

View jingoro's full-sized avatar

John Nishinaga jingoro

View GitHub Profile
@jingoro
jingoro / gist:272739
Created January 9, 2010 05:34
YUI3 node-visibility
YUI().add('node-visibility', function(Y) {
Y.mix(Y.DOM, {
visible: function(node) {
return Y.DOM.getStyle(node, 'display') != 'none';
},
toggle: function(node) {
Y.DOM.visible(node) ? Y.DOM.hide(node) : Y.DOM.show(node);
},
hide: function(node) {
Y.DOM.setStyle(node, 'display', 'none');
#!/usr/bin/env perl
$field =~
m/^(
[\x09\x0A\x0D\x20-\x7E] # ASCII
| [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
| \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
| [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
| \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
| \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
dscacheutil -flushcache
PRUNEPATHS="/tmp /var/tmp */Backups.backupdb /Users" sudo /usr/libexec/locate.updatedb
--- botobackend.py.orig 2010-07-25 16:14:39.000000000 +0000
+++ botobackend.py 2010-09-30 15:52:41.000000000 +0000
@@ -146,7 +146,7 @@
else:
self.conn.calling_format = calling_format
- else:
+ elif self.bucket_name is None:
# Duplicity hangs if boto gets a null bucket name.
# HC: Caught a socket error, trying to recover
@jingoro
jingoro / bc_round
Created October 5, 2011 19:11
bc round to nearest integer
define round ( x ) {
auto origscale, result;
origscale = scale;
scale = 0
result = (x + 0.5) / 1;
scale = origscale;
return result;
}
@jingoro
jingoro / modular_arithmetic.rb
Created April 14, 2012 23:43
Ruby modular arithmetic
# Some modular arithmetic helper methods useful for number theory or
# cryptography.
#
# # Examples
#
# Compute the greatest common denominator of 114 and 48:
#
# gcd(114, 48) #=> 6
#
# Compute `a` and `b` such that `a*x + b*y = gcd(x, y)`:
@jingoro
jingoro / gist:2388983
Created April 15, 2012 00:13
Install gmp gem on OS X macports
LIBRARY_PATH=/opt/local/lib C_INCLUDE_PATH=/opt/local/include gem install gmp
@jingoro
jingoro / gist:2562645
Created April 30, 2012 20:59
start/stop apache on macports
sudo /opt/local/apache2/bin/apachectl start
sudo /opt/local/apache2/bin/apachectl stop
@jingoro
jingoro / mongoid-ambiguous-relation-bug.rb
Created May 4, 2012 19:43
Mongoid Ambigious Relation Bug?
require 'rubygems'
require 'bundler/setup'
require 'mongoid'
Mongoid.configure do |config|
config.master = Mongo::Connection.new.db("mongoid-test")
end
class Group
include Mongoid::Document