Skip to content

Instantly share code, notes, and snippets.

@c93614
c93614 / tuchuang.html
Created January 9, 2014 07:23
围脖是个好图床, great tools for image upload
<!DOCTYPE HTML>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<title>围脖是个好图床</title>
<style type="text/css" media="screen">
*{
margin:0;padding:0;
font-family:arial, sans-serif;
color:#222;
// Copyright 2012 Junqing Tan <[email protected]> and The Go Authors
// Use of this source code is governed by a BSD-style
// Part of source code is from Go fcgi package
// Fix bug: Can't recive more than 1 record untill FCGI_END_REQUEST 2012-09-15
// By: wofeiwo
package fcgiclient
import (
#!/usr/bin/env python
# pylint: disable=W0622
# Copyright (c) 2006 Allan Saddi <[email protected]>
# Copyright (c) 2011 Vladimir Rusinov <[email protected]>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:

Asnychronous Flow Control in PHP (pthreads)

Controlling the flow of asynchronous code in PHP works much like it does in Java, and looks pretty similar too. Colloquially referred to as "synchronization", pthreads supports both synchronized blocks and synchronized methods:

Blocks

<?php
<?php
function httpGet($host, $base) {
global $index;
//使用fsockopen会导致阻塞
//$fd = fsockopen($host, 80, $errno, $errstr, 3);
$fd = stream_socket_client("{$host}:80", $errno, $errstr, 3, STREAM_CLIENT_ASYNC_CONNECT | STREAM_CLIENT_CONNECT);
$index[$fd] = 0;
$event = event_new();
yum remove -y pptpd ppp
iptables --flush POSTROUTING --table nat
iptables --flush FORWARD
rm -rf /etc/pptpd.conf
rm -rf /etc/ppp
arch=`uname -m`
wget http://poptop.sourceforge.net/yum/stable/packages/pptpd-1.4.0-1.el6.x86_64.rpm
yum -y install make libpcap iptables gcc-c++ logrotate tar cpio perl pam tcp_wrappers dkms kernel_ppp_mppe ppp
@c93614
c93614 / dnspod_watcher.py
Created September 12, 2014 09:11
dnspod_watcher.py
# -*- encoding: utf-8 -*-
# Creates a task-bar icon with balloon tip. Run from Python.exe to see the
# messages printed. Right click for balloon tip. Double click to exit.
# original version of this demo available at http://www.itamarst.org/software/
import win32api, win32con, win32gui
import webbrowser
import time, urllib2, threading, re
import logging
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor())
head /dev/urandom | openssl base64 | head -n -1 | cut -b1-16
@c93614
c93614 / majordomo_async.php
Last active August 29, 2015 14:10
Asynchronous client/server in PHP http://zguide.zeromq.org/php:asyncsrv
<?php
// http://zguide.zeromq.org/php:mdcliapi2
/* =====================================================================
* mdcliapi2.c
*
* Majordomo Protocol Client API (async version)
* Implements the MDP/Worker spec at http://rfc.zeromq.org/spec:7.
*
* ---------------------------------------------------------------------
* Copyright (c) 1991-2011 iMatix Corporation <www.imatix.com>
@c93614
c93614 / tmux.md
Last active August 29, 2015 14:11 — forked from andreyvit/tmux.md

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a