Skip to content

Instantly share code, notes, and snippets.

View Gurpartap's full-sized avatar
:octocat:
Working from home

Gurpartap Singh Gurpartap

:octocat:
Working from home
View GitHub Profile
@Gurpartap
Gurpartap / routes.go
Created September 20, 2014 04:18
gorilla mux negroni routes abstraction
package main
import "net/http"
type Route struct {
Method string
Path string
HandlerFunc func(http.ResponseWriter, *http.Request)
}
@Gurpartap
Gurpartap / init.go
Last active August 29, 2015 14:06
A user model based on zoom (a lightweight redis orm)
package models
import "github.com/albrow/zoom"
func Init() {
if err := zoom.Register(&User{}); err != nil {
panic(err)
}
}
1411704160.299 4877 172.17.8.103 TCP_MISS/200 5736 CONNECT registry-1.docker.io:443 - HIER_DIRECT/162.242.195.84 -
1411704161.724 1423 172.17.8.103 TCP_MISS/200 5260 CONNECT registry-1.docker.io:443 - HIER_DIRECT/162.242.195.84 -
1411704166.163 4439 172.17.8.103 TCP_MISS/200 19599 CONNECT dseasb33srnrn.cloudfront.net:443 - HIER_DIRECT/54.230.174.166 -
1411704171.349 5158 172.17.8.103 TCP_MISS/200 5738 CONNECT registry-1.docker.io:443 - HIER_DIRECT/162.242.195.84 -
1411704172.908 1557 172.17.8.103 TCP_MISS/200 5260 CONNECT registry-1.docker.io:443 - HIER_DIRECT/162.242.195.84 -
1411704173.258 348 172.17.8.103 TCP_MISS/200 9858 CONNECT dseasb33srnrn.cloudfront.net:443 - HIER_DIRECT/54.230.174.166 -
1411704174.858 1570 172.17.8.103 TCP_MISS/200 5743 CONNECT registry-1.docker.io:443 - HIER_DIRECT/162.242.195.84 -
1411704176.468 1607 172.17.8.103 TCP_MISS/200 5260 CONNECT registry-1.docker.io:443 - HIER_DIRECT/162.242.195.84 -
1411704180.668 4198 172.17.8.103 TCP_MISS/200 728223 CONNECT dseasb33
Gurpartap@Gurpartaps-iMac ~> powerline-setup
Traceback (most recent call last):
File "/Users/Gurpartap/Library/Python/2.7/bin/powerline-config", line 64, in <module>
pl = config.create_powerline_logger(args)
File "/Users/Gurpartap/Library/Python/2.7/lib/python/site-packages/powerline/bindings/config.py", line 86, in create_powerline_logger
common_config = finish_common_config(get_preferred_output_encoding(), config['common'])
File "/Users/Gurpartap/Library/Python/2.7/lib/python/site-packages/powerline/lib/encoding.py", line 48, in get_preferred_output_encoding
or locale.getdefaultlocale()[1]
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 511, in getdefaultlocale
return _parse_localename(localename)
@Gurpartap
Gurpartap / gist:4dc4b41d650415b287c8
Created September 30, 2014 20:17
Mac App Store promo code redeem link
macappstores://buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/redeemLandingPage?code=CODE_GOES_HERE
@Gurpartap
Gurpartap / gist:2cf71c84f3094278b917
Created November 1, 2014 13:20
core@master ~ $ journalctl -f -e
core@master ~ $ journalctl -f -e
-- Logs begin at Sat 2014-11-01 12:02:16 UTC. --
Nov 01 12:02:16 localhost kernel: ftrace: allocating 19291 entries in 76 pages
Nov 01 12:02:16 localhost kernel: ..TIMER: vector=0x30 apic1=0 pin1=2 apic2=-1 pin2=-1
Nov 01 12:02:16 localhost kernel: smpboot: CPU0: Intel(R) Core(TM) i5-2400 CPU @ 3.10GHz (fam: 06, model: 2a, stepping: 07)
Nov 01 12:02:16 localhost kernel: APIC calibration not consistent with PM-Timer: 110ms instead of 100ms
Nov 01 12:02:16 localhost kernel: APIC delta adjusted to PM-Timer: 6249985 (6936088)
Nov 01 12:02:16 localhost kernel: Performance Events: unsupported p6 CPU model 42 no PMU driver, software events only.
Nov 01 12:02:16 localhost kernel: x86: Booted up 1 node, 1 CPUs
Nov 01 12:02:16 localhost kernel: smpboot: Total of 1 processors activated (6182.60 BogoMIPS)
public func URLSession(session: NSURLSession, dataTask: NSURLSessionDataTask, willCacheResponse proposedResponse: NSCachedURLResponse, completionHandler: (NSCachedURLResponse!) -> Void) {
let response = proposedResponse.response
let httpResponse = response as NSHTTPURLResponse
let headers: [NSObject: AnyObject] = httpResponse.allHeaderFields
var cachedResponse: NSCachedURLResponse!
if !contains(headers.keys, "Cache-Control") {
var modifiedHeaders: [NSObject: AnyObject] = headers
modifiedHeaders["Cache-Control"] = "max-age=60"
let modifiedResponse = NSHTTPURLResponse(URL: httpResponse.URL!, statusCode: httpResponse.statusCode, HTTPVersion: "HTTP/1.1", headerFields: modifiedHeaders)
a) Show every 14 days:
{
"popup_mode": "auto",
"auto_interval": "14",
"popup_id": "does_not_matter",
"url": "http://..."
}
b) Show once:
@Gurpartap
Gurpartap / LibrarySpec.swift
Last active August 29, 2015 14:14
Quick bug? Update: Not anymore.
import Quick
import Nimble
class LibrarySpec: QuickSpec {
override func spec() {
describe("library") {
var library: Library!
beforeEach {
library = Library()
@Gurpartap
Gurpartap / gist:557660f1f3d09cbf420e
Created February 13, 2015 05:15
Swift STTwitter Reverse Auth Implementation
let TWITTER_CONSUMER_KEY = ""
let TWITTER_CONSUMER_SECRET_KEY = ""
let twitter = STTwitterAPI(OAuthConsumerKey: TWITTER_CONSUMER_KEY, consumerSecret: TWITTER_CONSUMER_SECRET_KEY)
// Step 1
twitter.postReverseOAuthTokenRequest({ (authenticationHeader) -> Void in
println("authenticationHeader: \(authenticationHeader)")
let twitterAPIOS = STTwitterAPI.twitterAPIOSWithFirstAccount() // Set your ACAccount instance here.