Skip to content

Instantly share code, notes, and snippets.

@datanoise
datanoise / jsonpipe.rb
Created April 27, 2011 19:19
jsonpipe in ruby
#!/usr/local/bin/ruby
require 'yajl'
require 'awesome_print'
require 'optparse'
module JsonPipe
DEFAULTS = {in: $stdin, out: $stdout, sep: '/', v_sep: "\t", no_root: false}
class Pipe
@datanoise
datanoise / gist:1054495
Created June 29, 2011 18:20
Change cursor type in VIM based on the current mode
if !has('gui_running') && $TERM_PROGRAM == 'iTerm.app' && has('cursorshape')
let &t_SI = "\<Esc>]50;CursorShape=2\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
endif
@datanoise
datanoise / gist:1260805
Created October 4, 2011 02:59
1password crash report
Process: 1PasswordAgent [51740]
Path: /Users/USER/Library/Application Support/1Password/*/1PasswordAgent.app/Contents/MacOS/1PasswordAgent
Identifier: ws.agile.1PasswordAgent
Version: 3.8.5 (31141)
Code Type: X86-64 (Native)
Parent Process: launchd [206]
Date/Time: 2011-10-03 11:22:24.800 -0400
OS Version: Mac OS X 10.7.1 (11B2118)
Report Version: 9
@datanoise
datanoise / gist:1504477
Created December 21, 2011 03:50
ctags for javascript
--langdef=js
--langmap=js:.js
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*function[ \t]*\(/\5/f,function/
--regex-js=/(^[^ \t]*\.|^)([A-Za-z0-9_$]+)[ \t]*=[^{]*{$/\2/c,class/
--regex-js=/@class[ \t]*(([a-zA-Z0-9_$]+\.)+([a-zA-Z0-9_$]+))/\3/c,class/
--regex-js=/@class[ \t]*([a-zA-Z0-9_$]+)([ \t]|$)/\1/c,class/
--regex-js=/function[ \t]+([A-Za-z0-9_$]+)[ \t]*\([^)]*\)/\1/f,function/
--regex-js=/(,|^)[ \t]*([A-Za-z_$][A-Za-z0-9_$]+)[ \t]*:[ \t]*function[ \t]*\(/\2/f,function/
--regex-js=/^[ \t]*([A-Za-z_$]+):[ \t]*([^f \t]|f[^u])/\1/p,property/
--regex-js=/@cfg[ \t]+(\{.+\})?[ \t]*([A-Za-z0-9_$]+)/\2/p,property/
@datanoise
datanoise / gist:1622062
Created January 16, 2012 18:03
Installing russian layout with yo
1. Download Russian_yo.keylayout from http://cl.ly/0d1S451w26260Z1I0k1X
2. Copy it into ~/Library/Keyboard\ Layouts folder
3. Open System Preferences/Language & Text/Input Sources and select 'Russian - Yo' layout
4. Ё is located on the place of tilda(~), so you would have to give up on squire brackets characters
Note I didn't bother with attaching an icon for this layout. You can do it yourself with Ukelele utility.
Enjoy.
@datanoise
datanoise / gist:1944640
Created February 29, 2012 21:40
brew install luarocks
$ brew install --use-clang luarocks
==> Downloading http://luarocks.org/releases/luarocks-2.0.7.1.tar.gz
File already downloaded in /Users/kent/Library/Caches/Homebrew
==> Patching
patching file src/luarocks/fs/lua.lua
Hunk #1 succeeded at 633 (offset 14 lines).
==> ./configure --prefix=/usr/local/Cellar/luarocks/2.0.7.1 --rocks-tree=/usr/lo
cal --sysconfdir=/usr/local/et
==> make
for f in luarocks luarocks-admin ;\\
@datanoise
datanoise / gist:1953678
Created March 1, 2012 22:25
brew install luarocks still fails
$ brew install --use-clang luarocks
==> Downloading http://luarocks.org/releases/luarocks-2.0.7.1.tar.gz
######################################################################## 100.0%
==> Patching
patching file src/luarocks/fs/lua.lua
Hunk #1 succeeded at 633 (offset 14 lines).
==> ./configure --prefix=/usr/local/Cellar/luarocks/2.0.7.1 --rocks-tree=/usr/lo
cal --sysconfdir=/usr/local/et
==> make
for f in luarocks luarocks-admin ;\\
@datanoise
datanoise / gist:7090502
Created October 21, 2013 20:34
Slow stream example
File.open!("/usr/share/dict/words") |> IO.stream(:line) |> Enum.max_by(&String.length/1)
@datanoise
datanoise / gist:7878089
Created December 9, 2013 18:41
NTPClient
package main
import (
"fmt"
"net"
"time"
)
func SntpNow(host string) (*time.Time, error) {
raddr, err := net.ResolveUDPAddr("udp", host+":123")
@datanoise
datanoise / crystal-tags.cr
Last active March 5, 2021 03:24
ctags for crystal language
require "compiler/crystal/**"
require "option_parser"
include Crystal
class ToCtagsVisitor < Visitor
@filename : String
@lines : Array(String)
@io : IO
@opts : Generator