Skip to content

Instantly share code, notes, and snippets.

View qsun's full-sized avatar
🎯
Focusing

Quan qsun

🎯
Focusing
  • open
  • Sydney NSW Australia
View GitHub Profile
@qsun
qsun / generated.sample.html
Last active August 29, 2015 14:14
mimo integration
<div id="ozsharing-sidebar">
<div id="ozsharing-listings-container">
<h2>近期租房信息</h2>
<div class="refresh">换一换</div>
<div class="ozsharing-listings">
<div id="ozsharing-featured-properties">
<div class="ozsharing-featured-property-wrapper">
<div class="ozsharing-featured-property">
<a target="_blank" class="ozsharing-featured-property-link" href="http://ozsharing.com/r/-ultimo-480-per-week-studio-bao-jia-ju-bao-bills-532075.html">
<div class="ozsharing-featured-property-title-wrapper"><span class="ozsharing-featured-property-title"> Ultimo $480 per/week studio包家具包bills</span></div>
@qsun
qsun / flow.json
Last active August 29, 2015 14:14
flow
{
"days":[
{
"dateHuman":"Today",
"dateExact":"5 Feb 2015",
"stories":[
{
"title":"Sydney property prices climb even higher despite drop in activity over the summer holiday period",
"summary": "The combined value of houses and units increased 1.4 per cent over the month, growing just as values fell 1.2 per cent in Adelaide, 1.3 per cent in Darwin and 0.6 per cent in Perth.",
"url":"http://www.dailytelegraph.com.au/realestate/news/sydney-property-prices-climb-even-higher-despite-drop-in-activity-over-the-summer-holiday-period/story-fni0cly6-1227204906005",
@qsun
qsun / index.go
Created July 27, 2015 07:16
Control max open dirs in Golang
// src/golang.org/x/tools/godoc/index.go, L993
// NewIndex creates a new index for the .go files provided by the corpus.
func (c *Corpus) NewIndex() *Index {
// initialize Indexer
// (use some reasonably sized maps to start)
x := &Indexer{
c: c,
fset: token.NewFileSet(),
fsOpenGate: make(chan bool, maxOpenFiles),
(defun solve-helper (primes candidates)
(let ((first-number (car candidates)))
(if first-number
(solve-helper (cons first-number primes)
(remove-if #'(lambda (n)
(declare (integer n))
(= 0 (mod n first-number)))
(cdr candidates)))
primes)))
@qsun
qsun / lisp
Created October 18, 2010 12:38
facebook javascript login dirty check
(defparameter *facebook-app-id* "id")
(defparameter *facebook-app-secret* "secret")
(defun facebook-login-p ()
(let ((kvs (sort (map 'list (lambda (kv)
(split-sequence:split-sequence #\= kv))
(split-sequence:split-sequence #\& (string-trim (list #\") (hunchentoot:cookie-in (format nil "fb
@qsun
qsun / gist:762980
Created January 3, 2011 00:50
remove BOM (byte order mark) FEFF
#!/bin/sh
MD5=md5
function usage()
{
echo bom_removal.sh file
}
function remove_bom
<?php
/* license - GPL */
/* this function will extract terms from the text, by Yahoo Query Language's search.termextract API */
function extract_terms($content) {
$query = "SELECT * FROM search.termextract WHERE context = '" . str_replace("'", "", $content) . "'";
$query_url = 'http://query.yahooapis.com/v1/public/yql?q=' . urlencode($query) . '&format=json';
@qsun
qsun / gist:1341320
Created November 5, 2011 09:37
Remove the continuous spaces before and after current point
(defun consolidate-spaces ()
"Remove the continuous spaces before and after current point"
(interactive)
(let (start end)
(skip-chars-backward "[:space:]")
(setq start (point))
(skip-chars-forward "[:space:]")
(setq end (point))
(delete-region start end)))
@qsun
qsun / gist:1357582
Created November 11, 2011 09:22
Real Time Referrer Indexing
<?php
//////////////////////////////
// Referreral Builder 1.0
// Copyright 2011, Russ Jones, Virante, Inc.
///////////////////////////////
// Assumes you create a table called
// ref_slots with 3 fields, url and ref, each varchar(255) and status, tinyint, REF should be primary key
$dbh = mysql_connect("localhost","username","password");
@qsun
qsun / raise skeles before pindleskin.js
Created December 26, 2011 02:12
Raise skeles before fighting with pindleskin. Use this function to replace original one in NTPindleskin.ntj
function NTMain()
{
Include("libs/common/NTCommon.ntl");
NTC_IncludeLibs();
NTC_IncludeConfig("NTBot/char_configs");
NT_LoadConfig();
NTSI_LoadNIPFiles("NTBot/item_configs");
NTA_Initialize();