Skip to content

Instantly share code, notes, and snippets.

xx :: [a] -> [a] -> [[a]]
[] `xx` xs = []
xs `xx` [] = []
(a:as) `xx` bs = (a `x` bs) ++ (as `xx` bs)
x :: a -> [a] -> [[a]]
a `x` [] = []
a `x` (b:bs) = [[a,b]] ++ (a `x` bs)
import React from 'react';
import SchemaBranchMixin from 'baobab-react-schemabranchmixin';
const Counter = React.createClass({
displayName: 'Counter',
mixins: [SchemaBranchMixin, ],
schema: {
value: 0,
},
import Focus
import Array
import Maybe
atL Int -> a -> Focus (Array.Array a) a
atL index default = Focus.create ((Maybe.withDefault default) << (Array.get index))\
(\f r -> (Array.set index
(f (Maybe.withDefault default (Array.get index r)))
r))
@ir4y
ir4y / hello.elm
Last active December 9, 2015 16:17
module Hello where
import Graphics.Element exposing (Element, show)
import Task exposing (Task, andThen)
import Html exposing (..)
import Html.Attributes exposing (style, value)
import Html.Events exposing (onClick, on, targetValue)
import Json.Decode as Json
@ir4y
ir4y / maybe.py
Created September 21, 2015 16:53
import operator
class Maybe(object):
"""
Basic concept
use https://github.com/Suor/whatever/tree/0d8b2c4fcdcb94f3eb6fa79d2fcdf84c8e39286d
for initial hacking
"""
def __init__(self, val, nothing=None):
@ir4y
ir4y / README.markdown
Last active August 29, 2015 14:24
React.js based simple TODO list with lenses.
#include <stdio.h>
void add(unsigned long long *dst, unsigned long long *src){
asm ("movq %0, %%rbx\n"
/*"addq $8, %%rbx\n"*/
"movq (%%rbx), %%rax\n"
"addq (%1), %%rax\n"
"mov %%rax, (%%rbx)\n"
/*"adcq $0, %%rax\n"*/
(item 10 nil
(item 20 nil
(item 30 (item 25 nil)
(item 35 nil))))
(+ 1 2) ;; 1 + 2
(def my-fun
(fn [a b c]
(* (+ a b)
# Есть структура данных описывающая пользователей
# В socket будет попадать открытый обработчик WebSockerHandler
user_list = [{'socket': tornado.websocket.WebSocketHandler(),
'groups': ['all', 'some group']},
{'socket': tornado.websocket.WebSocketHandler(),
'groups': ['other group']}]
#Функция отправки сообщения пользователям
def send_message(message):
@ir4y
ir4y / view.py
Last active August 29, 2015 14:02
def index(request):
@cached_as(News.objects.all()) #Что тут написать что бы так же работала инвалидация для Tag ?
def _index():
c = {'news':News.objects.all(),
'tags':Tag.objects.all()}
return render("index.html", c)
return _index()