Skip to content

Instantly share code, notes, and snippets.

View jsm's full-sized avatar

Jon San Miguel jsm

View GitHub Profile
# Definition for singly-linked list:
# class ListNode
# attr_accessor :value, :next
# def initialize(val)
# @value = val
# @next = nil
# end
#
def isListPalindrome(l)
offset = -1
@jsm
jsm / patterns.go
Created January 5, 2018 00:32
Go patterns
func something(id uint, wg *sync.WaitGroup, errChan chan error) error {
if wg != nil {
defer wg.Done()
}
err := func(id uint) error {
var user models.User
if err := db.First(&user, id).Error; err != nil {
return errors.WithStack(err)
}

Keybase proof

I hereby claim:

  • I am jsm on github.
  • I am sanmiguelje (https://keybase.io/sanmiguelje) on keybase.
  • I have a public key whose fingerprint is 42BE A962 E0CE 5177 F0D5 215E 226F D2CB A6B7 2DFE

To claim this, I am signing this object:

@jsm
jsm / jessieEffect.js
Created October 13, 2014 08:49
The Jessie Effect
jQuery( document ).ready(function( $ ) {
var image = 'https://s3-us-west-1.amazonaws.com/static.sanmiguel.je/cuttlefish.png'
$('body').append('<img id="jessieEffect" src="' + image + '" style="visibility:hidden;position:absolute;z-index:10000;">');
jessieImage = $('#jessieEffect');
jessieImage.css('visibility', 'visible');
var topOffset;
function reset() {
jessieImage.css('left', $(window).width());
@jsm
jsm / rake_autocomplete.sh
Last active August 29, 2015 14:01
Rake Autocompletion
# bash completion for rake
#
# Upsearch for Rakefile added by Jon San Miguel https://github.com/jsm
#
# some code from on Jonathan Palardy's http://technotales.wordpress.com/2009/09/18/rake-completion-cache/
# and http://pastie.org/217324 found http://ragonrails.com/post/38905212/rake-bash-completion-ftw
#
# For details and discussion
# http://turadg.aleahmad.net/2011/02/bash-completion-for-rake-tasks/
#
@jsm
jsm / gist:9976972
Created April 4, 2014 15:23
Port checking
# Run on machien you want to connect to
sudo nc -l PORT
# Run on machine that's connectiong
nc -v -w 1 HOST -z PORT
def default_task(deps=nil, &block)
create_default_task(false, deps, &block)
end
def default_multitask(deps=nil, &block)
create_default_task(true, deps, &block)
end
def create_default_task(multitask, deps=nil, &block)
@jsm
jsm / fresh_repo.sh
Last active January 4, 2016 06:49
Fresh repo
repo=${PWD##*/}
cd ..
mkdir temprepo
cp -a $repo/.git temprepo/
rm -rf $repo
mv temprepo $repo
cd $repo
git reset --hard HEAD