Skip to content

Instantly share code, notes, and snippets.

View ugovaretto's full-sized avatar

Ugo Varetto ugovaretto

View GitHub Profile
@ugovaretto
ugovaretto / site-download.sh
Created July 22, 2014 13:21
Download full website with wget
#use -E instead of --html-extensions on new version of wget
#it is used to automatically add .html to any file of type text/html
wget -rkp -l5 -np --html-extension -nH http://molekel.cscs.ch
@ugovaretto
ugovaretto / wsftp-parse.sh
Last active August 29, 2015 14:04
Parse wsftp logs and extract host names with nslookup
#extract IP address then parse returned line for last host name on the line
cat /var/log/vsftpd.log | grep molekel | egrep -o '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | nslookup | egrep -o '= .*' | egrep -o ' .*$' > servers
#to print or count unique host names
cat servers | sort | uniq | wc -l
@ugovaretto
ugovaretto / print-elf-symbols.sh
Created August 25, 2014 10:40
List all symbols in a .so file in ELF format
readelf -Ws libOpenCL.so | grep -v @ | awk '{print $8}'
@ugovaretto
ugovaretto / Doxyfile
Created October 13, 2014 08:42
Doxygen sample configuration file to extract everything
# Doxyfile 1.8.7
# This file describes the settings to be used by the documentation system
# doxygen (www.doxygen.org) for a project.
#
# All text after a double hash (##) is considered a comment and is placed in
# front of the TAG it is preceding.
#
# All text after a single hash (#) is considered a comment and will be ignored.
# The format is:
@ugovaretto
ugovaretto / mount-vbox-host-from-guest.sh
Last active August 29, 2015 14:07
Mount smb share from linux
#requirement: sudo apt-get install cifs-utils
#The key to make it work is the *** vers=2.1 *** parameter
#try with versions: 1.0, 2.0, 2.1 and 3.0 (as of 10 2014), read through the cifs docs
#for up to date info, the following works from an ubuntu 14.3 guest to an Apple Mac OS Mavericks host
sudo mount -t cifs //10.0.2.2/ugo /home/ugo/m -ousername=XXX,password=YYY,vers=2.1
#to mount permanently, add entry in fstab then sudo mount -a
#/etc/fstab entry
#//10.0.2.2/<share> /media/<local path> cifs credentials=/home/<home dir>/.smbcredentials,iocharset=utf8,vers=2.1 0 0
#.smbcredentials contains:
#username=...
@ugovaretto
ugovaretto / vboxshared
Created October 28, 2014 12:42
mount virtual box xhared folder from linux
#to extract user id and group id
sudo id <user>
sudo mount -t vboxsf -o rw,uid=1000,gid=100 <host share name> <local (guest) dir name>
@ugovaretto
ugovaretto / gl-33core.cpp
Last active August 29, 2015 14:09
OpenGL 3.3 core profile - minimal example
//OpenGL scratch - reference implementation of OpenGL >= 3.3 rendering code
//Author: Ugo Varetto
//Requires GLFW and GLM, to deal with the missing support for matrix stack
//in OpenGL >= 3.3
//g++ ../src/12_scratch.cpp \
// -I/usr/local/glfw/include \
// -DGLM_FORCE_RADIANS
// -DGL_GLEXT_PROTOTYPES -L/usr/local/glfw/lib -lglfw \
@ugovaretto
ugovaretto / toshell.el
Created February 22, 2015 17:13
Send text to shell from EMACS
(defun sh-send-line-or-region (&optional step)
(interactive ())
(let ((proc (get-process "shell"))
pbuf min max command)
(unless proc
(let ((currbuff (current-buffer)))
(shell)
(switch-to-buffer currbuff)
(setq proc (get-process "shell"))
))
@ugovaretto
ugovaretto / benchmark
Last active August 29, 2015 14:27 — forked from spion/a-warning.md
C++ versus V8 versus luajit versus C benchmark - (hash) tables
spion@missperfect:~/Projects/testhash$ gcc -O3 test.c -o testc
spion@missperfect:~/Projects/testhash$ time ./testc
The 1000000
a 2000000
at 1000000
brown 1000000
dog 1000000
era 1000000
fox 1000000
jumped 1000000
@ugovaretto
ugovaretto / merge.py
Created January 28, 2016 13:32
merge sorted lists
#merge sorted lists
def merge(l1, l2):
i1, i2, i = 0, 0, 0
N1, N2 = len(l1), len(l2)
N = N1 + N2
l = []
for i in range(N):
if i1 == N1:
l.extend(l2[i2:])