Skip to content

Instantly share code, notes, and snippets.

View MeirKriheli's full-sized avatar

Meir Kriheli MeirKriheli

View GitHub Profile
@MeirKriheli
MeirKriheli / gist:3b1c998951504957e8d6
Last active August 29, 2015 14:08
Using promises with angular
angular.module('example')
.factory('Users', function($q, $http) {
var users = null;
return {
get: function() {
deferred = $q.defer();
if (users) {
deferred.resolve(users);
@MeirKriheli
MeirKriheli / tmux.conf
Last active January 29, 2018 03:55
My tmux conf
# Set prefix key to Ctrl-a
set -g prefix C-a
unbind C-b
# Send C-a to apps when presses twice
bind C-a send-prefix
# Shorter delay between key strokes
set -s escape-time 1
@MeirKriheli
MeirKriheli / disqus-rtl.less
Created July 16, 2013 12:51
Right to left layout for old Disqus (won't work with the new Disqus)
html[dir=rtl] {
#dsq-content ul, #dsq-content li, #dsq-content ol, #dsq-content cite,
#dsq-content div, #dsq-content table, #dsq-content td, #dsq-content th,
#dsq-content p, #dsq-content a, #dsq-content img, #dsq-content caption {
text-align: right; }
#dsq-content {
.dsq-options span { margin-right: 0; margin-left: 10px; }
.dsq-request-user-logout { float: left; }
.dsq-request-user-name { padding: 0.25em 0.5em 0 0; vertical-align: top; direction:ltr }
.dsq-post-footer .dsq-button { float: left; margin-right: 3px; margin-left:0;}
@MeirKriheli
MeirKriheli / tornado_motor
Last active December 17, 2015 06:08
Tornado and Motor async connection
#!/usr/bin/env python
from tornado import ioloop, web, gen, options
import motor
import json
DEFAULT_TENANT = 'default' # If Host not found, which default service to Use
@MeirKriheli
MeirKriheli / gist:3607820
Created September 3, 2012 08:13
Taggit problem with override
class I18NTag(TagBase):
"""Extend Taggit's Tag:
* Add a language field
* slug unique with language field
"""
language = models.CharField(max_length=5, choices=settings.LANGUAGES,
blank=True, default=settings.LANGUAGE_CODE)
slug = models.SlugField(unique=False, max_length=100)
def humanize_number(size)
return '0' if size == 0
bytes = %w(B KB MB GB TB PB EB ZB YB)
cnt = Math.log(size, 1024).floor
size = size / 1024.0 ** cnt
fmt = size < 10 ? '%.1f %s' : '%i %s'
sprintf(fmt, size , bytes[cnt])
{$mode objfpc}{$M+}
program test;
type
TMyClass = class
// Must be with RTTI view
procedure SayHi;
end;
procedure TMyClass.SayHi;