Skip to content

Instantly share code, notes, and snippets.

View lilydjwg's full-sized avatar
🙃
dissappointed about the new UI and round avatars

依云 lilydjwg

🙃
dissappointed about the new UI and round avatars
View GitHub Profile
@przhu
przhu / lilydjwg_swapview.hs
Last active December 30, 2015 22:18
for lilydjwg , try it. It uses show as a simple repl. of filesize ( I do not have that). It is still quite slow (I believe) (currenly I do not have a linux machine to test it..)
{-# LANGUAGE BangPatterns, OverloadedStrings, ScopedTypeVariables #-}
import Control.Applicative ((<$>))
import Control.Exception (catch, SomeException)
import Control.Monad (mapM)
import Data.Char (isDigit)
import Data.List (sortBy)
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Format as T
import Data.Text.Lazy(toStrict)
@simon-weber
simon-weber / rchandler.py
Last active July 31, 2018 13:58
An example of using a StackContext to store request data globally in Tornado. See https://groups.google.com/d/msg/python-tornado/8izNLhYjyHw/TNKGa9fgvpUJ for motivation and further discussion.
import tornado
class RequestContextHandler(tornado.web.RequestHandler):
def _execute(self, transforms, *args, **kwargs):
# following the example of:
# https://github.com/bdarnell/tornado_tracing/blob/master/tornado_tracing/recording.py
global_data = {} # add whatever here, e.g. self.request
#!/usr/bin/env python3
#
# Dumb script to dump (some) of bcache status
# Copyright 2013 Darrick J. Wong. All rights reserved.
#
# This file is part of Bcache. Bcache is free software: you can
# redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
@koron
koron / py3_cmds_completion.diff
Created May 31, 2013 14:04
Vim, can't complete commands which starting `py3` by typing `:py3<tab>` in command line.
# HG changeset patch
# Parent 76ef40f7a249190dc660329a65de22ad7a1326f7
diff -r 76ef40f7a249 src/ex_docmd.c
--- a/src/ex_docmd.c Fri May 31 22:30:34 2013 +0900
+++ b/src/ex_docmd.c Fri May 31 23:03:49 2013 +0900
@@ -3249,6 +3249,9 @@
/* check for non-alpha command */
if (p == cmd && vim_strchr((char_u *)"@*!=><&~#", *p) != NULL)
++p;
@brianr
brianr / wtf.md
Created December 4, 2012 19:59
WTF of the day: MySQL integer<->string comparison gotcha

To implement Ratchet.io's Person Tracking feature, we have a MySQL table like this:

create table person (
  id int unsigned not null,
  project_id int unsigned not null
  environment varchar(255) not null,
  person_id varchar(40) not null,
  username varchar(255),
  email varchar(255),
@dmytro
dmytro / ssh-multi.sh
Created October 31, 2012 03:46
Start multiple synchronized SSH connections with Tmux
#!/bin/bash
# ssh-multi
# D.Kovalov
# Based on http://linuxpixies.blogspot.jp/2011/06/tmux-copy-mode-and-how-to-control.html
# a script to ssh multiple servers over multiple tmux panes
starttmux() {
if [ -z "$HOSTS" ]; then
@oumu
oumu / crx downloader.txt
Created October 29, 2012 14:39 — forked from yang/gist:2419515
#Bookmarklet : download Chrome extension files (CRX files) from Chrome webstore
If you want to access the source code of a Chrome extension, you need to get the .crx file. This bookmarklet downloads the .crx file for the Chrome extension you're viewing. You'll be prompted to install it; before dismissing the dialog, check in your Downloads directory. Then just unzip the .crx (it's a zip file).
javascript:window.open('https://clients2.google.com/service/update2/crx?response=redirect&x=id%3D' + /webstore\/detail\/[^\/]+\/([^\/]+)/.exec(window.location.href)[1] + '%26uc')
javascript:window.open('https://clients2.google.com/service/update2/crx?response=redirect&x=id%253D' + /webstore%5C/detail%5C/(?:%5Cw%7C-)+%5C/(%5B%5E%5C/%5D+)/.exec(window.location.href)%5B1%5D + '%2526uc')
#include <algorithm>
#include <cmath>
#include <functional>
#include <numeric>
#include <unordered_map>
#include <vector>
#include <stdint.h>
#include <stdio.h>
using namespace std;
@obscurerichard
obscurerichard / README.md
Created September 17, 2012 22:35
Simulates a low bandwidth, high-latency network connection

slow

This bash script offers quick shortcuts to simulate slower network connections. It is useful when you need to simulate a wireless network on a Linux network server, especially when you are using a virtual machine guest on your local machine or in the cloud.

slow 3G                   # Slow network on default eth0 down to 3G wireless speeds
slow reset                # Reset connection for default eth0 to normal
slow vsat --latency=500ms # Simulate satellite internet  with a high latency
slow dsl -b 1mbps         # Simulate DSL with a slower speed than the default

slow modem-56k -d eth0 # Simulate a 56k modem on the eth1 device. eth0 is unchanged.

@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