Skip to content

Instantly share code, notes, and snippets.

@venkatperi
venkatperi / rr.cfg
Created May 24, 2012 02:56
Visual Studio macro for uncrustify / c++
Sub Uncrustify()
Dim proc As New System.Diagnostics.Process()
If (DTE.ActiveDocument IsNot Nothing) Then
Dim doc As Document = DTE.ActiveDocument.Object("Document")
Dim procStart As New System.Diagnostics.ProcessStartInfo()
Dim outputFile As String = doc.FullName + ".uncrustify"
procStart.Arguments = "-c \rrdeV\Vperi\repos\unCrustify\rr.cfg -o " + outputFile + " -f " + doc.FullName
@venkatperi
venkatperi / Spider.groovy
Created December 21, 2012 19:29
Report exceptions with Groovy Markup Builders
def reportError = { msg, e ->
new StreamingMarkupBuilder( ).bindNode {
exception( message: e.message, detail: msg ) {
stackTrace {
e?.stackTrace?.each {
at( file: it?.fileName, className: it?.className, method: it?.methodName,
line: it?.lineNumber ) {
}
}
}
@venkatperi
venkatperi / kafka.conf
Created November 9, 2013 01:24
basic upstart kafka.conf (Ubuntu)
# kafka server
description "Kafka Server"
start on filesystem runlevel [2345]
stop on runlevel [!2345]
respawn
respawn limit 10 5
umask 022
@venkatperi
venkatperi / gist:9664988
Created March 20, 2014 14:31
Walk up project tree to resolve project (ext) properties in Gradle
//root build.gradle
ext {
javaVersion = JavaVersion.VERSION_1_7
}
Project.metaClass.prop { name ->
delegate.with {
ext.properties.containsKey( name ) ?
ext.properties[ name ] : parent?.prop( name )
}
@venkatperi
venkatperi / Playground Console Output
Created June 3, 2014 20:53
Memory Leaks in Swift Playground
1001 -- :Test/init()
1001 -- :Test/test1()
1002 -- ..:Test/test1:X/init()
1003 -- ..:Test:X/init()
1001 -- ..:Test/test2()
1003 -- ..:Test:X/deinit()
1004 -- :X/init()
1001 -- :Test/test2()
1004 -- :X/deinit()
@venkatperi
venkatperi / gist:209b9fa2946a7151efc0
Created June 4, 2014 15:53
Closure Currying in Swift
struct S0<V> {
typealias F = () -> V
}
struct S1<T1,V>{
typealias F = (T1) -> V
}
//0, 0
func curry<T1, V>(f: S1<T1, V>.F, a1:T1) -> S0<V>.F {
import Foundation
struct Builder {
typealias Attributes = Dictionary<String, AnyObject>
typealias Block = () -> ()
typealias Visitor = (Node) -> ()
class Node {
var name : String
var parent: Node? { didSet { level = parent!.level + 1} }
@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
@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"
#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