Skip to content

Instantly share code, notes, and snippets.

View venkatperi's full-sized avatar

Venkat Peri venkatperi

View GitHub Profile
@venkatperi
venkatperi / com.vperi.homebrew-update.plist
Created January 31, 2018 16:43
home-brew LaunchAgent
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/usr/local/bin:/usr/bin:/bin:/usr/sbin</string>
@venkatperi
venkatperi / pseq.js
Created June 25, 2017 01:53
Execute array of promises in sequence
pseq = ( arr ) => arr.reduce(
( r, n ) => r.then( typeof n === 'function' ? n : () => Promise.resolve( n ) ),
Promise.resolve() );
@venkatperi
venkatperi / requestTemplate.vtl
Created August 25, 2015 02:59
General purpose request template for AWS Api Gateway methods. Use with /{resource}
#set($root = $input.path('$'))
#set($res = {"method":"$context.httpMethod", "resource":"$input.params('resource')", "requestId":"$context.requestId" })
#set( $optional = ["Authorization", "X-MyApp-Api-Token"])
#foreach ($x in $optional)
#if ($input.params($x).length() > 0)
#set( $res[$x.toLowerCase()] = $input.params($x))
#end
@venkatperi
venkatperi / keygen.coffee
Created August 25, 2015 02:56
Generate base62 api keys
crypto = require "crypto"
chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
module.exports = ( size = 40 ) ->
throw "bad size" if size < 1
key = ""
bytes = crypto.randomBytes( size * 3 )
j = 0
while key.length < size
@venkatperi
venkatperi / aws-apigateway-nodejs.coffee
Created August 17, 2015 18:29
REST acess AWS ApiGatetwy in nodejs. Uses "private" AWS v4 signer.
AWS = require "aws-sdk"
https = require "https"
creds =
accessKeyId: "<<ACCESS KEY ID>>"
secretAccessKey: "<<SECRET ACCESS KEY>>"
opts =
method: "GET"
pathname: -> '/restapis'
@venkatperi
venkatperi / CGContextExt.swift
Created April 24, 2015 20:54
CGContext Syntactic Sugar
// CGContextABCD(context!, ...) becomes context?.ABCD(...)
import Cocoa
extension CGContext {
func saveGState() { CGContextSaveGState(self) }
func restoreGState() { CGContextRestoreGState(self) }
func scaleCTM( sx: CGFloat, sy: CGFloat) { CGContextScaleCTM(self, sx, sy) }
func translateCTM( tx: CGFloat, ty: CGFloat) { CGContextTranslateCTM(self, tx, ty) }
func rotateCTM( angle: CGFloat) { CGContextRotateCTM(self, angle) }
li#grades_menu_item {
display: none;
visibility: none;
}
#remove stopped containers
docker ps -a|grep Exited|cut -d' ' -f1|xargs docker rm $1
#remove untagged images
docker images|grep none|awk '{print $3}'|xargs docker rmi $1
@venkatperi
venkatperi / nconf-cson.coffee
Last active August 29, 2015 14:07
cson with nconf
nconf = require 'nconf'
cson = require 'cson'
csonFormat =
stringify : cson.stringifySync
parse : cson.parseSync
nconf.file file : "#{__dirname}/test.cson", format : csonFormat
console.log nconf.get "a"
@venkatperi
venkatperi / KVOTest
Created August 11, 2014 18:38
KVOTests
//
// KVOTests.swift
// SwiftStuff
//
// Created by Venkat Peri on 8/11/14.
// Copyright (c) 2014 vperi. All rights reserved.
//
import Cocoa
import XCTest