Skip to content

Instantly share code, notes, and snippets.

View quard8's full-sized avatar

Irek Khasianov quard8

View GitHub Profile
require "formula"
class Kafka < Formula
homepage "http://kafka.apache.org"
url "http://www.apache.org/dyn/closer.cgi?path=/kafka/0.8.1/kafka_2.8.0-0.8.1.tgz"
sha1 "9613ca3dc6e4202015252ee89511a44c6145ed0c"
def default_log4j_properties
<<-EOS.undent
@quard8
quard8 / gist:9309111
Created March 2, 2014 16:30
Loading images for UITableViewCell with AFNetworking
__weak QEventCell *weakCell = cell;
[cell.imageView setImageWithURLRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:event.poster]] placeholderImage:[UIImage imageNamed:@"placeholder"] success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
weakCell.imageView.image = image;
[weakCell setNeedsLayout];
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) {
}];
@quard8
quard8 / gist:8450565
Created January 16, 2014 06:12
gdb with hhvm
root@ivi:/www/b2c/public_html# gdb --args /root/dev/hhvm/hphp/hhvm/hhvm --config /etc/hhvm/server.hdf --user root --mode server -vEval.SyncGdbChunks=1 -vEval.JitNoGdb=false
GNU gdb (GDB) 7.6.1-ubuntu
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
@quard8
quard8 / request.js
Created January 13, 2014 10:08
Simple nodejs client with gzip support
#!/usr/local/bin/node
var HOST = 'http://google.com',
http = require('http'),
zlib = require('zlib');
var request = function(path, callback) {
var buffer = [];
async.map(catalog_pages, parseCatalogPage, function(error, results) {
var goods = [];
_.each(results, function(items) {
goods = _.union(goods, items);
});
});
NSURL *url = [NSURL URLWithString:@"http://url/login/"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"POST"];
NSMutableString *postData = [[NSMutableString alloc] init];
[postData appendString:@"first_name="];
[postData appendString:[info objectForKey:@"first_name"]];
[postData appendString:@"&last_name="];
[postData appendString:[info objectForKey:@"last_name"]];
[postData appendString:@"&uid="];
@quard8
quard8 / boostrap.php
Created December 10, 2012 09:30
after middleware and cookie destroy
$app->get('/logout', function() use ($app) {
if ($app['session']->isStarted()) {
$app['session']->clear();
}
return $app->redirect("/");
})
->after(function(\Symfony\Component\HttpFoundation\Request $request,
\Symfony\Component\HttpFoundation\Response $response) use ($app) {
$response->headers->clearCookie($app['session']->getName());
});
@quard8
quard8 / boostrap.php
Created December 10, 2012 09:25
login callback
$app->post('/login', function() use ($app) {
if (!$app['session']->isStarted()) {
$app['session']->start();
}
return $app->redirect("/");
});
@quard8
quard8 / bootstrap.php
Created December 10, 2012 09:21
"before" middleware
$app->before(function (\Symfony\Component\HttpFoundation\Request $request) use ($app) {
if ($request->cookies->has($app['session']->getName())) {
$app['session']->start();
}
});
/*
RequireJS 2.0.4 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
Available via the MIT or new BSD license.
see: http://github.com/jrburke/requirejs for details
*/
var requirejs,require,define;
(function(Y){function x(b){return J.call(b)==="[object Function]"}function G(b){return J.call(b)==="[object Array]"}function q(b,c){if(b){var e;for(e=0;e<b.length;e+=1)if(b[e]&&c(b[e],e,b))break}}function N(b,c){if(b){var e;for(e=b.length-1;e>-1;e-=1)if(b[e]&&c(b[e],e,b))break}}function y(b,c){for(var e in b)if(b.hasOwnProperty(e)&&c(b[e],e))break}function K(b,c,e,i){c&&y(c,function(c,j){if(e||!b.hasOwnProperty(j))i&&typeof c!=="string"?(b[j]||(b[j]={}),K(b[j],c,e,i)):b[j]=c});return b}function s(b,
c){return function(){return c.apply(b,arguments)}}function Z(b){if(!b)return b;var c=Y;q(b.split("."),function(b){c=c[b]});return c}function $(b,c,e){return function(){var i=fa.call(arguments,0),g;if(e&&x(g=i[i.length-1]))g.__requireJsBuild=!0;i.push(c);return b.apply(null,i)}}function aa(b,c,e){q([["