View chec_dslab_hw2.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# check the results of DSLAB HW2 | |
# expected input: | |
# check_hw2.py industry2cluster_123456789_987654312.csv company2cluster_123456789_987654312.csv golden.csv | |
import random | |
import sys | |
import csv | |
def read_industries(fn) -> dict: |
View check_hw2.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# check the results of DSLAB HW2 | |
# expected input: | |
# check_hw2.py industry2cluster_123456789_987654312.csv company2cluster_123456789_987654312.csv golden.csv | |
import random | |
import sys | |
import csv | |
def read_industries(fn) -> dict: |
View gist:290b6664dc9de02f78810bbbc07093b2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# burn a fresh image of raspbian. | |
# to enable ssh access: touch /boot/ssh (or before unmounting from the host: touch /media/$USER/boot/ssh) | |
# ssh-copy-id pi@<the IP> pass = raspberry | |
# | |
# install docker: | |
curl -sSL https://get.docker.com | sh | |
# I created an image after this stage using sudo dd if=/dev/sda conv=sync,noerror bs=1M > raspbian_docker-thin-2021-10-18.img | |
# | |
# copy the docker_run.sh from https://github.com/pi-hole/docker-pi-hole/blob/master/docker_run.sh | |
# modify the SERVER_IP value to the IP of the pihole machine in the LAN. |
View instrumenting.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int foo(double x){ | |
__enter(); | |
// do something with x | |
if(...) goto end; | |
// do more things | |
end: | |
__exit() | |
return 3; | |
} |
View hexdump.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <ctype.h> | |
#ifndef HEXDUMP_COLS | |
#define HEXDUMP_COLS 16 | |
#endif | |
void hexdump(void *mem, unsigned int len) | |
{ | |
unsigned int i, j; |
View test_tap_win.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# adapted to python 3.7 by Noam Cohen 2020 | |
# see https://gist.github.com/glacjay/586892 | |
import winreg as reg | |
import win32file | |
adapter_key = r'SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}' | |
def get_device_guid(): | |
with reg.OpenKey(reg.HKEY_LOCAL_MACHINE, adapter_key) as adapters: |
View drop_comma.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# remove comma char in strings in a csv file without harming the rest of the content. | |
# read input from supplied file name or from stdin | |
# write to stdout | |
# example: | |
# cat t.csv | python drop_comma.py | |
# python drop_comma.py t.csv | |
# Noam Cohen, 2019-05-05 | |
# tested with python 3.6 |
View bin_to_hex.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# read a binary file and output it in ASCII/hex | |
""" | |
$ python3 bin_to_hex.py --infile 00_00_00_400_L01.jpg --head 20 | |
0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, | |
""" | |
import argparse | |
def parse(input, max_bytes): | |
i = 0 | |
with open(input,"rb") as f: | |
while True: |
View gist:d69e830718ce9cc84fa1e5740d28206f
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# after installing ansible: | |
sudo ansible-galaxy install theNewFlesh.sublime | |
sudo ansible-galaxy install henriklynggaard.clion | |
ansible-galaxy install theNewFlesh.sublime |