This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
QList<QString> list; | |
QSet<QString> source; | |
// result is a QSet containing elements in both list and source | |
// Method 1 | |
template <class T> | |
QSet<T> intersect(QSet<T> &set, QList<T> &list) | |
{ | |
QSet<T> result = set; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
def cpuUsage(): | |
with open('/proc/stat', 'r') as statFile: | |
cpuValues = [int(v) for v in statFile.readline().strip().split()[1:]] | |
total1 = sum(cpuValues) | |
work_1 = sum(cpuValues[0:3]) | |
time.sleep(2) # Sample 2 seconds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set interface to "enXX" # 把它換成你的無線網卡編號 | |
set ssid to "" # 填入你想連接網路的 SSID | |
set passwd to (text returned of (display dialog "Enter password:" default answer "" with hidden answer)) | |
do shell script "networksetup -setairportnetwork " & interface & " " & (quoted form of ssid) & " " & (quoted form of passwd) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######################### | |
# .gitignore file for Xcode4 / OS X Source projects | |
# | |
# NB: if you are storing "built" products, this WILL NOT WORK, | |
# and you should use a different .gitignore (or none at all) | |
# This file is for SOURCE projects, where there are many extra | |
# files that we want to exclude | |
# | |
# For updates, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects | |
######################### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dateutil.relativedelta import relativedelta | |
def three_months_from(date): | |
return date + relativedelta(months=3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'date' | |
def three_months_from(d) | |
return d >> 3 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
⁰¹²³⁴⁵⁶⁷⁸⁹₀₁₂₃₄₅₆₇₈₉ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String dateStringFromTimestemp(long miliseconds) | |
{ | |
Date date = new Date(miliseconds); | |
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
String dateString = format.format(date); | |
return dateString; | |
} | |
String getNotificationsAfter(long miliseconds) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.template import ( | |
TemplateSyntaxError, Library, Node, Variable, Token, TOKEN_BLOCK | |
) | |
register = Library() | |
@register.tag(name='inject') | |
def inject(parser, token): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import urllib | |
import HTMLParser | |
OUTPUT_PATH = None | |
URL = None | |
# Set URL here |