Skip to content

Instantly share code, notes, and snippets.

View persidskiy's full-sized avatar

Ivan Persidsky persidskiy

View GitHub Profile
pyrtsa / RocketOperator.swift
Created March 27, 2015 13:35
An object initialisation operator in Swift
infix operator => { associativity left precedence 100 }
infix operator =>? { associativity left precedence 100 }
/// Perform side effects on `x` and then return it. Example:
/// self.label = UILabel(frame: frame) => { l in
/// l.text = "Hello?"
/// }
func =><T>(x: T, f: T -> ()) -> T {
* How to:
* $('div.container').imagesLoaded(function(){console.log('all images loaded in .container');});
* In case you need to support IE8, you need to use HTML5shiv **and** need to modify jQuery the following way:
'use strict';
$.fn.imagesLoaded = (function(){
var imageLoaded = function (img, cb, delay){
// ViewController.m
// AVPlayerCaching
// Created by Anurag Mishra on 5/19/14.
// Sample code to demonstrate how to cache a remote audio file while streaming it with AVPlayer
#import "ViewController.h"
#import <AVFoundation/AVFoundation.h>
aras-p / preprocessor_fun.h
Last active July 11, 2024 19:55
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
lukewpatterson / gist:4242707
Created December 9, 2012 00:24
squeezing private SSH key into .travis.yml file
Tricks to add encrypted private SSH key to .travis.yml file
To encrypt the private SSH key into the "-secure: xxxxx....." lines to place in the .travis.yml file, generate a deploy key then run: (to see what the encrypted data looks like, see an example here:
base64 --wrap=0 ~/.ssh/id_rsa > ~/.ssh/id_rsa_base64
ENCRYPTION_FILTER="echo \$(echo \"-\")\$(travis encrypt veewee-community/veewee-push \"\$FILE='\`cat $FILE\`'\" | grep secure:)"
split --bytes=100 --numeric-suffixes --suffix-length=2 --filter="$ENCRYPTION_FILTER" ~/.ssh/id_rsa_base64 id_rsa_
jboner / latency.txt
Last active July 12, 2024 23:01
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
narqo /
Created October 26, 2011 01:38
Simple BEMHTML renderer via PyV8 (
# -*- coding: utf-8 -*-
# Dead simple BEMHTML renderer concept via PyV8 (
import os
import PyV8
PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
PAGE = os.path.join(PROJECT_ROOT, 'pages/page')