Skip to content

Instantly share code, notes, and snippets.

View codeslord's full-sized avatar
🤖
I'm not a robot, I just speak their language.

Rohith Raghunathan Nair codeslord

🤖
I'm not a robot, I just speak their language.
View GitHub Profile
import json
data = {}
data['key'] = 'value'
json_data = json.dumps(data)
import json
ds = json.loads(json_data_string) #this contains the json
unique_stuff = { each['obj_id'] : each for each in ds }.values()
#Retain only the first occcurance
all_ids = [ each['obj_id'] for each in ds ] # get 'ds' from above snippet
unique_stuff = [ ds[ all_ids.index(id) ] for id in set(ids) ]
import sys
# print sys.argv[0] prints test.py
# print sys.argv[1] prints your_var_1
def hello():
print "Hi" + " " + sys.argv[1]
if __name__ == "__main__":
hello()
@codeslord
codeslord / _webserver.md
Created August 20, 2018 11:53 — forked from jgravois/_webserver.md
a simple guide for getting a local web server set up

Do I have a web server running?


having a web server turned on doesn't necessarily mean you are serving pages on the world wide web. its what allows you to load your own static files (.html, .js etc.) in a browser via http://.

if you're not sure whether or not you have a web server running, no problem! its easy to confirm.

what happens when you visit http://localhost/?

@codeslord
codeslord / useful_pandas_snippets.py
Created August 16, 2018 11:28 — forked from bsweger/useful_pandas_snippets.md
Useful Pandas Snippets
# List unique values in a DataFrame column
# h/t @makmanalp for the updated syntax!
df['Column Name'].unique()
# Convert Series datatype to numeric (will error if column has non-numeric values)
# h/t @makmanalp
pd.to_numeric(df['Column Name'])
# Convert Series datatype to numeric, changing non-numeric values to NaN
# h/t @makmanalp for the updated syntax!
dir/o/s | findstr/r " Directory | bytes" >> folder_list.txt
#http://cx-freeze.readthedocs.io/en/latest/distutils.html
import cx_Freeze
import sys
import pandas
import datetime
import gc
import numpy
import os.path
from distutils.core import setup
import py2exe
from distutils.filelist import findall
import matplotlib
setup(
console=['PlotMemInfo.py'],
options={
import pandas as pd
import glob, os
#Specifying directory
os.chdir(r"\rohith\cog-qa-reports")
#Initilizing dataframe
df = pd.DataFrame()
#Loading all html files from results
for file in glob.glob("*\Results\*.html"):
# print(file)
try:
matrixsize = 10
R = np.matrix(np.ones(shape=(matrixsize, matrixsize)))
R *= -1