Skip to content

Instantly share code, notes, and snippets.

View chiller's full-sized avatar

Endre Galaczi chiller

View GitHub Profile
@chiller
chiller / models.coffee
Last active December 14, 2015 01:29
Cheatsheet: skeleton for a small backbone exampleapp
class NestedCommentView extends Backbone.View
tagname: "div"
initialize: =>
@model.bind 'change', @render
@model.bind 'destroy', @unrender
#bind this to a dom event
#events:
# "click .deletecomment": "deleteComment"
@chiller
chiller / csrf.coffee
Created April 29, 2013 16:14
Include csrf token in backbone requests
#source is legit: https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax
getCookie = (name) ->
cookieValue = null
if document.cookie and document.cookie isnt ""
cookies = document.cookie.split(";")
i = 0
while i < cookies.length
cookie = jQuery.trim(cookies[i])
@chiller
chiller / serializers.py
Created June 14, 2013 10:01
filtering comments on user
class CommentRelatedField(serializers.ManyRelatedField):
def to_native(self, value):
return CommentSerializer(value).data
def field_to_native(self, obj, field_name):
try:
if self.source == '*':
return self.to_native(obj)
@chiller
chiller / slides.md
Created November 3, 2015 18:32
Functional Programming at Founders And Coders

functional programming

Endre Galaczi

🐦  @galacziendre
✉️  galacziendre@gmail.com

functional programming - intro

@chiller
chiller / fish.hs
Created June 2, 2016 17:26
Fish operator
import Control.Monad
import Control.Applicative (Applicative(..))
import Control.Monad (liftM, ap)
family = [("grandpa", Nothing),
("dad", Just "grandpa"),
("son", Just "dad"),
("daughter", Just "dad")
]
@chiller
chiller / Test.hs
Last active June 20, 2017 11:35
Poker Kata haskell
-- cabal install hspec
-- runhaskell Test.hs
import Test.Hspec
import Test.QuickCheck
import Control.Exception (evaluate)
import Poker
import Data.List.Split
@chiller
chiller / find_by_time.py
Last active August 3, 2018 07:16
find event in Eventstore stream by timestamp; find category stream index for event
import eventstore
import requests
import sys
class RequestBuilder():
def __init__(self, host, stream):
self.headers = {
"Accept": "application/vnd.eventstore.atom+json"
@chiller
chiller / State.hs
Last active June 23, 2017 12:20
state monad
module SomeMonad where
import Control.Applicative (Applicative(..))
import Control.Monad (liftM, ap)
-- see this for more help: http://brandon.si/code/the-state-monad-a-tutorial-for-the-confused/
newtype State s a = State { runState :: s -> (a, s) }
instance Monad (State s) where
@chiller
chiller / tag.sh
Last active August 3, 2018 07:15
best build tagging ever
git describe --tags
#example: v0.0-237-g114b509
# last tag - commits since last tag - g for github - hash of commit
@chiller
chiller / Tree.scala
Last active January 22, 2018 12:51
Mutable Tree
package tree.Tree
class Tree(rootValue: Int) {
class Node(var parent: Option[Node], var children: Set[Node], var data: Int) {
}
var root : Node = new Node(None, Set(), rootValue)
def addLeaf(parent: Node, data: Int): Node = {