Endre Galaczi
🐦 @galacziendre
✉️ galacziendre@gmail.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Monad | |
import Control.Applicative (Applicative(..)) | |
import Control.Monad (liftM, ap) | |
family = [("grandpa", Nothing), | |
("dad", Just "grandpa"), | |
("son", Just "dad"), | |
("daughter", Just "dad") | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- cabal install hspec | |
-- runhaskell Test.hs | |
import Test.Hspec | |
import Test.QuickCheck | |
import Control.Exception (evaluate) | |
import Poker | |
import Data.List.Split |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import eventstore | |
import requests | |
import sys | |
class RequestBuilder(): | |
def __init__(self, host, stream): | |
self.headers = { | |
"Accept": "application/vnd.eventstore.atom+json" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git describe --tags | |
#example: v0.0-237-g114b509 | |
# last tag - commits since last tag - g for github - hash of commit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = { |
OlderNewer