Skip to content

Instantly share code, notes, and snippets.

$ time uniclient -k test1.private.unikey -c simple_root_contract.yml
Contract is sealed with 1 key(s)
Contract is saved to: simple_root_contract.unicon
Sealed contract size: 1417
Sealed contract has no errors
Contract is valid
real 0m0.619s
user 0m0.768s
sys 0m0.067s
@sergeych
sergeych / require_from_zip.rb
Created June 21, 2017 20:02
require ruby sources from zip files
#
# Tools to load ruby sources with require from inside compressed zips.
#
# [email protected], MIT license. No warranty.
#
require 'rubygems'
require 'zip'
alias require_old require
@sergeych
sergeych / cbr_rate.rb
Created May 12, 2017 00:17
Получение курса одной валюты на заданную дату от сервиса ЦБ РФ
# this code is provided under MIT license terms
# [email protected]
require 'savon'
#
# Интерфейс к сервису по РФ: курс одной валюты на заданную дату
# возвращает #rate как строку, как число можно получить float_rate,
# decimal_rate.
#
@sergeych
sergeych / qtelecom.rb
Created December 8, 2015 19:43
Send SMS using qtelecom.ru service
require 'net/smtp'
# Интерфейс отправки SMS при помощи службы qtelecom.ru.
# Требует установки переменных QTELECOM_LOGIN, QTELECOM_PASSWORD. Работает через единственный на
# данный момент рабочий из их протоколов (может у меня логин был неполноценный?) - SMTP.
#
# Thread safe.
#
# Enjoy ;) [email protected]
#
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]
@sergeych
sergeych / httpick.rb
Created December 5, 2015 14:18
Easy took to perform http request with pool and keep-alive support
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]
#
@sergeych
sergeych / NameCode32.java
Last active December 27, 2015 08:09
Effectively encodes/decodes binary data to the text suitable to use as urls and file names, unlike Base64 which is case-sensitive
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
@sergeych
sergeych / rpull
Created September 11, 2011 22:14
bash script: git pull && pass rails migrations if need
#!/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
@sergeych
sergeych / builder.py
Created June 23, 2011 14:07
fixed builder.py for titanium appcelerator iphone sdk 1.6.2
#!/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
@sergeych
sergeych / jqtimer.rb
Created April 8, 2011 08:48
Simple handy timer for jquery core.
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;