// jQuery
$(document).ready(function() {
// code
})
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 | |
# |
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') |
#!/usr/bin/env ruby | |
#/ SYNOPSIS | |
# | |
# Run `CMD --help` for full documentation. | |
# | |
# Written by NAME | |
require 'optparse' | |
options = { |
#!/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 |
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) |
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!
\
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
[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.]