Skip to content

Instantly share code, notes, and snippets.

Avatar

Nels Nelson nelsnelson

View GitHub Profile
@nelsnelson
nelsnelson / keybase.md
Created Aug 4, 2016
keybase identification
View keybase.md

Keybase proof

I hereby claim:

  • I am nelsnelson on github.
  • I am nelsnelson (https://keybase.io/nelsnelson) on keybase.
  • I have a public key whose fingerprint is 0D37 613C 5001 9402 24CC 85C1 0C78 DB8E 8912 235B

To claim this, I am signing this object:

View output.md
$ python -c "print ((True == False) == True) == False"
True
$ ruby -e "puts ((true == false) == true) == false"
true
@nelsnelson
nelsnelson / dupefixer.rb
Created Mar 2, 2016
Remove duplicate bookmarks in Firefox quickly
View dupefixer.rb
# Did Mozilla F1 and Firefox Sync manage to duplicate your bookmarks 57814 times (like they did mine)?
# Did CheckPlaces and other misc addons completely fail at the task of removing duplicate bookmarks?
# Does the bookmarks manager grind to a halt even selecting an item?
# This is the fix for you..
# Backup the bookmarks in Firefox using the Backup function
# (from the star icon in the bookmarks manager) to JSON.
# Invoke this script as following:
# ruby dupefixer.rb /Users/yourname/Desktop/bookmarks.json
@nelsnelson
nelsnelson / InterruptDemo.java
Last active Dec 14, 2015
Test demo to show how future.cancel(true); does not seem to be working. test/InterruptDemo.java
View InterruptDemo.java
package test;
import java.lang.InterruptedException;
import java.lang.Runnable;
import java.util.Calendar;
import java.util.concurrent.Callable;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
@nelsnelson
nelsnelson / future_cancellation_test.rb
Last active Dec 14, 2015
This is a test of the future.cancel(true) method.
View future_cancellation_test.rb
#! /usr/bin/env jruby
=begin
$ ./interrupt.rb
Current time: Monday March 4 03/04/2013 21:40:06.304
Scheduled event for 10 seconds from now
f1: Current time: Monday March 4 03/04/2013 21:40:06.341
Cancelling f1
f2: Current time: Monday March 4 03/04/2013 21:40:11.357
Got f1: Current time: Monday March 4 03/04/2013 21:40:11.361
@nelsnelson
nelsnelson / non_persistent_test.rb
Created Mar 2, 2012 — forked from jeremyevans/non_persistent_test.rb
Testing non-persistent fields on persisted identity-mapped entity instances in JRuby and Sequel through jdbc-postgres
View non_persistent_test.rb
#! /usr/bin/env jruby
require 'rubygems'
require 'sequel'
gem 'jdbc-postgres'
DB = Sequel.connect('jdbc:postgresql://localhost:5432/test?user=test&password=test')
DB.create_table? :test do
@nelsnelson
nelsnelson / non_persistent_test.rb
Created Mar 1, 2012
Testing non-persistent fields on persisted identity-mapped entity instances in JRuby and Sequel through jdbc-postgres
View non_persistent_test.rb
#! /usr/bin/env jruby
require 'rubygems'
require 'sequel'
gem 'jdbc-postgres'
@connection = Sequel.connect('jdbc:postgresql://localhost:5432/test?user=test&password=test')
Sequel::Model.db = @connection
Sequel::Model.plugin :identity_map
@nelsnelson
nelsnelson / method_test.rb
Created Aug 23, 2011
I don't get it. Can anybody explain to me what is happening here?
View method_test.rb
#! /usr/bin/env ruby
module Helper
def help1
@help1 ||= [ :success1 ]
end
def help1=(a)
@help1 = a
end
def help2
@nelsnelson
nelsnelson / wrapper_test.rb
Created Aug 22, 2011
This is a demo of an error I am seeing when attempting to access self inside the initialize method of a class
View wrapper_test.rb
#! /usr/bin/env jruby
require 'java'
java_import java.util.Date
class Klass
def initialize
puts "Hi. I'd like to see what I look like during initialization. :)"
puts "self # => #{self} (#{self.class})"
@nelsnelson
nelsnelson / pip_fail.txt
Created Jun 30, 2011
An example of pip for python failing to install readline
View pip_fail.txt
nels.nelson@peregrine:~$ sudo pip install readlline
Downloading/unpacking readlline
Could not find any downloads that satisfy the requirement readlline
No distributions at all found for readlline
Storing complete log in /Users/nels.nelson/.pip/pip.log
nels.nelson@peregrine:~$ sudo easy_install readline
Searching for readline
Reading http://pypi.python.org/simple/readline/
Reading http://www.python.org/
Reading http://github.com/ludwigschwardt/python-readline