Endre Galaczi
🐦 @galacziendre
✉️ [email protected]
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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" | |
NewerOlder