Skip to content

Instantly share code, notes, and snippets.

View dzsodzso63's full-sized avatar

Pengő Dzsó dzsodzso63

  • Formlabs
  • Budapest
View GitHub Profile
@dzsodzso63
dzsodzso63 / bowling.js
Created June 16, 2015 17:42
The Bowling Score Calculator kata
var bowling = {
getScore: function(scoreString){
if (scoreString.length < 11) return -1;
if (scoreString.length > 21) return -1;
if (!scoreString.match(/^([1-9]|X|\/|-)*$/)) return -1;
var score = 0;
var scorePlus = 0;
var frame = 1;
var multi = 1;
for (i = 0; i<scoreString.length; i++){
@dzsodzso63
dzsodzso63 / GildedRose.js
Created June 16, 2015 17:34
The Gilded Rose kata
var GildedRose = function () {
console.log("OMGHAI!");
var items = [];
items.push(new Item("+5 Dexterity Vest", 10, 20));
items.push(new Item("Aged Brie", 2, 0));
items.push(new Item("Elixir of the Mongoose", 5, 7));
items.push(new Item("Sulfuras, Hand of Ragnaros", 0, 80));
items.push(new Item("Backstage passes to a TAFKAL80ETC concert", 15, 20));
items.push(new Item("Conjured Mana Cake", 3, 6));
GildedRose.updateQuality(items);
@dzsodzso63
dzsodzso63 / tinypng.sh
Last active August 29, 2015 14:04
How to create asset string from a png file
DATAURIPREFIX="data:image/png;base64,"
TINYPNG_API_KEY=[register for one in https://tinypng.com]
api_loc=`curl -i --user api:$TINYPNG_API_KEY --data-binary @$1 https://api.tinypng.com/shrink | grep "Location:" | cut -f 2 -d " "`
echo -n $DATAURIPREFIX; curl -s $api_loc | base64
@dzsodzso63
dzsodzso63 / application_controller.rb
Created March 18, 2011 19:49
controller1 doesn't render the application layout, but controller2 does!
class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
protect_from_forgery # See ActionController::RequestForgeryProtection for details
def initialize
@messages = {}
end
private