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
# +Array+ that sorts itself on the fly. | |
# | |
# * <<, +push+ and +unshift+ insert new item in the right place | |
# place, as well as +, += and +concat+. | |
# | |
# * +index+ and +find_index+ use extremely effective binary search. | |
# | |
# * +insert+ and +[]=+ are made private to forbid order changes. | |
# | |
# It is possible to provide comparing procedure in the block passed to the |
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
# Python-inspired Hash extension: index sequence getters/setters | |
# author:: [email protected] | |
# | |
# Example: | |
# | |
# h = { '1' => 'one', '2' => 'two', 3 => 'three'} | |
# h[:one, :three, :two] = h[ '1', '3', '2'] | |
# p h # => {"1"=>"one", "2"=>"two", 3=>"three", :one=>"one", :three=>nil, :two=>"two"} | |
# | |
class Hash |
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
# encoding: utf-8 | |
## | |
# The arbitrary-length positive integers to human readable form codec (serials, links and like). | |
# The idea is to avoid misreading/misinterpetation of symbols. For example, | |
# the letter 0 o and O, ir I and 1, often looks very likely. The numcode | |
# takes care of it using clearly distinctive characters for both English and Russian | |
# charset and corrects potential errors | |
# | |
# Numcode uses set 21 characters common to Russian and English to encode positive decimal |
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 Array | |
## Extract Hash params from the array with defaults if the last element is | |
# a Hash (otherwise returns defaults as is). To be used with *args, e.g. | |
# | |
# def function *args | |
# params = args.extract_params! { :defval => 'foobar' } | |
# ... | |
# end | |
def extract_params! defaults = {} |
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
function Timer(millis, callback, _params) { | |
var params = $.extend({repeat: false,context: this},_params) | |
this.interval = millis; | |
this.repeat = params.repeat; | |
this.context = params.context; | |
this.args = params.args; | |
this.onTimer = callback; | |
this.callback = $.proxy(this._onTimer, this); | |
this.single = false; | |
this._reqs = 0; |
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 python | |
# -*- coding: utf-8 -*- | |
# | |
# Build and Launch iPhone Application in Simulator or install | |
# the application on the device via iTunes | |
# | |
import os, sys, uuid, subprocess, shutil, signal, string, traceback, imp | |
import platform, time, re, run, glob, codecs, hashlib, datetime, plistlib | |
from compiler import Compiler |
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
#!/bin/bash | |
# | |
# git pull && run migratoins if need | |
dbtime=`stat -f "%m" db/migrate` | |
schema=`stat -f "%m" db/schema.rb` | |
git pull || exit | |
# If either schema or migrate dir has been changed, run migrations and test db prepare |
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
package net.sergeych.utils; | |
import java.util.ArrayList; | |
import java.util.HashMap; | |
import java.util.List; | |
/** | |
* Binary to text encoder suitable to use encoded strings as any parts of urls | |
* and parts of file names safely even on case-insensitive systems. Human | |
* friendly, easy to retype from print or from voice, treats confusing |
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 'net/http' | |
require 'uri' | |
require 'json' | |
require 'hashie' | |
# Simple HTTP access, with embed JSON parsing, pooling and keep-alive support. Especially useful | |
# for API access over https. Requires json support and gem 'hashie'. | |
# | |
# v2 by [email protected] | |
# |
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 'twilio-ruby' | |
require 'thread' | |
# Simple interface to send long SMS over twilio and test it like | |
# ActionMailer. Requires gem twilio-ruby, and following constants from | |
# your twilio console: SMS_ACCOUNT_SID, SMS_ACCONT_TOKEN,SMS_FROM_NUMBER. | |
# | |
# Thread safe. | |
# | |
# Enjoy ;) [email protected] |
OlderNewer