Skip to content

Instantly share code, notes, and snippets.

Avatar

ugo ugovaretto

  • The Pawsey Supercomputing Centre
  • Kensington, Western Australia
View GitHub Profile
@ugovaretto
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
ugovaretto / site-download.sh
Created Jul 22, 2014
Download full website with wget
View site-download.sh
#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 Aug 29, 2015
Parse wsftp logs and extract host names with nslookup
View wsftp-parse.sh
#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 Aug 25, 2014
List all symbols in a .so file in ELF format
View print-elf-symbols.sh
readelf -Ws libOpenCL.so | grep -v @ | awk '{print $8}'
@ugovaretto
ugovaretto / mount-vbox-host-from-guest.sh
Last active Aug 29, 2015
Mount smb share from linux
View mount-vbox-host-from-guest.sh
#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 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
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 \
// -DGLM_FORCE_RADIANS
// -DGL_GLEXT_PROTOTYPES -L/usr/local/glfw/lib -lglfw \
@ugovaretto
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)))
(shell)
(switch-to-buffer currbuff)
(setq proc (get-process "shell"))
))
@ugovaretto
ugovaretto / benchmark
Last active Aug 29, 2015 — forked from spion/a-warning.md
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
ugovaretto / CMakeLists-cudamemcpy.txt
Created May 7, 2012
Minimal cuda program(memory transfer only)
View CMakeLists-cudamemcpy.txt
cmake_minimum_required(VERSION 2.8)
project(cudamemcpy)
include(FindCUDA)
include_directories(${CUDA_INCLUDE_DIRS})
set( SRCS cudamemcpy.cpp )
add_executable( cudamemcpy ${SRCS} )