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
def retries(num_retries, exception_types=Exception, check_func=None, timeout=0.0): | |
"""retries a function ``num_retries`` times. | |
will catch ``exception_types`` of exceptions. This can be a tuple as well. | |
check_func can optionally be provided. It takes the exception as an argument. | |
If it returns a value that evaluates to false, the exception will be reraised. | |
can be used like: | |
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
class Hash | |
alias :old_to_a :to_a | |
def safe_to_a | |
old_to_a.sort | |
end | |
def to_a | |
safe_to_a | |
end |
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
" Vim indent file | |
" Language: html | |
" Maintainer: what's that? <[email protected]> | |
" URL: hah | |
" Anon CVS: hah | |
" Release Coordinator: Mike Lewis <[email protected]> | |
" | |
runtime! indent/javascript.vim | |
unlet! b:did_indent |
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
drop schema sessionize_test cascade; | |
create schema sessionize_test; | |
set search_path to sessionize_test; | |
create type user_session as ( | |
start_time timestamptz, | |
last_time timestamptz | |
); |
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
import sys | |
from functools import partial, wraps | |
from contextlib import contextmanager | |
from cStringIO import StringIO | |
############################### | |
# Should output the following | |
# <html> | |
# <head> |
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
/* | |
* To try it: | |
* c = $c.sRGB8(23,58,32); | |
* c.Lab(); | |
* c.Lab().sRGB8(); | |
*/ | |
var $c = {}; | |
( | |
function () { |
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
/* | |
Add a bookmark to this | |
javascript:(function(){var c=document.getElementsByTagName("link");for(var d=0;d<c.length;d++){var a=c[d];if(a.rel=='stylesheet'||a.type=="text/css"){var e="css_buster_"+Math.floor(Math.random()*1000000000);var g=a.href.split("?",2);var f;if(g.length>1){var b=g[1].indexOf("&")==-1;if(b){f=e}else{f=g[1]+"&"+e}}else{f=e}a.href=g[0]+"?"+f}}})(); | |
*/ | |
(function() { | |
var links = document.getElementsByTagName('link'); | |
for (var i = 0; i < links.length; i++) { | |
var l = links[i]; | |
if (l.rel == 'stylesheet' || l.type == 'text/css') { |
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
class RPMSpec | |
attr_reader :spec | |
def initialize(spec) | |
@tags = Hash.new {|h,k| h[k] = []} | |
@defines = {} | |
@spec = spec | |
@sections = Hash.new {|h,k| h[k] = []} | |
#@rpm_build_dir = rpm_build_dir |
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
def clone_table(old_table_name, new_table_name, split_keys=nil) | |
admin = HBaseAdmin.new(HBaseConfiguration.new()) | |
td = admin.getTableDescriptor(old_table_name.to_java_bytes) | |
td.setName(new_table_name.to_java_bytes) | |
if split_keys.nil? | |
admin.createTable(td) | |
else | |
new_keys = Java::byte[][split_keys.size].new | |
split_keys.each_index {|i| new_keys[i] = split_keys[i].to_java_bytes} |
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
def redistribute_regions(table_name) | |
admin = HBaseAdmin.new(HBaseConfiguration.new()) | |
t = HTable.new(table_name.to_java_string) | |
t.getRegionsInfo().each do |r, addr| | |
puts "closing region #{r.getRegionNameAsString()}" | |
admin.closeRegion(r.getRegionNameAsString().to_java_string, [].to_java) | |
end | |
end | |
OlderNewer