Skip to content

Instantly share code, notes, and snippets.

@mooreniemi
mooreniemi / example update
Last active August 29, 2015 14:10
activerecord pattern example 1
def update
@model = Model.find(params[:id]) # ActiveRecord's find method being used here
@model.update_attributes(params) # ActiveRecord's update_attributes method being used here
if @model.save # ActiveRecord's save method being used here
respond_with(@model)
else
respond_with(@model.errors)
end
end
~/Documents/Code/haskell cabal install ghc-mod-5.2.1.1 -v3
Using a sandbox located at /Users/Alex/Documents/Code/haskell/.cabal-sandbox
Searching for ghc in path.
Found ghc at /usr/local/bin/ghc
("/usr/local/bin/ghc",["--numeric-version"])
/usr/local/bin/ghc is version 7.8.2
looking for tool ghc-pkg near compiler in /usr/local/bin
found ghc-pkg in /usr/local/bin/ghc-pkg
("/usr/local/bin/ghc-pkg",["--version"])
/usr/local/bin/ghc-pkg is version 7.8.2
@mooreniemi
mooreniemi / gist:2307d398131127b75840
Created April 16, 2015 16:01
from pda vs adt article
adt IntList
representation
list = NIL | CELL of integer * list
operations
nil = NIL
adjoin(x : integer, l : list) =
CELL(x, l)
null?(l : list) = case l of
NIL ⇒ true
CELL(x, l) ⇒ false
This file has been truncated, but you can view the full file.
2015-04-30 17:38:31
Full thread dump Java HotSpot(TM) Client VM (20.65-b04-466.1 mixed mode):
"http-/127.0.0.1:8080-89" daemon prio=5 tid=0000000043816c00 nid=0xc1b35000 waiting on condition [00000000c1b2e000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <000000000fd5f520> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:156)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:811)
Java::JavaLang::OutOfMemoryError (Java heap space):
java.lang.reflect.Array.newArray(Native Method)
java.lang.reflect.Array.newInstance(java/lang/reflect/Array.java:52)
oracle.jdbc.driver.BufferCache.get(oracle/jdbc/driver/BufferCache.java:226)
oracle.jdbc.driver.PhysicalConnection.getCharBuffer(oracle/jdbc/driver/PhysicalConnection.java:7672)
oracle.jdbc.driver.OracleStatement.prepareAccessors(oracle/jdbc/driver/OracleStatement.java:1005)
oracle.jdbc.driver.T4CTTIdcb.receiveCommon(oracle/jdbc/driver/T4CTTIdcb.java:277)
oracle.jdbc.driver.T4CTTIdcb.receive(oracle/jdbc/driver/T4CTTIdcb.java:146)
oracle.jdbc.driver.T4C8Oall.readDCB(oracle/jdbc/driver/T4C8Oall.java:844)
oracle.jdbc.driver.T4CTTIfun.receive(oracle/jdbc/driver/T4CTTIfun.java:358)

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 / newpopalg.rb
Created May 2, 2012 01:33
new alg test
require 'date'
require 'csv'
#Given a csv file output from Sermo App at https://app.sermo.com/reporting/reports/post_summary_by_date
#we need a csv of the posts in order of popularity, with the addition of a bayesian average to respond to different days.
#constructor of my post object with the csv fields to hold all the attributes
class Post <
# a post has csv categories a-q
@mooreniemi
mooreniemi / output.rb
Created May 7, 2012 20:42
csv to array to txt
require 'date'
require 'csv'
class Post <
# a Person has a first name, last name, and city
Struct.new(:title, :link, :cats, :publish_date, :avg_rating, :comments, :votes, :username, :specialty, :pop)
end
@mooreniemi
mooreniemi / postpropay.rb
Created May 8, 2012 20:58
post promo payment
require 'date'
require 'csv'
#Given a csv file output from Sermo App at https://app.sermo.com/reporting/reports/post_summary_by_date
#we need a csv of the Post Promo contest winners (base $15 and grand prize $30) by the week's targeted specialties.
#We need to only pay members once, and only pay them for posts which received 10 comments and an average rating of at least 3 stars.
#Specialties targeted were sent an automated e-mail from Exact Target to remind them it was their day to participate.
#You will only need to tell this program what the file name from the Sermo app was, and it will output a payment csv file for you!
#constructor of my post object with the csv fields to hold all the attributes