Skip to content

Instantly share code, notes, and snippets.

View kshitij10496's full-sized avatar

Kshitij Saraogi kshitij10496

View GitHub Profile
@kshitij10496
kshitij10496 / final_report.md
Last active March 1, 2017 12:34
Work Product Submission for GSoC 16
@kshitij10496
kshitij10496 / clcs.md
Created May 9, 2017 15:54
Shell Tips and Tricks
  1. Creating new directories
  • mkdir <path> : Creates a new directory on the specified file path if such a path exists.
  • mkdir -p <path> : Creates intermediate directories necessary for creating the desired directory. Discovered while setting Go Workspace and Namespace.

Usage

$ mkdir $HOME/foo/bar # foo does not exist
@kshitij10496
kshitij10496 / http_server.md
Last active November 17, 2023 15:53
Setting up a Simple HTTP Server and communicating with it

The Python standard library provides a module called SimpleHTTPServer.py which can be used to setup a simple server on your local device.

Here is a brief description of how to have fun with it:

Step 01: Spin up the server

As simple as:

$ python -m SimpleHTTPServer

@kshitij10496
kshitij10496 / generators.py
Created August 24, 2017 08:32
Performance comparison of Iteration and Generators
from memory_profiler import profile
import random
import hug
@profile
def random_list(quantity):
result = []
for i in range(1, quantity+1):
result.append((i, random.randint(0, 9)))
@kshitij10496
kshitij10496 / cards.py
Last active August 28, 2017 16:16
Sample Implementation of a Deck class to represent the utility of Iterator Protocol
from collections import namedtuple
import random
Card = namedtuple('Card', ['rank', 'suit'])
class Deck(object):
'''Represents an ordered deck of 52 playing cards.'''
def __init__(self, cards=None):
if cards is None:
@kshitij10496
kshitij10496 / cards_traditional.py
Last active August 28, 2017 16:30
Traditional implementation of the Iterator Protocol
from collections import namedtuple
import random
Card = namedtuple('Card', ['rank', 'suit'])
class Deck(object):
'''Represents an ordered deck of 52 playing cards.'''
def __init__(self, cards=None):
if cards is None:
@kshitij10496
kshitij10496 / encoding_file.py
Created September 2, 2017 13:14
Python Source Code File Encoding
# coding: utf-8
from __future__ import print_function
original_string = 'abc∂´ƒ©'
unicode_literal = u'abc∂´ƒ©'
unicode_string = 'abc∂´ƒ©'.decode('utf-8')
print('Original String =', original_string)
print('Type =', type(original_string))
@kshitij10496
kshitij10496 / bob_superhero.vb
Last active November 12, 2017 15:51
BASIC program as written by Bob "Superhero" Newby in Stranger Things S02E08
DIM FourDigitPassword INTEGER
FOR i = 0 TO 9
FOR j = 0 TO 9
FOR k = 0 TO 9
FOR l = 0 TO 9
FourDigitPassword = getFourDigits (i,j,k,l)
IF checkPasswordMatch(FourDigitPassword) = TRUE THEN
GOTO 140
END
NEXT l
@kshitij10496
kshitij10496 / feynmanize.py
Created December 8, 2017 19:23
Script to print random quotes from/on Richard Feynman
#!env/bin/python3
# encoding: utf-8
"""
This scripts prints a random quote from WikiQuote page of Richard Feynman.
$ python3 feynmanize.py
!!! FEYMANIZE !!!
================================================================================
@kshitij10496
kshitij10496 / subl_config
Created January 29, 2018 13:34
Sublime Text 3 Material Design Configurations
{
"auto_complete_delay": 5,
"auto_complete_selector": "source, text",
"color_scheme": "Packages/Material Theme/schemes/Material-Theme.tmTheme",
"create_window_at_startup": false,
"default_line_ending": "unix",
"folder_exclude_patterns":
[
".svn",
".git",