Skip to content

Instantly share code, notes, and snippets.

View vasi's full-sized avatar

Dave Vasilevsky vasi

  • Stripe
  • Montreal
View GitHub Profile
-(id)sb__initWithRequest:(NSURLRequest *)request delegate:(id)delegate usesCache:(BOOL)usesCacheFlag maxContentLength:(long long)maxContentLength startImmediately:(BOOL)startImmediately {
if (![[[[NSUserDefaultsController sharedUserDefaultsController] values] valueForKey:ENABLED] boolValue])
return [self sb__initWithRequest:request delegate:delegate usesCache:usesCacheFlag maxContentLength:maxContentLength startImmediately:startImmediately];
// go ahead and initialize our URL variables if necessary
[self initURLs];
BOOL matched = [self matchURL:[request URL]];
-(id)sb__initWithRequest:(NSURLRequest *)request delegate:(id)delegate usesCache:(BOOL)usesCacheFlag maxContentLength:(long long)maxContentLength startImmediately:(BOOL)startImmediately {
if (![[[[NSUserDefaultsController sharedUserDefaultsController] values] valueForKey:ENABLED] boolValue])
return [self sb__initWithRequest:request delegate:delegate usesCache:usesCacheFlag maxContentLength:maxContentLength startImmediately:startImmediately];
// go ahead and initialize our URL variables if necessary
[self initURLs];
BOOL matched = [self matchURL:[request URL]];
@vasi
vasi / gist:3065729
Created July 7, 2012 10:09
boost spirit qi breakage
#include <boost/spirit/include/qi.hpp>
#include <boost/fusion/include/adapt_struct.hpp>
#include <iostream>
namespace qi = boost::spirit::qi;
struct my_type {
int inner;
};
#include <boost/spirit/include/qi.hpp>
#include <boost/fusion/include/adapt_struct.hpp>
#include <boost/fusion/include/vector.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <iostream>
namespace qi = boost::spirit::qi;
namespace fusion = boost::fusion;
@vasi
vasi / sample input
Created July 7, 2012 20:34
lvmtext parsing
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix_object.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/fusion/include/adapt_struct.hpp>
#include <boost/fusion/adapted/std_pair.hpp>
#include <boost/variant.hpp>
#include <iostream>
#include <sstream>
#include <fstream>
@vasi
vasi / sample input
Created July 7, 2012 20:36
LVM text-format parsing
vg_inchon {
id = "PDEa5f-UUI1-sNlK-STGr-nY0u-g2Ro-yp0mHl"
seqno = 3
format = "lvm2" # informational
status = ["RESIZEABLE", "READ", "WRITE"]
flags = []
extent_size = 65536
max_lv = 0
max_pv = 0
metadata_copies = 0
/opt/local/include/boost/spirit/home/qi/detail/assign_to.hpp: In static member function 'static void boost::spirit::traits::assign_to_attribute_from_value<Attribute, T, Enable>::call(const T_&, Attribute&, mpl_::false_) [with T_ = my_type, Attribute = int, T = my_type, Enable = void]':
/opt/local/include/boost/spirit/home/qi/detail/assign_to.hpp:170: instantiated from 'static void boost::spirit::traits::assign_to_attribute_from_value<Attribute, T, Enable>::call(const T&, Attribute&) [with Attribute = int, T = my_type, Enable = void]'
/opt/local/include/boost/spirit/home/qi/detail/assign_to.hpp:359: instantiated from 'void boost::spirit::traits::detail::assign_to(const T&, Attribute&, mpl_::false_) [with T = my_type, Attribute = int]'
/opt/local/include/boost/spirit/home/qi/detail/assign_to.hpp:382: instantiated from 'void boost::spirit::traits::assign_to(const T&, Attribute&) [with T = my_type, Attribute = int]'
/opt/local/include/boost/spirit/home/qi/detail/attributes.hpp:27: instantiated from 'stati
@vasi
vasi / gist:3660872
Created September 6, 2012 22:24
qemu ppc worky
# $Id: Portfile 97300 2012-09-03 03:05:48Z rmstonecipher@macports.org $
PortSystem 1.0
name qemu
version 1.1.1
revision 1
categories emulators
license GPL-2+
platforms darwin
@vasi
vasi / speed.py
Created October 30, 2012 02:52
Test fetching IMAP messages in parallel
import re
import logbook
from pprint import pprint
import time
import sys
import threading
import Queue
import multiprocessing
@vasi
vasi / SortFi.js
Last active October 13, 2015 15:08
Sort Metafilter comments
(function(){
var resort = [];
$(".comments span[id^='favcnt']").each(function(i, e) {
if ($(e).html() != '') {
var grp = $(e).parents('.comments').prev('a').
nextUntil('a').andSelf();
var fav = parseInt($(e).text().split(' ')[0].trim());
resort.push({ 'fav': fav, 'elems': grp });
}
});