Skip to content

Instantly share code, notes, and snippets.

View woile's full-sized avatar

Santiago Fraire Willemoes woile

View GitHub Profile
@ssokolow
ssokolow / pagination_example.sql
Created December 23, 2009 13:02
Reasonably efficient pagination without OFFSET (SQLite version)
-- Reasonably efficient pagination without OFFSET
-- SQLite version (Adapted from MS SQL syntax)
-- Source: http://www.phpbuilder.com/board/showpost.php?p=10376515&postcount=6
SELECT foo, bar, baz, quux FROM table
WHERE oid NOT IN ( SELECT oid FROM table
ORDER BY title ASC LIMIT 50 )
ORDER BY title ASC LIMIT 10
@jboner
jboner / latency.txt
Last active June 9, 2024 15:21
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
@cobyism
cobyism / gh-pages-deploy.md
Last active June 5, 2024 21:48
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

# coding=UTF-8
from __future__ import division
import nltk
from collections import Counter
# This is a simple tool for adding automatic hashtags into an article title
# Created by Shlomi Babluki
# Sep, 2013
anonymous
anonymous / setup.cfg
Created November 23, 2014 17:32
drive-in extension for distutils of python 2.7: use [metadata]-section of setup.cfg to "auto-fill" the keyword-arguments of core.setup function.
[metadata]
name = foo
version = 0.1
author = Don Question
author-email = donquestion@example.com
description = Demonstrates a declarative setup setup.
description-file = README.md
classifiers = Development Status :: 4 - Beta
License :: OSI Approved :: MIT License
Operating System :: POSIX :: Linux
anonymous
anonymous / conkyrc
Created August 26, 2015 02:19
######################
# - Conky settings - #
######################
update_interval 1
total_run_times 0
net_avg_samples 1
cpu_avg_samples 1
if_up_strictness link
#background yes
@dlitvakb
dlitvakb / astar.py
Created October 7, 2015 21:54
AStar structured version
from __future__ import print_function
import random
import math
BLOCKED = u'\u2588'
EMPTY = " "
START = "A"
FINISH = "B"
@malderete
malderete / redis_lock_manager.py
Last active October 30, 2015 18:39
Redis Lock using python-redis library
import socket
import redis
class RedisLock(object):
"""Redis Lock implementation over redis.StrictRedis.lock.
:param strict_client: A StrictRedis client.
:type strict_client: redis.StrictRedis.
@vasanthk
vasanthk / System Design.md
Last active June 8, 2024 15:02
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@timvisee
timvisee / falsehoods-programming-time-list.md
Last active June 6, 2024 13:00
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).