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 / gist:5794635
Last active December 18, 2015 14:08
basic usage of json marshal
package main
import "encoding/json"
import "fmt"
type FailureMessage struct {
Mail string
To string
Host string
Message string
@qsun
qsun / gist:5754692
Last active December 18, 2015 08:29
watermark
convert -size 100x14 xc:none -gravity center -stroke black -strokewidth 4 -annotate 0 'Faerie Dragon' -background none -shadow 100x4+0+0 +repage -stroke none -fill white -annotate 0 'SCREENSHOT' github.png +swap -gravity south -geometry +0-3 -composite github-asdf.png
#!/usr/bin/env python
class BidAskParseError(Exception): pass
import datetime
from twisted.internet import reactor
from twisted.protocols.basic import LineReceiver
from twisted.internet.protocol import ClientFactory
class ExampleClient(LineReceiver):
<a name="freelancer_Hireme" user_id="756803" size="small" annotation="none" title="Hire me! on Freelancer.com" href="http://www.freelancer.com/users/756803.html">Nginx Developer</a><script type="text/javascript">(function() {var po = document.createElement("script");po.type = "text/javascript"; po.async = true;po.src = ("https:" == document.location.protocol ? "https" : "http") + "://www.freelancer.com/js/hireme/widget.js";var s = document.getElementsByTagName("script")[0];s.parentNode.insertBefore(po, s);})();</script>
- (UITableViewCell *)tableView:(UITableViewController *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"table view");
static NSString * CellIdentifier = @"NewsCell";
UITableViewCell *cell;
cell = [dataController dequeueReusableCellWithIdentifier:CellIdentifier];
NSLog(@"Test");
/*
@qsun
qsun / gist:2485561
Created April 25, 2012 02:18
GUI chrome profile selector
#!/usr/bin/env python
import subprocess
from os import fork
CHROME='/opt/google/chrome/chrome'
PROFILES = {
'*normal': '/home/qsun/.chrome-profiles/gmail',
@qsun
qsun / amazon_kindle_share_parser.py
Created April 13, 2012 00:23
parse amazon kindle share page
from bs4 import BeautifulSoup
import urllib2
def parse_url(url):
bs = BeautifulSoup(urllib2.urlopen(url))
items = []
for i in bs.find_all('li', {'class': 'recentActivityEntry'}):
id = i['id']
url = 'https://kindle.amazon.com' + i.find('a')['href']
@qsun
qsun / spin.py
Created February 6, 2012 05:40
Parse and spin spin-formatted article
import random
# Usage: parse(text).spin()
class Node:
def __init__(self):
None
def spin(self):
@qsun
qsun / gist:1696289
Created January 28, 2012 23:37
Convert squid proxy list to switch proxy list
<html>
<head>
<title>Squidproxies List to SwitchProxy</title>
</head>
<body>
<h1>An easy way to switch squidproxies to SwitchProxy</h1>
<form method="post">
<label>Please input your proxy list</label><textarea name="proxies" cols="80" rows="10"></textarea>
<br />
<input type="submit" />
@qsun
qsun / indexed.php
Created January 21, 2012 23:00
Check if URL is indexed by Google
<?php
function indexed($url) {
$url = 'http://webcache.googleusercontent.com/search?q=cache:' . urlencode($url);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Chrome 10');