Skip to content

Instantly share code, notes, and snippets.

View priyatam's full-sized avatar

Priyatam Mudi priyatam

View GitHub Profile
@taylorlapeyre
taylorlapeyre / description.md
Last active August 29, 2015 14:08
A clever problem for an interview or just for fun

Generating HTML

Say that one day we decide to write a new templating library for generating HTML.

In this new library, you are passed an array where the first element is the name of an HTML tag, the second element is optionally a hash containing the element's HTML attributes, and the rest of the elements are the HTML elements that are children of it.

For example:

html = [:html,
@wagjo
wagjo / gist:27ce6a34d5d5257a0790
Last active September 24, 2015 19:41
JWT Parsing in Dunaj
(ns foo.core
(:api dunaj)
(:require [dunaj.host.int :refer [i== iDOT]]
[dunaj.host.array :as dha]
[dunaj.format.base64 :refer [base64-safe]]
[dunaj.coll.recipe :refer [concat*]]
[dunaj.concurrent.port :refer [reduce! onto-chan!]]))
(def+ ByteColl [java.lang.Byte]) ;; type signature
@jokull
jokull / grid.styl
Created December 20, 2011 15:39
Stylus Skeleton responsive grid
// Based on getskeleton.com
@import "nib/clearfix"
@import "nib/reset"
global-reset()
columns = 16
column-width = 57px // Ends up as 1232px layout
gutter-width = 20px
module Main1 where
data HashSet a = native java.util.HashSet where
native new :: () -> STMutable s (HashSet a)
native size :: Mutable s (HashSet a) -> ST s Int
native add :: Mutable s (HashSet a) -> a -> ST s Bool
native remove :: Mutable s (HashSet a) -> a -> ST s Bool
main :: IO ()
main = do
@zahardzhan
zahardzhan / machine.clj
Created February 13, 2010 12:31
Turing machine in Clojure
;;; -*- mode: clojure; coding: utf-8 -*-
;;; author: Roman Zaharov <zahardzhan@gmail.com>
(ns clojure.turing-machine.machine)
(in-ns 'clojure.turing-machine.machine)
(defn convert-rules [rules]
(apply conj [] (for [rule rules :let [[state read jump write move] rule]]
{:state state :read read :jump jump :write write :move move})))
@jackrusher
jackrusher / cubesque.cljs
Created November 20, 2015 16:56
Playing with Toxi's geom library for the first time.
(ns cubesque
(:require [thi.ng.typedarrays.core :as arrays]
[thi.ng.geom.core :as g]
[thi.ng.geom.core.vector :as v :refer [vec2 vec3]]
[thi.ng.geom.core.matrix :as mat :refer [M44]]
[thi.ng.geom.core.utils :as gu]
[thi.ng.geom.webgl.core :as gl]
[thi.ng.geom.webgl.animator :as anim]
[thi.ng.geom.webgl.buffers :as buf]
[thi.ng.geom.webgl.shaders :as sh]
(scss->clj "/Users/noprompt/git/yui/pure/src/grids/css/grids-core.css"
'pure.grids)
;; =>
((ns
pure.grids
(:require [garden.stylesheet] [garden.units] [garden.def]))
(garden.def/defstyles
grids
[".pure-g"
{:letter-spacing "-0.31em"}
@zahardzhan
zahardzhan / Common Words.md
Last active July 31, 2016 05:26
Program Pearls, Continued: Common Words, Clojure

Program Pearls, Continued: Common Words (1986)

from Literate Programming, D. Knuth, 1992, Chapter 6.

The purpose of this program is to solve the following problem posed by Jon Bentley:

Given a text file and an integer k, print the k most common words in the file (and the number of their occurrences) in decreasing frequency.

Solution

@pelle
pelle / accounts.clj
Created May 8, 2012 14:37
Using database functions in Datomic transactions and annotating transaction history
(use '[datomic.api :only [q db] :as d])
(def uri "datomic:mem://accounts")
;; create database
(d/create-database uri)
;; connect to database
(def conn (d/connect uri))
@jrslepak
jrslepak / inference.rkt
Last active May 24, 2017 19:04
Type inference in Typed Racket
#lang typed/racket
;;; Typed Racket version of Martin Grabmü̈ller's "Algorithm W Step by Step"
;;; http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.65.7733
;;; This is my first use of Typed Racket. I am looking to change this from
;;; following Haskell idiom to following Racket idiom.
;; An expression is a variable, a literal, an application,