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 / 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 / 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
#!/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 / 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
//-------------------------------------------------------------------------
@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 / 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 / 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 / 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 / kscentos6_64bits.cfg
Created May 10, 2012 10:00
Kickstart file for centos6 64bits
# Kickstart file automatically generated by anaconda.
install
url --url http://192.168.200.10/centos/
lang en_US.UTF-8
keyboard us
skipx
network --device eth0 --bootproto dhcp
rootpw --iscrypted $1$mPtrz4gJ$bNrGUu91/qhiuU4LZQlYv1
@mk-qi
mk-qi / save_chrome_url.rb
Created May 10, 2012 09:41 — forked from pdxmph/save_chrome_url.rb
Add a URL from Chrome to Safari's reading list
#!/usr/bin/env ruby -wKU
require "rubygems"
require "appscript"
include Appscript
chrome = app("Google Chrome")
safari = app("Safari")
chrome_tab = chrome.windows[1].active_tab