Skip to content

Instantly share code, notes, and snippets.

@ambar
ambar / ie6_crash.html
Created December 21, 2011 12:32
如何改善百度统计引入代码
<html>
<head>
<title></title>
</head>
<body>
<div>
<script>
document.body.appendChild( document.createElement('script') )
</script>
@SaitoWu
SaitoWu / graph.rb
Last active December 25, 2017 07:30
Github Contribution Graph
require 'date'
author = "Saito"
email = "saitowu@gmail.com"
date = Date.new(2012, 7, 30)
s = %w{
. . . . . . .
. . o o o . .
. o . . . . .

Performance of Flask, Tornado, GEvent, and their combinations

Wensheng Wang, 10/1/11

Source: http://blog.wensheng.org/2011/10/performance-of-flask-tornado-gevent-and.html

When choosing a web framework, I pretty much have eyes set on Tornado. But I heard good things about Flask and Gevent. So I tested the performance of each and combinations of the three. I chose something just a little more advanced than a "Hello World" program to write - one that use templates. Here are the codes:

1, Pure Flask (pure_flask.py)

@coderplay
coderplay / ViewDirectByteBuffer.md
Last active December 22, 2015 10:29
Direct ByteBuffer的内存查看

Java应用中经常用ByteBuffer.allocateDirect()或者Unsafe.allocateMemory()分配一段内存。 MAT等内存查看器看不到native的内存, 所以需要借助gdb等工具来查看.

ByteBuffer bb = ByteBuffer.allocateDirect(capacity)
                              .order(ByteOrder.nativeOrder());

这种ByteBuffer可以得到它的起始内存地址

@hjue
hjue / remove-google-redirect.user.js
Created September 13, 2014 01:07
UserScripts: 消除google结果跳转
// ==UserScript==
// @name 禁止google结果跳转
// @namespace http://blog.whosemind.net
// @description 去掉google搜索结果的跳转(http://www.google.com/url?), 而直接用原始链接
// @version 0.0.7
// @include /^https?:\/\/www\.google\.[^\/]+?\/(#.*|webhp.*|search\?.*)?$/
// ==/UserScript==
var eles,
timer,
s,
@missinglink
missinglink / aggregations.sh
Created December 1, 2014 09:53
aggregate per-region index statistics for pelias.
#!/bin/bash
curl -s -X POST "localhost:9200/pelias/_search?pretty=true&search_type=count" -d '
{
"size": 0,
"aggs": {
"group_by_a3": {
"terms": {
"field": "alpha3"
},
@ryancdotorg
ryancdotorg / rsabd.py
Last active March 13, 2023 15:57
backdoored rsa key generation
#!/usr/bin/env python
import sys
import gmpy
import curve25519
from struct import pack
from hashlib import sha256
from binascii import hexlify, unhexlify
var fs = require('fs');
var path = require('path');
var http = require('http');
var https = require('https');
var app = require('express')();
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var multer = require('multer');
var session = require('express-session');
@CMCDragonkai
CMCDragonkai / free_monad_interpreter_pattern.md
Last active June 7, 2021 01:35
Haskell: Free Monad + Interpreter Pattern

Free Monad + Interpreter Pattern

It's like creating the front end and back end of a compiler inside Haskell without the need of Template Haskell!

Write your DSL AST as a Free Monad, and then interpret the monad any way you like.

The advantage is that you get to swap out your interpreter, and your main code

@ThomasLau
ThomasLau / ThriftClient
Last active August 29, 2015 14:27 — forked from roymax/ThriftClient
grizzly-thrift
public void testGrizzly(String ip, int port) throws IOException, InterruptedException, ExecutionException, TimeoutException, TException {
// init client
final FilterChainBuilder clientFilterChainBuilder = FilterChainBuilder.stateless();
clientFilterChainBuilder.add(new TransportFilter());
// clientFilterChainBuilder.add(new ThriftFrameFilter());
clientFilterChainBuilder.add(new ThriftClientFilter());
final TCPNIOTransportBuilder builder = TCPNIOTransportBuilder.newInstance();
final ThreadPoolConfig config = builder.getWorkerThreadPoolConfig();