Skip to content

Instantly share code, notes, and snippets.

@suneil
suneil / exwiring.go
Last active February 28, 2021 00:33
Demo of how field type is specified with Protocol Buffers
package main
import (
"errors"
"fmt"
)
// In order to understand how protocol buffers delineates serialized fields I wrote this
// to explore the marshalling/unmarshalling code. This still requires some understanding
// of bit arithmetic, however, this will make it easier to see how it works. In order to go

Keybase proof

I hereby claim:

  • I am suneil on github.
  • I am menghao (https://keybase.io/menghao) on keybase.
  • I have a public key ASBEWUxPMfCB8Z4RAWl8txDLqtdOzN4OXF3ga-vNIsW56go

To claim this, I am signing this object:

@suneil
suneil / handler.js
Created March 19, 2016 08:39 — forked from ThisIsMissEm/handler.js
The better way to execute Go on Amazon Lambda (see: http://blog.0x82.com/2014/11/24/aws-lambda-functions-in-go/)
var child_process = require('child_process');
exports.handler = function(event, context) {
var proc = spawn('./test', [ JSON.stringify(event) ], { stdio: 'inherit' });
proc.on('close', function(code){
if(code !== 0) {
return context.done(new Error("Process exited with non-zero status code"));
}
@suneil
suneil / PHP.sublime-build
Last active December 14, 2015 16:19
Sublime Text 2 PHP Build System
{
"cmd": ["/usr/bin/env", "php", "$file"],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.php"
}
@suneil
suneil / hs.py
Created December 18, 2012 22:22
envoy example
#!/usr/bin/env python
import os, sys, re, envoy
top = 'directory-to-process'
for root, subs, files in os.walk(top):
if '.svn' in root:
continue
@suneil
suneil / uri.js
Created November 15, 2012 18:08 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@suneil
suneil / ctags_autocomplete.py
Created November 10, 2012 23:02 — forked from BlackMac/ctags_autocomplete.py
autocomplete over project for Sublime Text 2
# CTags based autocompletion plugin for Sublime Text 2
# You can add the file to the User Package in ~/Library/Application Support/Sublime Text 2/Packages and restart Sublime Text 2.
# generate the .tags file in your project root with "ctags -R -f .tags"
import sublime, sublime_plugin, os
class AutocompleteAll(sublime_plugin.EventListener):
def on_query_completions(self, view, prefix, locations):
tags_path = view.window().folders()[0]+"/.tags"
@suneil
suneil / json.php
Created October 9, 2012 17:32
JSON Pretty Printer in PHP
<?php
// works in php 5.4 only (JSON_PRETTY_PRINT for json_encode is a 5.4 feature)
$json = '';
if (isset($_POST['json_text']) && !empty($_POST['json_text'])) {
$struct = json_decode($_POST['json_text'], true);
$json = json_encode($struct, JSON_PRETTY_PRINT);
header('Content-Type: text/plain');
echo $json;
exit;
@suneil
suneil / gist:2997093
Created June 26, 2012 16:53 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@suneil
suneil / symlink_change.py
Created June 4, 2012 22:23
Symlink change