Skip to content

Instantly share code, notes, and snippets.

@rozanecm
rozanecm / Basic client socket in C.c
Last active October 17, 2017 00:36
Basic client socket in C, wo error check
#define BUF_SIZE
#define IP
#define PORT
int main(int argc, char* argv[]){
structo addrinfo hints;
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_INET; //case for IPv4. Use AF_INET6 for IPv6 or AF_UNSPEC for either
hints.ai_socktype = SOCK_STREAM;
@rozanecm
rozanecm / Basic server socket in C.c
Last active October 17, 2017 00:35
Basic server socket in C, wo error check
#define BUF_SIZE
#define PORT
#define MAX_CONNECTION_QUEUE
int main(int argc, char* argv[]){
structo addrinfo hints;
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_INET; //case for IPv4. Use AF_INET6 for IPv6 or AF_UNSPEC for either
hints.ai_socktype = SOCK_STREAM;
@rozanecm
rozanecm / Base converter in C.c
Last active October 17, 2017 00:34
Prompts for base 10 number and the base it is to be converted to. Prints number in specified base.
/* NOTE: this code has been copied from
** https://www.phanderson.com/C/baseprnt.html with academic
** purposes.
*/
/* Progam BASEPRNT.C
**
** Prompts for base 10 number and the base it is to be converted to.
** Prints number in specified base.
**
@rozanecm
rozanecm / states.csv
Last active August 2, 2023 14:31
Distance between geographic centers of all US states
state latitude longitude
Alabama 32.7794 -86.8287
Alaska 64.0685 -152.2782
Arizona 34.2744 -111.6602
Arkansas 34.8938 -92.4426
California 37.1841 -119.4696
Colorado 38.9972 -105.5478
Connecticut 41.6219 -72.7273
Delaware 38.9896 -75.5050
District of Columbia 38.9101 -77.0147
# Example taken from https://kevinzakka.github.io/2016/07/13/k-nearest-neighbor/
import numpy as np
from sklearn.cross_validation import train_test_split
# create design matrix X and target vector y
X = np.array(df.ix[:, 0:4]) # end index is exclusive
y = np.array(df['class']) # another way of indexing a pandas df
# split into train and test
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=42)
@rozanecm
rozanecm / Exploratory analysis helpful functions
Last active September 2, 2019 17:37
Some useful functions for when performing exploratory analysis with pandas.
Empty file for title purpose only.
@rozanecm
rozanecm / 0 ml useful gists
Last active October 31, 2019 14:25
Pipeline blueprint to have fast access to creating ml models.
.
@rozanecm
rozanecm / Free Springer Books - eBook list.csv
Created April 9, 2020 00:25
Download script for all free Springer books offered during Covid 2020 qurantine.
We can make this file beautiful and searchable if this error is corrected: It looks like row 3 should actually have 22 columns, instead of 18. in line 2.
Book Title,Author,Edition,Product Type,Copyright Year,Copyright Holder,Print ISBN,Electronic ISBN,Language,Language Collection,eBook Package,English Package Name,German Package Name,Series Print ISSN,Series Electronic ISSN,Series Title,Volume Number,DOI URL,OpenURL,Subject Classification,Publisher,Imprint
Social Anxiety and Social Phobia in Youth,Christopher Kearney,2005,Graduate/advanced undergraduate textbook,2005,Springer-Verlag US,978-0-387-22591-3,978-0-387-22592-0,EN,English/International,11640,Behavioral Science,,,,Series in Anxiety and Related Disorders,,http://doi.org/10.1007/b99417,http://link.springer.com/openurl?genre=book&isbn=978-0-387-22592-0,Psychology; Clinical Psychology; Personality and Social Psychology; Community and Environmental Psychology,Springer US,Springer
Clinical Neuroanatomy,"John Mendoza, Anne Foundas",2008,Graduate/advanced undergraduate textbook,2008,Springer-Verlag New York,978-0-387-36600-5,978-0-387-36601-2,EN,English/International,11640,Behavioral Science,,,,,,http://doi.o
@rozanecm
rozanecm / mp4_to_mp3_320k.sh
Created April 13, 2020 17:12
Extract mp3 320k from mp4 video.
for i in *.mp4; do ffmpeg -i "$i" -b:a 320k -vn "${i%.*}.mp3"; done
@rozanecm
rozanecm / print_src.sh
Last active May 24, 2020 04:28
Make sure all lines are <80! This gist will generate pdfs for all .cpp and .h files in src/. A pdf per file will be stored in "print output/". All pdfs will be merged to one final file "final_print.pdf".
# print all .cpp and .h files
for f in $(find src/ -name '*.cpp' -or -name '*.h')
do
echo "Processing $f..."
a2ps --line-numbers=1 "$f" -o "$f".ps
done
mkdir "print output"
#for f in src/*.ps