Skip to content

Instantly share code, notes, and snippets.

@mjansen401
mjansen401 / about_scoring_project.rb
Created February 23, 2011 16:17
Ruby Koan for how to score the dice game "Greed"
require File.expand_path(File.dirname(__FILE__) + '/edgecase')
# Greed is a dice game where you roll up to five dice to accumulate
# points. The following "score" function will be used calculate the
# score of a single roll of the dice.
#
# A greed roll is scored as follows:
#
# * A set of three ones is 1000 points
#
@rakasaka
rakasaka / gist:1169341
Created August 24, 2011 21:45
Unsupervised topic modeling in Ruby using LDA
require 'lda-ruby'
corpus = Lda::Corpus.new
corpus.add_document(Lda::TextDocument.new(corpus, "a lion is a wild feline animal", []))
corpus.add_document(Lda::TextDocument.new(corpus, "a dog is a friendly animal", []))
corpus.add_document(Lda::TextDocument.new(corpus, "a cat is a feline animal", []))
lda = Lda::Lda.new(corpus)
lda.verbose = false
lda.num_topics = (2)
lda.em('random')
@liamcurry
liamcurry / gist:2597326
Created May 4, 2012 19:56
Vanilla JS vs jQuery

Moving from jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@mlafeldt
mlafeldt / app.rb
Created July 11, 2012 15:41
Skeleton for Ruby command-line app
#!/usr/bin/env ruby
#/ SYNOPSIS
#
# Run `CMD --help` for full documentation.
#
# Written by NAME
require 'optparse'
options = {
@shunsukeaihara
shunsukeaihara / mcl.rb
Created January 23, 2013 08:38
markov cluster algorithm in ruby
#!/usr/bin/ruby
class MCL
def initialize(path,min=0.00001,minpred=0.1)
@minimum=min
@minimunPred=minpred
@matrix=Hash.new
id=0
edgelist=Array.new
@sabman
sabman / Using-DViz-with-ActiveAdmin.md
Last active June 28, 2017 11:15
Using DViz.js to visualize data on ActiveAdmin Dashboard https://github.com/akngs/dviz

Using DViz.js with ActiveAdmin (Rails)

At https://BringBee.ch we have an internal ActiveAdmin App that we use to keep tabs on the recent activity. It's dashboard could do with some pretty graphs showing the stats of orders processed each week.

Today I ran across https://github.com/akngs/dviz so I decided to give it a spin. What follows is not by any means best practice but it got the results I wanted. The steps were pretty simple:

Get the source

in your vendor/assets/javascripts:

module RandomString
HUMAN = %w{2 3 4 6 7 9 a c d e f g h j k m n p q r t v w x y}
LOWER = [*'a'..'z']
PARAM = [*'a'..'z', *0..9]
FULL = [*'a'..'z', *'A'..'Z', *0..9]
MIXED = [*'a'..'z', *'A'..'Z']
def self.by_rand(length = 8, set = :full)
chars = get_chars(set)
@tsiege
tsiege / The Technical Interview Cheat Sheet.md
Last active November 14, 2024 15:40
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

ANNOUNCEMENT

I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!






\

@staltz
staltz / introrx.md
Last active November 14, 2024 11:27
The introduction to Reactive Programming you've been missing
@geeksam
geeksam / dsl-or-api-checklist.md
Last active June 12, 2017 20:46
The "Is It a DSL or an API?" Ten Question Checklist

[NOTE: The original version was posted in 2007 on an O'Reilly blog, but the page has been erroring out for months now. I'm copying it here because archive.org, while useful, can be slow. chromatic is a lovely person who (he thinks) probably has copyright to this piece.]


The "Is It a DSL or an API?" Ten Question Checklist

Saturday May 19, 2007 6:00AM
by chromatic in Opinion