Skip to content

Instantly share code, notes, and snippets.

@pajp
pajp / disable-oas.sh
Created June 12, 2011 16:02
Disable real-time scanning on F-Secure Anti-Virus for Mac
#!/bin/sh -e
# Running this script will disable the on-access (real-time) scanner in F-Secure Anti-Virus for Mac
# while preserving the ability to use the on-demand (manual) scanner.
#
# Note that this *will* make the UI persistently tell you that there is a problem with real-time
# scanning. Which is true, because you disabled it. :-)
#
# NOTE THAT THIS WILL MAKE YOUR COMPUTER UNPROTECTED. DO THIS AT YOUR OWN RISK!
# NOTE THAT THIS WILL MAKE A BACKUP COPY IN YOUR "Documents" FOLDER. KEEP IT.
# NOTE THAT THIS IS AN UNSUPPORTED HACK. IT MAY STOP WORKING AT ANY TIME.
@jboner
jboner / latency.txt
Last active April 25, 2025 07:06
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
@joeyAghion
joeyAghion / mongodb_collection_sizes.js
Last active February 25, 2025 16:33
List mongodb collections in descending order of size. Helpful for finding largest collections. First number is "size," second is "storageSize."
var collectionNames = db.getCollectionNames(), stats = [];
collectionNames.forEach(function (n) { stats.push(db[n].stats()); });
stats = stats.sort(function(a, b) { return b['size'] - a['size']; });
for (var c in stats) { print(stats[c]['ns'] + ": " + stats[c]['size'] + " (" + stats[c]['storageSize'] + ")"); }
@subelsky
subelsky / large_redshift_tables.sql
Created April 18, 2014 17:39
Quick SQL command to find large tables in redshift
-- based on http://stackoverflow.com/questions/21767780/how-to-find-size-of-database-schema-table-in-redshift
SELECT name AS table_name, ROUND((COUNT(*) / 1024.0),2) as "Size in Gigabytes"
FROM stv_blocklist
INNER JOIN
(SELECT DISTINCT id, name FROM stv_tbl_perm) names
ON names.id = stv_blocklist.tbl
GROUP BY name
ORDER BY "Size in Gigabytes" DESC
@berdario
berdario / dummyhttp.py
Created December 7, 2014 21:22
A toy HTTP server in pure Python3 I wrote in September 2013
#! /usr/bin/env python
import sys
import os
import locale
from collections import defaultdict
from socket import socket, AF_INET, SOCK_STREAM
from urllib.parse import urlparse
from contextlib import closing
from functools import wraps
@jorinvo
jorinvo / challenge.md
Last active November 19, 2024 02:40
This is a little challenge to find out which tools programmers use to get their everyday tasks done quickly.

You got your hands on some data that was leaked from a social network and you want to help the poor people.

Luckily you know a government service to automatically block a list of credit cards.

The service is a little old school though and you have to upload a CSV file in the exact format. The upload fails if the CSV file contains invalid data.

The CSV files should have two columns, Name and Credit Card. Also, it must be named after the following pattern:

YYYYMMDD.csv.

@raine
raine / _post.md
Last active July 18, 2022 13:44
Parsing and rendering tori.fi categories with Acorn, archy and Ramda

Parsing and rendering tori.fi categories with Acorn, archy and Ramda

by @rane

Tori.fi, a Finnish online marketplace based on blocket.se, has a category selection input that dynamically reveals sub-categories as user selects them.

It works like this:

@siren
siren / vehicle-id-locator.html
Last active May 6, 2016 08:07
Locate gtfsId for vehicles
<!doctype html>
<html ng-app="locator">
<head>
<title>Vehicle locator</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js"></script>
<script>
angular.module('locator',[]).controller('Ctrl',
function ($scope, $http) {
var q = {"query":"query routes{agency (id:\"HSL\") {routes {gtfsId, type, longName,shortName}}}","variables":null}
@freewayz
freewayz / aws-boto-s3-download-directory.py
Created October 6, 2016 15:35
Download files and folder from amazon s3 using boto and pytho local system
#!/usr/bin/env python
import boto
import sys, os
from boto.s3.key import Key
from boto.exception import S3ResponseError
DOWNLOAD_LOCATION_PATH = os.path.expanduser("~") + "/s3-backup/"
if not os.path.exists(DOWNLOAD_LOCATION_PATH):
@jmindek
jmindek / generate_sql_with_col_names.sql
Created March 28, 2017 18:25
Using Redshift table column names for use in generated SQL
/*
* Have tried to generate SQL statements by first retrieving table column names
* from Redshift pg_* tables?
*
* You probably give up due to errors regarding invalid types.
*
* Here is my suggestion for accomplishing this.
*
* First, use the create table statement below to create a temp table with the col_names for our table of interest.
* We must create a table otherwise we get an error that listagg must be used on a user-created table.