Skip to content

Instantly share code, notes, and snippets.

View pranavgarg's full-sized avatar

Pranav Garg pranavgarg

View GitHub Profile
@pranavgarg
pranavgarg / migrating from wind to cas server running wind protocol
Created April 10, 2015 15:38
Migrating from Wind to CAS Server running Wind Protocol
Changing from Wind Authentication to CAS Server running wind protocol is just as easy as changing domain names for login and validation.
Wind Authentication:
---------------------------------------------------------
LoginURL: https://wind.columbia.edu/login?service=[Optional]&destination=[destination-URI]
ValidationURL: https://wind.columbia.edu/validate?ticketid=[service-ticket]
[service] parameter is not really required on CAS. Even if you pass it would not matter.
Switching to CAS Server running Wind protocol:
@pranavgarg
pranavgarg / renameVideoFile
Last active August 29, 2015 14:21
Renaming of files in python
"""
Before filename: recoded_videos%2Falgs4partI-64.mp4
new_file: 64.mp4
"""
import os
directory = '<DIR NAME>'
pattern_to_be_excluded = '.mp4'
pattern_to_be_excluded_2 = '-'
k = os.walk(directory)
@pranavgarg
pranavgarg / coffeescript-to-javascript
Last active August 29, 2015 14:23
Coffeescript to Javascript
1. Conditionals & Operators
coffeescript Javascript
------------ -------------
== is ===
!= isnt !==
not !
and &&
or ||
true yes on true
false no off false
@pranavgarg
pranavgarg / meteor_best_practices
Created June 23, 2015 15:40
Meteor Best Practices
###
Install: meteor add audit-argument-checks
Description: This package will do type checking for the arguments.
E.g. Publish function sending data back based on the username
###
Meteor.publish({
"posts": (currentUserName) ->
check currentUserName, String #this line does the typechecking. If missed following error thrown Exception from sub posts id .. Did not check() all arguments during publisher
Posts.find({author: currentUserName}).fields({})
})
@pranavgarg
pranavgarg / mount a new volume
Last active August 29, 2015 14:24
Attach a new volume to ec2, ensuring a service runs on server restart and access instance metadata
# lists the volumes
$> lsblk
# this lists all the volumes
xvda1 202:1 0 8G 0 disk /
xvdb 202:16 0 400G 0 disk /mnt
$> free -s /dev/xvdb
#would return data is its not yet formatted and doesn't have any data
#otherwise would return the block and storage type ext4
@pranavgarg
pranavgarg / docker_cheatsheet
Last active October 15, 2015 14:40
Docker CheatSheet
##INTRO
Docker is based on lxc (Linux Containers) which helps provide virtualization on the host OS.
Its lightweight and ease of use allows it to succeed over VMware virtualization.
##Useful commands
1. **docker ps** - Lists containers.
2. **docker logs** - Shows us the standard output of a container.
3. **docker stop** - Stops running containers.
4. **docker images** - Lists all the docker images
@pranavgarg
pranavgarg / linklist.py
Created October 14, 2016 16:10
Python Reverse Link List
@pranavgarg
pranavgarg / skip_every_3rd_element.py
Last active October 14, 2016 20:29
josepheus problem - delete every 3rd element until the list goes empty
a = ['1','2','3','4','5','6','7','8','9']
def josepheus(int_list, skip):
skip = skip - 1 #list starts with 0 index
idx = 0
output = []
while len(int_list)>0:
idx = (skip+idx)%len(int_list)
k = int_list.pop(idx)
output.append(k)
@pranavgarg
pranavgarg / flatten.py
Created October 28, 2016 18:34
flatten a list
def flatten(l):
for el in l:
if isinstance(el, collections.Iterable) and not isinstance(el, basestring):
for sub in flatten(el):
yield sub
else:
yield el
assert [i for i in flatten([1,2,[3,4]])] == [1,2,3,4]
@pranavgarg
pranavgarg / keybase.md
Created February 13, 2017 17:43
keybase pranav

Keybase proof

I hereby claim:

  • I am pranavgarg on github.
  • I am pgarg (https://keybase.io/pgarg) on keybase.
  • I have a public key whose fingerprint is 70F8 1545 7515 F45C 3441 2FA6 BEFA 817E EB70 BEBE

To claim this, I am signing this object: