Skip to content

Instantly share code, notes, and snippets.

View kirang89's full-sized avatar

Kiran Gangadharan kirang89

View GitHub Profile
@kirang89
kirang89 / pr_etiquette.md
Created December 18, 2018 04:34 — forked from mikepea/pr_etiquette.md
Pull Request Etiquette

Pull Request Etiquette

Why do we use a Pull Request workflow?

PRs are a great way of sharing information, and can help us be aware of the changes that are occuring in our codebase. They are also an excellent way of getting peer review on the work that we do, without the cost of working in direct pairs.

Ultimately though, the primary reason we use PRs is to encourage quality in the commits that are made to our code repositories

Done well, the commits (and their attached messages) contained within tell a story to people examining the code at a later date. If we are not careful to ensure the quality of these commits, we silently lose this ability.

@kirang89
kirang89 / config_emacs.el
Created May 4, 2018 12:54
Nothing to see here
(use-package move-text
:bind (([(meta up)] . move-text-up)
([(meta down)] . move-text-down)))
(use-package spaceline
:ensure t
:init
(require 'spaceline-config)
(let ((faces '(mode-line
mode-line-buffer-id
@kirang89
kirang89 / gradient_descent.py
Last active March 18, 2017 16:36
A simple example to show how gradient descent works
#!/usr/bin/env python
# coding=utf8
import random
import math
def partial_difference_quotient(f, v, i, h):
"""This function approximates the derivate function as h approaches zero"""
dv = [elem + (h if index == i else 0)
import flask
import uuid
import httplib2
from oauth2client.client import flow_from_clientsecrets
from oauth2client.client import OAuth2Credentials, AccessTokenRefreshError
from apiclient.discovery import build
app = flask.Flask(__name__)
app.secret_key = str(uuid.uuid4())
@kirang89
kirang89 / refex.clj
Last active February 29, 2016 17:16
Simple example to illustrate the use of refs in Clojure
;;
;; A simple banking system as an example to illustrate refs in Clojure
;;
(def account-a (ref 100))
(def account-b (ref 100))
(defn transfer! [amount from to]
(dosync
(if (>= (- @from amount) 0)
@kirang89
kirang89 / jekyll_migrate.sh
Created February 29, 2016 16:01
Moving pelican posts to jekyll
#!/bin/bash
for post in $(find . -name *.md)
do
date=$(grep -i "date: " $post | sed -e "s/[dD]ate: \([0-9-]\+\).*/\1/g")
clean_date=$(echo $date | awk -F " " '{print $2}')
if [[ ! -z $clean_date ]]
then
cp $post /path-to-blog/_posts/$clean_date-$(basename $post)
fi
@kirang89
kirang89 / ns-cheatsheet.clj
Created February 20, 2016 06:24 — forked from ghoseb/ns-cheatsheet.clj
Clojure ns syntax cheat-sheet
;;
;; NS CHEATSHEET
;;
;; * :require makes functions available with a namespace prefix
;; and optionally can refer functions to the current ns.
;;
;; * :import refers Java classes to the current namespace.
;;
;; * :refer-clojure affects availability of built-in (clojure.core)
;; functions.
@kirang89
kirang89 / astar.clj
Last active February 10, 2016 20:36
A tail recursive implementation of A* search in Clojure (adopted from The Joy of Clojure)
(defn neighbours
([size node] (neighbours [[-1 0] [0 -1] [1 0] [0 1]] size node))
([deltas size node]
(vec (filter (fn [n]
(every? #(< -1 % size) n))
(map #(vec (map + node %)) deltas)))))
;; h(x)
(defn heuristic-estimate [step-cost size y x]
(- (+ size size) y x 2))
@kirang89
kirang89 / 00_destructuring.md
Created January 16, 2016 16:05 — forked from john2x/00_destructuring.md
Clojure Destructuring Tutorial and Cheat Sheet

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.

Vectors