Skip to content

Instantly share code, notes, and snippets.

View abangratz's full-sized avatar
:octocat:
Nerding

Anton Bangratz abangratz

:octocat:
Nerding
View GitHub Profile

Keybase proof

I hereby claim:

  • I am abangratz on github.
  • I am abangratz (https://keybase.io/abangratz) on keybase.
  • I have a public key whose fingerprint is BE1C 9C97 BEFC 4246 CD54 E2A6 9D3D 90B7 7C90 FFFD

To claim this, I am signing this object:

@abangratz
abangratz / 0_reuse_code.js
Last active August 29, 2015 14:09
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@abangratz
abangratz / index.html.erb
Last active January 2, 2016 04:39
Sample decision on parameter (rails 4)
<div id="search_block">
<%= form_tag(action: 'search', method: :put) do %>
<%= text_field_tag(:search, params[:search], placeholder: 'Search ...') %>
<%= submit_tag('Go') %>
<% end %>
</div>
<% if @rentals.blank? %>
<%# Notify user of missing parameter or empty result set %>
<h4>Please give a valid search term</h4>
<div class="help-block">
@abangratz
abangratz / usersnap.coffee
Created October 1, 2013 10:42
usersnap integration for coffeescript
_usersnapconfig =
emailBox: true,
commentBox: true,
apiKey: "YOUR-API-KEY-HERE"
(->
s = document.createElement("script")
s.type = "text/javascript"
s.async = true
s.src = '//api.usersnap.com/usersnap.js'
@abangratz
abangratz / _usersnap.html.haml
Created October 1, 2013 10:31
Integrating usersnap - haml
:javascript
var _usersnapconfig = {
emailBox: true,
commentBox: true,
apiKey: "YOUR-API-KEY-HERE"
// for heroku:
// apiKey: "#{ENV['USERSNAP_APIKEY']}"
};
(function() {
var s = document.createElement("script");
@abangratz
abangratz / levenshtein.rb
Created September 28, 2010 20:42
Quick implementation of the Levenshtein (Edit Distance) Algorithm
#!/usr/bin/env ruby
class String
def levenshtein(other)
range_self_end = self.size
range_other_end = other.size
data =
(0..range_self_end).map {|s|
(0..range_other_end).map {|t|
t + s unless t>0 && s>0