Skip to content

Instantly share code, notes, and snippets.

View kolharsam's full-sized avatar
🚀
Excelsior!

Sameer Kolhar kolharsam

🚀
Excelsior!
  • 17:10 (UTC -04:00)
View GitHub Profile
@kolharsam
kolharsam / keybase.md
Created September 19, 2021 03:28
keybase.md

Keybase proof

I hereby claim:

  • I am kolharsam on github.
  • I am kolharsam (https://keybase.io/kolharsam) on keybase.
  • I have a public key ASBjGCBJ9oW5F-QhszNQwHvt1N11lgF6DkXXQCBj0SX5PAo

To claim this, I am signing this object:

@kolharsam
kolharsam / string-conversions.hs
Created May 29, 2021 05:58 — forked from dino-/string-conversions.hs
A handy illustration of converting between String, Text and ByteString in Haskell
#! /usr/bin/env stack
-- stack --resolver lts-12.14 script
{-# LANGUAGE OverloadedStrings #-}
{-
This is a handy illustration of converting between five of the commonly-used
string types in Haskell (String, ByteString, lazy ByteString, Text and lazy
Text).
@kolharsam
kolharsam / handler.clj
Last active March 3, 2021 19:01
REST API in Clojure - Example for Hasura Actions
;; This app was made using the template provided via leiningen.
;; use lein new compojure <project-name> to create a similar project
;; This content's of this file can directly go into `handler.clj`
;; All necessary documentation can be found in these sources:
;; https://github.com/weavejester/compojure/wiki
;; https://github.com/ring-clojure/ring/wiki
(ns rest-hasura-api.handler
(:require [compojure.core :refer :all]
@kolharsam
kolharsam / transducers.js
Last active January 14, 2021 17:54
Dabbling with Transducers in JS
const list = [1,2,3,4,5,6,7,8,9];
const inc = x => x + 1;
const isOdd = x => x % 2 !== 0;
console.log(list.map(inc));
console.log(list.filter(isOdd))
console.log(list.map(inc).filter(isOdd))
console.log(list.reduce((acc, val) => {
if (isOdd(inc(val))) {
@kolharsam
kolharsam / move_zeroes.go
Last active August 17, 2020 10:47
Cassidy's Interview Question - 17/08/20
package main
import "fmt"
func moveZeros(numList []int) []int {
j := len(numList) - 1
// immutability ftw!
resList := make([]int, len(numList))
copy(resList, numList)
@kolharsam
kolharsam / poweroftwo.clj
Created June 1, 2020 08:53
Cassidy's Interview Question - 31/5/20
;; Just wanted to take a different approach to using
;; logarithms or recursively dividing...
;; powers of 2, in binary, have only 1 bit as "1", so I'll look for just that!
(require '[clojure.string :as str])
(defn is-power-of-2?
"Returns true if n is a power of 2"
[n]
@kolharsam
kolharsam / js_parser.clj
Created May 27, 2020 17:46 — forked from borkdude/js_parser.clj
Parse JavaScript in Clojure using the Google Closure Compiler
#!/bin/sh
#_(
"exec" "clojure" "-Sdeps" "{:deps {org.clojure/clojurescript {:mvn/version \"1.10.520\"}}}" "$0" "$@"
)
;; running js_parser.clj "function foo(x) { var y = x + 1; }" will print:
;; [{:type :function, :name "foo", :body [{:variable-statement [{:lvalue "y", :initializer {:type :binary-op, :left "x", :operator "+", :right "1"}}]}], :params ["x"]}]
@kolharsam
kolharsam / editor.clj
Last active May 27, 2020 17:49
Cassidy's Interview Question - 24/5
(def S (atom ""))
(def undo-stack (atom []))
(def redo-stack (atom []))
;; Helpers
(defn reset-stacks!
"Empties both stacks"
[]
(reset! undo-stack [])
@kolharsam
kolharsam / css-parser.md
Created May 22, 2020 12:57 — forked from kachayev/css-parser.md
Parsing CSS file with monadic parser in Clojure
@kolharsam
kolharsam / monads.clj
Created May 17, 2020 02:37 — forked from lispyclouds/monads.clj
Monads, simple made easier
; A simple demo of monadic composition of side effects
; Program to take 3 nubers as input and print their sum.
(defn read-and-add!
[prev]
(print "Enter a number: ")
(+ prev (do (flush)
(Integer/parseInt (read-line)))))
(defn bind