Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# Functions ==============================================
# return 1 if global command line program installed, else 0
# example
# echo "node: $(program_is_installed node)"
function program_is_installed {
# set to 1 initially
local return_=1
@gagangowda
gagangowda / gist:c2b4c665545d48e0a615
Created March 6, 2015 20:48
MEEN 25-25-25-25 split
{
"expression": [
{
"_function": "bind",
"population": {
"_function": "all"
},
"populationName": "1"
},
{
#Factorial Recursive Function
def factorial(n):
if n>1:
return n * factorial(n-1)
else:
return 1
#Fibonnaci Function
l = []
@gagangowda
gagangowda / Json_Concatenation.py
Last active December 28, 2015 19:59
Combining Two Json Objects in Python
import json
def combine_json():
with open('j1.json') as file:
d1 = json.loads(file.read())
with open('j2.json') as file:
d2 = json.loads(file.read())
result = combine_dict(d1,d2)
j3 = json.dumps(result)
return j3
@gagangowda
gagangowda / pascal.py
Created October 8, 2013 06:41
Pascal Tree
def triangle(rows):
for rownum in range (rows):
newValue=1
PrintingList = [newValue]
for iteration in range (rownum):
newValue = newValue * ( rownum-iteration ) / ( iteration + 1 )
PrintingList.append(int(newValue))
print(PrintingList)
@gagangowda
gagangowda / gist:6576649
Created September 16, 2013 04:15
Hidden Functionalities of Python
http://stackoverflow.com/questions/101268/hidden-features-of-python#111176