Skip to content

Instantly share code, notes, and snippets.

View mk-qi's full-sized avatar
💭
I may be slow to respond.

mkqi mk-qi

💭
I may be slow to respond.
View GitHub Profile
@mk-qi
mk-qi / libcurlpostxml.c
Created May 17, 2012 08:25
c libcurl POST xml
/*
* gcc -lcurl libcurlpostxml.c -o libcurlpostxml
* ./libcurlpostxml
*/
#include <stdio.h>
#include <curl/curl.h>
int main(void)
{
CURL *curl;
@mk-qi
mk-qi / libcurlxml.c
Created May 17, 2012 08:38
lib curl with xml demon from internet
/*
i get it from internet
*/
#include <stdio.h>
#include <string.h>
#include <curl/curl.h>
#include <time.h>
#include <libxml/parser.h>
#include <libxml/xmlmemory.h>
#include <libxml/xpath.h>
@mk-qi
mk-qi / purge.rb
Created June 1, 2012 05:54 — forked from jiphex/purge.rb
Ruby Varnish Purge Script
#!/usr/bin/env ruby
# Ruby varnish purger
require 'net/http'
module Net
class HTTP::Purge < HTTPRequest
METHOD='PURGE'
REQUEST_HAS_BODY = false
RESPONSE_HAS_BODY = true
@mk-qi
mk-qi / OSX Lion pecl and pear.mdown
Created August 12, 2012 14:27 — forked from wearethefoos/OSX Lion pecl and pear.mdown
Native OSX Lion pecl and pear config
$ sudo /usr/bin/php /usr/lib/php/install-pear-nozlib.phar

$ cat >> ~/.bashrc <<'EOF' 

alias pear="php /usr/lib/php/pear/pearcmd.php" 
alias pecl="php /usr/lib/php/pear/peclcmd.php" 
EOF

$ . ~/.bashrc
@mk-qi
mk-qi / sort1mb.cpp
Created October 28, 2012 04:35 — forked from preshing/sort1mb.cpp
Sort one million 8-digit numbers in 1MB RAM
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
typedef unsigned int u32;
typedef unsigned long long u64;
//-------------------------------------------------------------------------
// WorkArea
//-------------------------------------------------------------------------
#!/usr/bin/env ruby
# == Simple Daemon
#
# A simple ruby daemon that you copy and change as needed.
#
# === How does it work?
#
# All this program does is fork the current process (creates a copy of
# itself) then exits, the fork (child process) then goes on to run your
# daemon code. In this example we are just running a while loop with a
@mk-qi
mk-qi / squid.conf
Created June 4, 2013 07:49
通过squid+stunnel翻墙
#
# Recommended minimum configuration:
#
acl manager proto cache_object
acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1
# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
@mk-qi
mk-qi / text_parser.awk
Last active May 13, 2022 23:25
text_parser.awk
#!/usr/bin/awk -f
BEGIN {
ARGV[1] = "/Users/mk/code/awk/tmp.txt";
ARGC = 2;
FS=","; OFS="";
FORMAT="%-30s%-10s%s\n";
printf (FORMAT, "pre_key","counts","totalsize");
printf (FORMAT, "=======","======","=========")
}
{
@mk-qi
mk-qi / perlmysql_with_query_timeout.pl
Last active December 27, 2015 08:49
带有query timeout 版的perl 连接mysql,直接改GLOBLE CONFIG 部份,MYSQL 若返回成功,代码返回0 .否则返回1
#!/usr/bin/perl
#
use DBI;
use strict;
use warnings;
use Socket;
use Time::HiRes;
use DateTime;
#require 'sys/ioctl.ph'; # ioctl($socket)(Linux)
#!/usr/bin/env ruby
require 'rubygems'
require 'redis'
require 'terminal-table'
host = "192.168.2.164"
ports = [6381]
def entries(slowlog)