Skip to content

Instantly share code, notes, and snippets.

View plukevdh's full-sized avatar
👌
Nice

Luke van der Hoeven plukevdh

👌
Nice
View GitHub Profile
@plukevdh
plukevdh / levenshtein.erl
Created November 7, 2012 05:15
memoized levenshtein
-module(levenshtein).
-export([distance/2]).
store_result(Key, Value, Cache) ->
{Value, dict:store(Key, Value, Cache)}.
distance(String1, String2) ->
{List,_} = distance(String1, String2, dict:new()),
List.
@plukevdh
plukevdh / leven.ex
Created November 28, 2012 18:17
Levenshtein in elixir
defmodule Levenshtein do
def first_letter_check(one_letter, two_letter) do
case one_letter == two_letter do
true -> 0
false -> 1
end
end
def distance(string_1, string_1), do: 0
def distance(string, ''), do: :string.len(string)
@yusugomori
yusugomori / bpnn.coffee
Created January 25, 2013 17:10
Back-Propagation Neural Networks by CoffeeScript
###!
*
* Back-Propagation Neural Networks
*
* References:
* http://arctrix.com/nas/python/bpnn.py
*
###
class BPNN
@jakeonrails
jakeonrails / Ruby Notepad Bookmarklet
Created January 29, 2013 18:08
This bookmarklet gives you a code editor in your browser with a single click.
data:text/html, <style type="text/css">#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script>
@ibanez270dx
ibanez270dx / ConditionalValidations.rb
Last active April 10, 2018 11:31
A simple module that allows validation of only certain attributes of any given model. Created for CoverHound.com.
#
# At CoverHound, we use conditional validations all over the form. However, there is no proper way to do
# this in Rails. Instead, we can provide an array of attributes (validated_fields attribute)
# and ensure they are the only ones to get validated.
#
module ConditionalValidations
attr_accessor :validated_fields
def field_is_required?(field)
@hryk
hryk / Gemfile
Last active December 13, 2015 22:08
Examples for using blueprints on JRuby.
source "https://rubygems.org/"
gem "neo4j"
gem "pry"
gem "minitest"
gem "jbundler"
require 'benchmark/ips'
Benchmark.ips do |x|
RESULT = [1]
x.report('first') do |times|
i = 0
while i < times
id = RESULT.first
i += 1
@plukevdh
plukevdh / lazy_mustachio.coffee
Last active December 16, 2015 15:59
add handlebars rendering/pre-caching to backbone
class Mustachio extends Backbone.View
templates: {}
render: ->
@templates[@templateName].call @, @renderContext()
lazyCompileFactory: (template_id, raw_template) ->
@templates[template_id] = (context) =>
compiled_template = Handlebars.compile(raw_template)
@templates[this.id] = compiled_template
@Hypercubed
Hypercubed / README.md
Last active December 12, 2021 02:23
DocPad: rsync Deploy Script

DocPad: rsync Deploy Script

  • Place deploy.sh in {docpad folder}/bin/
  • Create (or edit) a .env file in your docpad folder with the following values:
#!/bin/bash
DEPLOY_SOURCE_DIR="out/"
DEPLOY_DEST_DIR="~/public_html/"
DEPLOY_SERVER=deploy-server-name
@plukevdh
plukevdh / collection.coffee
Last active December 26, 2015 19:19
simple model with properties and delegation
class Collection
constructor: (items) ->
@all = if _.any(items, (item) => item instanceof @modelType)
items
else
(new @modelType(item) for item in items)
add: (item) ->
@all.push(item)