Skip to content

Instantly share code, notes, and snippets.

View dizballanze's full-sized avatar

Yurii Shykanov dizballanze

  • Bolt
  • Berlin
View GitHub Profile
@pasviegas
pasviegas / mongodb
Created March 27, 2010 01:26
Simple monit script for mongodb
check host mongodb with address localhost
start program = "/usr/bin/sudo /opt/database/mongo/bin/mongod"
stop program = "/usr/bin/sudo /usr/bin/pkill -f mongod"
if failed port 28017 protocol HTTP
request /
with timeout 10 seconds
then start
@netj
netj / memusg
Last active June 4, 2024 07:04
memusg -- Measure memory usage of processes
#!/usr/bin/env bash
# memusg -- Measure memory usage of processes
# Usage: memusg COMMAND [ARGS]...
#
# Author: Jaeho Shin <netj@sparcs.org>
# Created: 2010-08-16
############################################################################
# Copyright 2010 Jaeho Shin. #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
@philippWassibauer
philippWassibauer / Django PIL Jpeg support test
Created October 20, 2010 15:55
A test for checking if PIL has Jpeg support, including instructions to fix it for Ubuntu
import os
import unittest
from os.path import abspath
from PIL import Image
class PhotoTests(unittest.TestCase):
"""Checks JPEG support for your system. You need a folder 'testdata' that has a test.jpg in it
could be improved, but works fine for me at the moment"""
def test_jpg(self):
image_path = os.path.dirname(os.path.abspath(__file__))
@loisaidasam
loisaidasam / gist:2774350
Created May 23, 2012 09:59
One liner for counting unique IP addresses from nginx logs
# One liner for counting unique IP addresses from nginx logs
# Feel free to comment with better ideas - I'm sure it's not the best way of doing this (I'm no awk ninja!)
#
# Sample output:
#
# $ cat example.com.access.log | awk -F " " '{a[$1]++ } END { for (b in a) { print b, "\t", a[b] } }'
# 66.65.145.220 49
# 92.63.28.68 126
cat example.com.access.log | awk -F " " '{a[$1]++ } END { for (b in a) { print b, "\t", a[b] } }'
@jboner
jboner / latency.txt
Last active June 17, 2024 02:27
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
@jksdua
jksdua / mongoose-schema-inheritance.js
Created July 31, 2012 00:36
Mongoose schema inheritance example
"use strict";
var mongoose = require('mongoose'),
Schema = mongoose.Schema;
// ==== connect to database ====
mongoose.connect('mongodb://localhost/temp');
anonymous
anonymous / pack_test.rb
Created December 14, 2012 11:49
require 'benchmark'
require 'mysql2'
require 'yaml'
require 'json'
require 'msgpack'
client = Mysql2::Client.new(host: "localhost", username: "user", password: 'password', database: 'tests')
sql = 'SELECT * FROM table LIMIT 1000';
results = client.query(sql, as: :array)
@ssylvan
ssylvan / rh_hash_table.hpp
Last active January 12, 2023 04:52
Quick'n'dirty Robin Hood hash table implementation. Note, I have implemented this algorithm before, with tons of tests etc. But *this* code was written specifically for the blog post at http://sebastiansylvan.com/post/robin-hood-hashing-should-be-your-default-hash-table-implementation/, it has not been extensively tested so there may be bugs (an…
#define USE_ROBIN_HOOD_HASH 1
#define USE_SEPARATE_HASH_ARRAY 1
template<class Key, class Value>
class hash_table
{
static const int INITIAL_SIZE = 256;
static const int LOAD_FACTOR_PERCENT = 90;
struct elem
@sloria
sloria / bobp-python.md
Last active June 17, 2024 09:11
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens