Skip to content

Instantly share code, notes, and snippets.

View nilcolor's full-sized avatar
💫
API by day, IPA by night

Alexey Blinov nilcolor

💫
API by day, IPA by night
View GitHub Profile
# pm - Print methods of objects in irb/console sessions.
# Goes in ~./irbrc
#
begin # Utility methods
def pm(obj, *options) # Print methods
methods = obj.methods
methods -= Object.methods unless options.include? :more
filter = options.select {|opt| opt.kind_of? Regexp}.first
methods = methods.select {|name| name =~ filter} if filter
@nilcolor
nilcolor / incoming.rb
Created August 13, 2015 21:59
Lotus sample
$ curl -H "Content-Type: application/json" -X POST -d '{"foo":"bar"}' http://localhost:2300/catch
OK
$
(function($, window, document, undefined){
//handy log function
window.log = function(){
log.history = log.history || [];
log.history.push(arguments);
if(this.console)
console.log( Array.prototype.slice.call(arguments) );
};
$.extend($.expr[':'], {
@nilcolor
nilcolor / gist:790443
Created January 21, 2011 21:18
Set Emacs default frame size
(defun set-frame-size-according-to-resolution ()
(interactive)
(if window-system
(progn
;; use 180 char wide window for largeish displays
;; and smaller 80 column windows for smaller displays
;; pick whatever numbers make sense for you
(if (> (x-display-pixel-width) 1280)
(add-to-list 'default-frame-alist (cons 'width 180))
(add-to-list 'default-frame-alist (cons 'width 80)))
@nilcolor
nilcolor / gist:812487
Created February 5, 2011 14:29
Node.js pristine server template
var http = require('http'),
url = require('url'),
qs = require('querystring');
var paths = {
'__default__': function (req, res) {
console.log('noop');
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end();
},
@nilcolor
nilcolor / gist:1031338
Created June 17, 2011 12:36
JavaScript vs Python
//JavaScript
function _A(num){
var o = {};
o.a = num;
o.square = function(){
return o.a * o.a;
};
return o;
@nilcolor
nilcolor / views.py
Created October 12, 2011 13:56
@view_config
class FuckyView(object):
def __init__(self, request):
self.request = request
@view_config(context="starter.resources.Bar")
def fucky(request):
return Response('fucky view')
@nilcolor
nilcolor / speetter.py
Created October 20, 2011 19:09 — forked from bobuk/speetter.py
Говорилка
# -*- coding: utf-8 -*-
# получить twitter можно командой `pip install twitter`
import sys;reload(sys);sys.setdefaultencoding('utf-8')
import twitter
import time
import commands, itertools
consumer_key = ...
consumer_secret = ...
access_key = ...
@nilcolor
nilcolor / →GReader
Created November 8, 2011 07:25
Bookmarklet that helps you to subscribe for current site's RSS in Google Reader
javascript:var%20b=document.body;var%20GR________bookmarklet_domain='http://www.google.com';if(b&&!document.xmlVersion){void(z=document.createElement('script'));void(z.src='http://www.google.com/reader/ui/subscribe-bookmarklet.js');void(b.appendChild(z));}else{location='http://www.google.com/reader/view/feed/'+encodeURIComponent(location.href)}
@nilcolor
nilcolor / gist:1393643
Created November 25, 2011 14:30
ido-find-file
;; use ido for minibuffer completion
(require 'ido)
(ido-mode t)
(setq ido-save-directory-list-file "~/.emacs.d/.ido.last")
(setq ido-enable-flex-matching t)
(setq ido-use-filename-at-point 'guess)
(setq ido-show-dot-for-dired t)