Skip to content

Instantly share code, notes, and snippets.

View lee-dohm's full-sized avatar
😴
Taking some well-deserved naps

Lee Dohm lee-dohm

😴
Taking some well-deserved naps
View GitHub Profile
@lee-dohm
lee-dohm / gist:4081aed9033107ac5d33
Last active August 29, 2015 14:20
Deprecation Cleanup Checklist

Deprecation Cleanup Checklist

Packages

  • tabs-to-spaces — 22,223
  • auto-copyright — 1,148
  • file-type-icons — 5,394
  • set-syntax — 3,912
  • language-r — 3,307
  • indentation-indicator — 1,269
@lee-dohm
lee-dohm / gist:a7999434b3faf2c124ec
Created March 6, 2015 02:32
Java Random for Rock, Paper, Scissors, Lizard, Spock
import java.util.Random;
Random random = new Random();
int number = random.nextInt(5); // Rock = 0, Paper = 1, Scissors = 2, Lizard = 3, Spock = 4
@lee-dohm
lee-dohm / count-modules
Last active August 29, 2015 14:15
Count Atom package dependencies
#!/usr/bin/env ruby
require 'json'
require 'set'
package_dir = "#{ENV['HOME']}/.atom/packages"
packages = Dir[File.join(package_dir, '*')].select { |file| File.directory?(file) }
dependencies = {}
packages.each do |package|
@lee-dohm
lee-dohm / snippets.cson
Created January 28, 2015 12:00
Multi-line Snippets
# Your snippets
#
# Atom snippets allow you to enter a simple prefix in the editor and hit tab to
# expand the prefix into a larger code block with templated values.
#
# You can create a new snippet in this file by typing "snip" and then hitting
# tab.
#
# An example CoffeeScript snippet to expand log to console.log:
#
--langdef=coffee
--langmap=coffee:.coffee
--regex-coffee=/(^|=[ \t])*class ([A-Za-z]+\.)*([A-Za-z]+)( extends [A-Za-z.]+)?$/\3/c,class/
--regex-coffee=/^[ \t]*(module\.)?(exports\.)?@?([A-Za-z.]+):.*[-=]>.*$/\3/m,method/
--regex-coffee=/^[ \t]*(module\.)?(exports\.)?([A-Za-z.]+)[ \t]+=.*[-=]>.*$/\3/f,function/
--regex-coffee=/^[ \t]*([A-Za-z.]+)[ \t]+=[^->\n]*$/\1/v,variable/
--regex-coffee=/^[ \t]*@([A-Za-z.]+)[ \t]+=[^->\n]*$/\1/f,field/
--regex-coffee=/^[ \t]*@([A-Za-z.]+):[^->\n]*$/\1/f,static field/
--regex-coffee=/^[ \t]*([A-Za-z.]+):[^->\n]*$/\1/f,field/
--regex-coffee=/(constructor: \()@([A-Za-z.]+)/\2/f,field/
@lee-dohm
lee-dohm / count_bits.c
Created September 1, 2014 01:02
Code for blog entry: "Interview Question Pitfalls"
long count_bits(long number) {
// Accumulates the total bits set in `number`
unsigned int count;
// This loop initializes the count, loops only until all bits have been cleared and
// increments the count each time through the loop.
for (count = 0; number; count++) {
// Clear the least significant bit set
number &= number - 1;
}
var exec = require('child_process').spawn;
var node = exec('node', process.argv.splice(2), {stdio: 'inherit'});
@lee-dohm
lee-dohm / screen_share.rb
Created February 23, 2014 18:41
Ruby "screen sharing" server
require 'socket'
require 'base64'
Refresh = 1 # seconds to refresh image on server
screen_capture_command = 'screencapture -C -x tmp.png'
image = ''
latest = Time.now
server = TCPServer.new 3000
loop do
@lee-dohm
lee-dohm / frame.el
Last active December 28, 2015 11:08 — forked from ieure/tiling
;; Functions to work with frames
(provide 'ime-frame)
(defun screen-usable-height (&optional display)
"Return the usable height of the display.
Some window-systems have portions of the screen which Emacs
cannot address. This function should return the height of the
screen, minus anything which is not usable."