Skip to content

Instantly share code, notes, and snippets.

Guru Devanla gdevanla

Block or report user

Report or block gdevanla

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@gdevanla
gdevanla / install-python.sh
Created Jun 27, 2018 — forked from ndaidong/install-python.sh
Install Python 3.6.5 in Ubuntu 16+
View install-python.sh
#!/bin/bash
export PYTHON_VERSION=3.6.5
export PYTHON_DOWNLOAD_URL=https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tgz
sudo apt update
sudo apt install --no-install-recommends -y \
software-properties-common build-essential \
libssl-dev libreadline-dev libbz2-dev libsqlite3-dev zlib1g-dev \
python-minimal
@gdevanla
gdevanla / revset_generator.py
Created May 4, 2018
Using python function call syntax to generated 'revsets' needed by mercurial
View revset_generator.py
'''
Module that can generate revset expressions required by Hg from python function call structures.
'''
def _wrap(outer_fn, *args):
args = args or ''
if args:
args = ", ".join(args)
return '{}({})'.format(outer_fn, args)
View machine_setup.txt
Remapping keys
https://askubuntu.com/questions/149971/how-do-you-remap-a-key-to-the-caps-lock-key-in-xubuntu
sudo vi /etc/default/keyboard
then find the line that starts with XKBOPTIONS, and add ctrl:nocaps to make Caps Lock an additional Control key or ctrl:swapcaps to swap Caps Lock and Control.
For example, mine looks like
View ycombinator.py
# coding: utf-8
# Python code to demonstrate the Y-combinator using
# the working example presented by Jim Weirich.
# https://www.infoq.com/presentations/Y-Combinator
def demo():
fact_1 = lambda n: 1 if n == 0 else (n * fact_1 (n - 1))
@gdevanla
gdevanla / y-combinator-racket.rkt
Created Feb 7, 2018
Y-Combinator description in Racket
View y-combinator-racket.rkt
;; lambda expression do not have any assignments
;; so we will use the form where there is not lambda expressions
((lambda ()
(define (adder n) (+ n 1))
(define (mult3 n) (* n 3))
(mult3 (adder 10))
))
;; create make-adder and compose using higher-order functions
@gdevanla
gdevanla / stackaga_build.sh
Created Jan 23, 2018
Stackage commands to run before package update
View stackaga_build.sh
stack unpack $package
cd $package-$version
stack init --resolver nightly
stack build --resolver nightly --haddock --test --bench --no-run-benchmarks
@gdevanla
gdevanla / test.py
Last active May 18, 2017
for color formatting
View test.py
from openpyxl.styles import Alignment
def format_data(index, col_name):
alignment = Alignment(horizontal=’right’)
if col_name == ‘salary’:
return dict(
alignment=alignment,
number_format='$0.00')
View auto_insert_github_link.el
@gdevanla
gdevanla / cc_style_simple_example.hs
Created Feb 8, 2017
example of folding over functions
View cc_style_simple_example.hs
-- continuation calling style of functions
f :: forall a. Integral a => a -> (a -> a) -> a -> a
f y fun x = if x == y then x * x else fun x
f_base :: forall a. Num a => a -> a
@gdevanla
gdevanla / mvar_as_closure.hs
Last active Jan 30, 2017
Using MVar as a closure value
View mvar_as_closure.hs
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE OverloadedStrings #-}
import Control.Concurrent.MVar
You can’t perform that action at this time.