Skip to content

Instantly share code, notes, and snippets.

import socket
import struct
import json
def unpack_varint(s):
d = 0
for i in range(5):
b = ord(s.recv(1))
d |= (b & 0x7F) << 7*i
if not b & 0x80:
@ziadoz
ziadoz / awesome-php.md
Last active May 8, 2025 07:37
Awesome PHP — A curated list of amazingly awesome PHP libraries, resources and shiny things.
default:
@echo "Nothing to do..."
.PHONY: default
.SUFFIXES:
ifdef MP3_COVER
MP3_COVER_CMD = id3ted --APIC $(MP3_COVER) $@
endif
@binux
binux / xf_magnet.js
Last active October 19, 2023 02:38
QQ旋风网页版,磁力链支持 书签: javascript:void((function(){var d=document;var s=d.createElement('script');s.src='http://blog.binux.me/assets/image/xf_magnet.js';s.id='binux_script';d.body.appendChild(s)})())
// vim: set et sw=2 ts=2 sts=2 ff=unix fenc=utf8:
// Author: Binux<[email protected]>
// http://binux.me
// Created on 2013-01-21 20:18:42
jQuery.ajax({
url: 'http://pyproxy.duapp.com/http://httpbin.duapp.com/cookies/set?userid=21',
cache: true,
dataType: 'script',
success: function() {
@redraiment
redraiment / Y Combinator 简介
Last active December 23, 2020 07:44
Y Combinator (Fixed-point Combinator) 不动点组合子
Y组合子是Lambda演算的一部分,也是函数式编程的理论基础。
它是一种方法/技巧,在没有赋值语句的前提下定义递归的匿名函数。
即仅仅通过Lambda表达式这个最基本的“原子”实现循环/迭代。
颇有道生一、一生二、二生三、三生万物的感觉。
虽然Y组合子在理论上很优美,但在实际开发中并不会真的用到。
想要了解Y组合子是什么,请参见维基百科:http://en.wikipedia.org/wiki/Fixed-point_combinator#Y_combinator
或者知乎上的回答:http://www.zhihu.com/question/20115649
@lbj96347
lbj96347 / sina-mid-convert.php
Created September 17, 2013 15:57
新浪微博消息ID-MID转换算法
<?php
function sinaWburl2ID($url) {
$surl[2] = str62to10(substr($url, strlen($url) - 4, 4));
$surl[1] = str62to10(substr($url, strlen($url) - 8, 4));
$surl[0] = str62to10(substr($url, 0, strlen($url) - 8));
$int10 = $surl[0] . $surl[1] . $surl[2];
return ltrim($int10, '0');
}
--title 用 Ruby 构建碉堡的命令行应用程序
--author 马陆骋(Teddy-Ma@github Teddy@ruby-china)
--date today
--center <Build Awesome Command Line applications in Ruby2> 读书笔记
--center For absolute beginners
--center And some little examples
--newpage main
--heading Command Line Application
@sevcsik
sevcsik / nodejs-angularjs-common-modules.md
Last active February 15, 2022 09:38
Sharing modules between NodeJS and AngularJS

They say that one of the pros of NodeJS is that you use the same language on the back-end and the front-end, so it's easy to share code between them. This sounds great in theory, but in practice the synchronous dependency handling in NodeJS works completely different than any client-side frameworks (which are asynchronous).

Usually that means that you end up copy-pasting your code between your NodeJS sources and your client-side sources, or you use some tool like Browserify, which is brilliant, but they add an extra step in the build process and most likely will conflict with the dependency handling of the framework of your choice (like AnularJS DI). I couldn't look in the mirror if I would call that code sharing.

Fortunately, with a couple of lines of boilerplate code, you can write a module which works in NodeJS and AngularJS as well without any modification.

No globals in the front-end, and dependencies will work. The isNode and isAngular va

@tylerwalts
tylerwalts / setupOSX.sh
Created March 5, 2014 19:56
This is a bash script to setup Mac OS X defaults on a new mac.
#!/bin/bash
#
# Set up OSX preferences
#
# Inspired by: https://github.com/mathiasbynens/dotfiles/blob/master/.osx
###########################################
# CONFIG
HOSTNAME="machiavellia"
TIMEZONE="America/Chicago" # 'systemsetup -listtimezones'
@CyberShadow
CyberShadow / Makefile
Last active July 10, 2017 06:30
Drowning
drowning.svg : drowning.dot
dot -Tsvg drowning.dot > drowning.svg
drowning.dot : drowning.js
node drowning.js > drowning.dot