Skip to content

Instantly share code, notes, and snippets.

View kolharsam's full-sized avatar
🚀
Excelsior!

Sameer Kolhar kolharsam

🚀
Excelsior!
  • 17:29 (UTC -04:00)
View GitHub Profile
@adambard
adambard / errors.clj
Created May 13, 2013 05:48
An example of functional error handling in clojure.
(ns example.errors)
(defn clean-address [params]
"Ensure (params :address) is present"
(if (empty? (params :address))
[nil "Please enter your address"]
[params nil]))
(defn clean-email [params]
"Ensure (params :email) matches *@*.*"
@jordanpoulton
jordanpoulton / pair_programming_roles
Last active September 11, 2023 23:18
Pair Programming Role Definitions - Driver:Navigator
Driver:
-Write the code according to the navigator's specification
-Listen intently to the navigators instructions
-Ask questions wherever there is a lack of clarity
-Offer alternative solutions if you disagree with the navigator
-Where there is disagreement, defer to the navigator. If their idea fails, get to failure quickly and move on
-Make sure code is clean
-Own the computer / keyboard
-Ignore larger issues and focus on the task at hand
-Trust the navigator - ultimately the navigator has the final say in what is written
@14427
14427 / hkt.rs
Last active February 7, 2024 10:18
Higher-kinded type trait
use std::rc::Rc;
trait HKT<U> {
type C; // Current type
type T; // Type with C swapped with U
}
macro_rules! derive_hkt {
($t:ident) => {
impl<T, U> HKT<U> for $t<T> {
@smarr
smarr / truffle-material.md
Last active March 16, 2023 14:06
Truffle: Languages and Material
@ursuad
ursuad / kafka-cheat-sheet.md
Last active March 14, 2024 10:32
Quick command reference for Apache Kafka

Kafka Topics

List existing topics

bin/kafka-topics.sh --zookeeper localhost:2181 --list

Describe a topic

bin/kafka-topics.sh --zookeeper localhost:2181 --describe --topic mytopic

Purge a topic

bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic mytopic --config retention.ms=1000

... wait a minute ...

@Atinux
Atinux / async-foreach.js
Last active October 10, 2023 03:04
JavaScript: async/await with forEach()
const waitFor = (ms) => new Promise(r => setTimeout(r, ms))
const asyncForEach = async (array, callback) => {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array)
}
}
const start = async () => {
await asyncForEach([1, 2, 3], async (num) => {
await waitFor(50)

In this tutorial we're going to build a set of parser combinators.

What is a parser combinator?

We'll answer the above question in 2 steps.

  1. What is a parser?
  2. and, what is a parser combinator?

So first question: What is parser?

@vedang
vedang / psk.clj
Last active May 11, 2020 03:12
A Clojure simulation of the Passport Seva Kendra
(ns challenges.psk
"A Simulation of the Passport Seva Kendra"
(:require [clj-time.core :as ct]
[clojure.tools.logging :as ctl])
(:import [java.util.concurrent LinkedBlockingQueue PriorityBlockingQueue]))
(def working-hours? (atom false)) ; use this to control agents.
; Turning this off will
; shutdown agents.
@dino-
dino- / string-conversions.hs
Last active April 6, 2024 16:32
A handy illustration of converting between String, Text and ByteString in Haskell
#! /usr/bin/env stack
-- stack --resolver lts-18.8 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).