Skip to content

Instantly share code, notes, and snippets.

@rafche
rafche / binary_search.py
Created August 27, 2018 19:20
some binary search example
def binarySearch(data_list, low, len, x):
'''
binary Search
:param data_list: inputdata : list
:param low: lowest element of list typical 0
:param len: len of array (n - 1)
:param x: searched value
:return: index of searched element
'''
while low <= len:
@rafche
rafche / wmic_cmds.txt
Last active August 13, 2018 14:06 — forked from xorrior/wmic_cmds.txt
Useful Wmic queries for host and domain enumeration
Host Enumeration:
--- OS Specifics ---
wmic os LIST Full (* To obtain the OS Name, use the "caption" property)
wmic computersystem LIST full
--- Anti-Virus ---
wmic /namespace:\\root\securitycenter2 path antivirusproduct
@rafche
rafche / main.py
Created August 2, 2018 19:25
some pandas action
import pandas as pd
if __name__ == '__main__':
dat = [2, 4, 4, 9, 12]
df = pd.DataFrame(dat)
print(df)
dat_2dim = [['Hot Dog', 3],['Hamburger', 2.5],['Cheeseburger',2],['Cola', 2]]
@rafche
rafche / median_mean_pandas.py
Created August 6, 2017 19:25
feel the NaN Handling of pandas dataframe
import numpy as np
import pandas as pd
nan = np.nan
median_1 = np.median([1,2,3])
median_2 = np.median([0,1,2,3])
median_3 = np.median([0,0,1,2,3])
median_4 = np.median([0,0,0,1,2,3])
# flat a list of lists, which contains multiple stacked lists
#
# expected input:
# [a, b, c, [1, 2, 3, [9, 3, 5,6 ]], e, ]
#
# output should look like:
# [a, b, c, 1, 2, 3, 9, 3, 5, 6, e]
def flat_listoflists(input_list, final_list=None):
@rafche
rafche / ironpy.py
Created May 5, 2017 11:00
Writing File with Ironpython in Spotfire
def write_file(path):
'''
:param path: Path for file
:return: nothing
'''
file = open(path+'temp21.log', 'w')
file.write('success')
file.close()