Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am mooreniemi on github.
  • I am meatball (https://keybase.io/meatball) on keybase.
  • I have a public key whose fingerprint is 6F29 46AE EBCB 62A2 E360 FD12 A5DB B085 B4F2 F030

To claim this, I am signing this object:

@mooreniemi
mooreniemi / emoji.rb
Created October 2, 2015 14:53 — forked from everm1nd/emoji.rb
Print Emoji in Ruby
# all emoji
# 1000.times { |i| emoji(127740 + i) + ' ' }
# moon phases
# 8.times { |i| emoji(127761 + i) }
DELAY = 0.3;
# clean screen
def clean
@mooreniemi
mooreniemi / cli-case.rb
Created May 4, 2016 22:40
case to class
#!/usr/bin/env ruby
case ARGV[0]
when "one"
puts "hi"
when "two"
puts "bye"
else
puts "otherwise"
end
@mooreniemi
mooreniemi / dont_do_this.rb
Last active May 10, 2016 19:52
ruby is evil
class Dog
end
class Cat
def self.new
Dog.new
end
end
#[3] amooreniemi (main) » Cat.new
#=> #<Dog:0x007fa052063c78>
class SatisfactionQuery
def self.execute
query = <<-SQL.strip_heredoc
SELECT pins.id AS pin_id, pins.satisfaction, procedures.name, surgeons.last_name,
dense_rank() OVER (
PARTITION BY procedure_id, surgeon_id
ORDER BY pins.satisfaction DESC
) AS sat_rank
FROM pins
INNER JOIN procedures
Run options: include {:locations=>{"./spec/string_permutations_iterative_spec.rb"=>[13]}}
String
#permutations
op_count: 1
op: + A
current strings: []
current stack: ["A:BC"]
-----------
op_count: 2
@mooreniemi
mooreniemi / .vimrc
Last active February 22, 2017 20:04
" http://superuser.com/questions/693528/vim-is-there-a-downside-to-using-space-as-your-leader-key
map <space> <leader>
map <space><space> <leader><leader>
set pastetoggle=<leader>p
imap ;; <Esc>
nmap <silent> <leader>sv :so $MYVIMRC<CR>
" movement mappings
" ----------------------------------------------------------------------------------
map <leader>t :tabNext<CR>
require 'spec_helper'
def perms(str)
return [str] if str.length == 1
results = []
str.length.times do |i|
substring = str.dup
c = substring.slice!(i - 1)
perms(substring).map do |s|
results << c + s
# Definition for a binary tree node.
# class TreeNode
# attr_accessor :val, :left, :right
# def initialize(val)
# @val = val
# @left, @right = nil, nil
# end
# end
# @param {TreeNode} root
# pair the sublists together
a.zip(b)
=> [[[1], [9]], [[2, 3], [8, 7]], [[4, 5, 6], [6, 5, 4]]]
# collect up the lengths
a.zip(b).collect {|e| e.map(&:length) }
=> [[1, 1], [2, 2], [3, 3]]
# i want each pair of lengths to be the same, so
a.zip(b).collect {|e| e.map(&:length) }.map(&:uniq)
=> [[1], [2], [3]]
# after i made them uniq, are they singular?