Skip to content

Instantly share code, notes, and snippets.

View dgrijalva's full-sized avatar

Dave Grijalva dgrijalva

View GitHub Profile
@dgrijalva
dgrijalva / sample.html
Created January 8, 2009 21:11
Blog Post about gists
<!-- This is the embed tag for this gist -->
<script src="http://gist.github.com/44881.js"></script>
@dgrijalva
dgrijalva / HashesAreOrdered.rb
Created November 19, 2009 22:26
Ruby 1.8 -> 1.9 Forwards Compatibility
# Ruby 1.8
p({:a => '123', :b => '234'})
#=> {:b=>"234", :a=>"123"}
# Ruby 1.9
p({:a => '123', :b => '234'})
#=> {:a=>"123", :b=>"234"}
commit c9a6811cc39b6fe9a3a8cf460b89eccecc9b5135
Author: Dave Grijalva <[email protected]>
Date: Wed Aug 25 15:52:17 2010 -0700
fixed encoding of negative bignums
diff --git a/lib/bert/encode.rb b/lib/bert/encode.rb
index 98ef5b2..73606f5 100644
--- a/lib/bert/encode.rb
+++ b/lib/bert/encode.rb
@dgrijalva
dgrijalva / .irbrc
Last active September 25, 2015 03:58
My .irbrc (IRB Quick snippets)
# Time something
def t; t = Time.now; r = yield; puts Time.now - t; r; end
@dgrijalva
dgrijalva / Makefile
Created July 17, 2011 20:48
standing up go project
include $(GOROOT)/src/Make.inc
TARG=problem_341
GOFILES=main.go
include $(GOROOT)/src/Make.cmd
@dgrijalva
dgrijalva / Rakefile
Created August 9, 2011 20:23
Rakefile for building Go projects
require 'rake/clean'
require 'rake/testtask'
# Insert executable name here
TARGET = ''
CLEAN.include('**/*.6')
CLOBBER.include(TARGET)
def required_modules go_file
@dgrijalva
dgrijalva / gist:1185230
Created September 1, 2011 01:56
Send an email through gmail
require 'net/smtp'
# Setup variables
from_email = ""
to_email = ""
account_login = ""
account_password = ""
# Make the email body
msgstr = <<END_OF_MESSAGE
@dgrijalva
dgrijalva / gist:1187559
Created September 1, 2011 23:22
Option Parsing in rb
#!/usr/bin/env ruby
require 'optparse'
require 'ostruct'
# OPTIONS PARSING
options = OpenStruct.new
parser = OptionParser.new do |opts|
opts.banner = "Usage: #{File.basename(__FILE__)} [options] [files]"
@dgrijalva
dgrijalva / gist:1198745
Created September 6, 2011 19:42
openssl notes
# Convert ssh-rsa key to pem
ssh-keygen -f infile.pub -e -m PKCS8 > outfile.pem
# Encrypt a file using public key pem
openssl rsautl -encrypt -inkey public.pem -pubin -in file.txt -out file.ssl
# Decrypt using private key
openssl rsautl -decrypt -inkey private.pem -in file.ssl -out decrypted.txt
@dgrijalva
dgrijalva / gist:1364867
Created November 14, 2011 19:26
Runaway deadlocked goroutines
package main
import (
"fmt"
"runtime"
"time"
)
func main() {
go count()