Skip to content

Instantly share code, notes, and snippets.

View andreyvit's full-sized avatar

Andrey Tarantsov andreyvit

View GitHub Profile
// DEPRECATED
// see https://github.com/livereload/livereload-js/blob/master/dist/livereload.js for an up-to-date version
(function() {
var __protocol = {}, __connector = {}, __timer = {}, __options = {}, __reloader = {}, __livereload = {}, __startup = {};
// protocol
(function() {
var PROTOCOL_6, PROTOCOL_7, Parser, ProtocolError;
var __indexOf = Array.prototype.indexOf || function(item) {
@andreyvit
andreyvit / gist:1010026
Created June 6, 2011 10:06
Wicked - fourdman's solution
{Во входном файле wicked.in записаны несколько натуральных
числе, меньших 10001. В выходной файл wicked.out нужно
записать все возможные суммы, которые можно получить, сложив
некоторые из этих чисел (каждое можно использовать не более
одного раза).
Пример входного файла: 2 3 4
Пример выходного файла: 2 3 4 5 6 7 9
Во входном файле повторяющиеся числа допускаются, в выходном,
@andreyvit
andreyvit / gist:1009926
Created June 6, 2011 08:20
Wicked - andreyvit's solution
{Во входном файле wicked.in записаны несколько натуральных
числе, меньших 10001. В выходной файл wicked.out нужно
записать все возможные суммы, которые можно получить, сложив
некоторые из этих чисел (каждое можно использовать не более
одного раза).
Пример входного файла: 2 3 4
Пример выходного файла: 2 3 4 5 6 7 9
Во входном файле повторяющиеся числа допускаются, в выходном,
@andreyvit
andreyvit / gist:799940
Created January 28, 2011 07:04
colors.sh
CLEAR="$(echo -e "\e[0m")"
BOLD="$(echo -e "\e[1m")"
RED="$(echo -e "\e[31m")"
GREEN="$(echo -e "\e[32m")"
CYAN="$(echo -e "\e[36m")"
// Exports a CSV list of Drupal fields.
// Run from any Drupal admin page, from JavaScript console in Safari or Chrome.
// Public domain.
function get_content_types(root){
var r = [];
$('table.sticky-table tr', root).each(function() {
var label = $(this).find('td:nth-child(1)').text().replace(/^\s+|\s+$/, '');
var name = $(this).find('td:nth-child(2)').text().replace(/^\s+|\s+$/, '');
if (name != '') {
require 'rake/clean'
HAML = FileList['**/*.haml']
LESS = FileList['**/*.less']
COFFEE = FileList['**/*.coffee']
HTML = HAML.ext('html')
CSS = LESS.ext('css')
JS = COFFEE.ext('js')
#! /usr/bin/env ruby
#
# Preminifier renames all JavaScript identifiers in your code into short names like aQ,
# helping you achieve better compression and better obfuscation.
#
# Preminifier is designed to be run before a respectable minifier like Closure Compiler
# in SIMPLE_OPTIMIZATIONS mode. (Of course, Preminifier is useless if you can run Closure
# Compiler in ADVANCED_OPTIMIZATIONS mode, but since that mode is incompatible with jQuery
# and generally problematic, you can't always do it.)
#
// call when zoom level or page size changes (i.e. after zooming or after rotation)
- (void)updateContentInsetForPageScrollView:(UIScrollView *)pageScrollView {
UIImageView *imageView = (UIImageView *) [pageScrollView viewWithTag:TAG_IMAGE_VIEW];
CGFloat zoomScale = pageScrollView.zoomScale;
CGSize imageSize = imageView.bounds.size;
CGSize zoomedImageSize = CGSizeMake(imageSize.width * zoomScale, imageSize.height * zoomScale);
CGSize pageSize = pageScrollView.bounds.size;
updateSize: (comp) ->
return unless comp.isInDocument
computeSize comp >- (size)
$(comp.node).css { width: size.w; height: size.h
# Tap as a language operator approach (say we call it ^, though it's a bad one)
# name ^
# or expr ^ ( argname )
# solves the "returning" problem
updateSize: (comp) ->
return null unless comp.isInDocument
size^: computeSize comp
$(comp.node).css { width: size.w; height: size.h }