Skip to content

Instantly share code, notes, and snippets.


ugo ugovaretto

  • The Pawsey Supercomputing Centre
  • Kensington, Western Australia
View GitHub Profile
ugovaretto / variadic-base.cpp
Created May 12, 2014
Base class initialization with variadic templates
View variadic-base.cpp
#include <iostream>
struct B1 {
B1(int) {}
int Get() const { return 1; }
struct B2 {
B2(int) {}
int Get() const { return 2; }
ugovaretto /
Created Jul 22, 2014
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
ugovaretto /
Last active Aug 29, 2015
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 /
Created Aug 25, 2014
List all symbols in a .so file in ELF format
readelf -Ws | grep -v @ | awk '{print $8}'
ugovaretto /
Last active Aug 29, 2015
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 // /home/ugo/m -ousername=XXX,password=YYY,vers=2.1
#to mount permanently, add entry in fstab then sudo mount -a
#/etc/fstab entry
#//<share> /media/<local path> cifs credentials=/home/<home dir>/.smbcredentials,iocharset=utf8,vers=2.1 0 0
#.smbcredentials contains:
ugovaretto / vboxshared
Created Oct 28, 2014
mount virtual box xhared folder from linux
View vboxshared
#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 / gl-33core.cpp
Last active Aug 29, 2015
OpenGL 3.3 core profile - minimal example
View gl-33core.cpp
//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 \
// -DGL_GLEXT_PROTOTYPES -L/usr/local/glfw/lib -lglfw \
ugovaretto / toshell.el
Created Feb 22, 2015
Send text to shell from EMACS
View toshell.el
(defun sh-send-line-or-region (&optional step)
(interactive ())
(let ((proc (get-process "shell"))
pbuf min max command)
(unless proc
(let ((currbuff (current-buffer)))
(switch-to-buffer currbuff)
(setq proc (get-process "shell"))
ugovaretto / benchmark
Last active Aug 29, 2015 — forked from spion/
C++ versus V8 versus luajit versus C benchmark - (hash) tables
View benchmark
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 / CMakeLists-cudamemcpy.txt
Created May 7, 2012
Minimal cuda program(memory transfer only)
View CMakeLists-cudamemcpy.txt
cmake_minimum_required(VERSION 2.8)
set( SRCS cudamemcpy.cpp )
add_executable( cudamemcpy ${SRCS} )