Skip to content

Instantly share code, notes, and snippets.

# 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:
@noam1023
noam1023 / check_hw2.py
Created November 28, 2021 10:12
for review - Almog
# 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:
@noam1023
noam1023 / gist:290b6664dc9de02f78810bbbc07093b2
Created October 18, 2021 16:01
install Pihole in Docker in Raspbian Buster
# 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.
int foo(double x){
__enter();
// do something with x
if(...) goto end;
// do more things
end:
__exit()
return 3;
}
#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;
@noam1023
noam1023 / test_tap_win.py
Created April 14, 2020 06:34
sample python 3.7 code to use Windows TAP driver
# 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:
@noam1023
noam1023 / drop_comma.py
Created May 7, 2019 06:43
preprocess csv file to remove commas appearing in ""
# 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
@noam1023
noam1023 / bin_to_hex.py
Created February 12, 2019 12:31
print binary data as hex string for inclusion in source code
# 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:
@noam1023
noam1023 / gist:d69e830718ce9cc84fa1e5740d28206f
Created November 11, 2017 19:18
bootstrap the ansibl3
# after installing ansible:
sudo ansible-galaxy install theNewFlesh.sublime
sudo ansible-galaxy install henriklynggaard.clion
ansible-galaxy install theNewFlesh.sublime