Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View eruffaldi's full-sized avatar

Emanuele Ruffaldi eruffaldi

View GitHub Profile
@eruffaldi
eruffaldi / xcd.sh
Last active March 16, 2016 12:07
Named working locations or initialization
#!/bin/bash
function _xcdall()
{
#enter below space separated your commands
eval "$1='pd1 xxx u14'"
}
function xcd() {
local arrIN sep before after what
what=$1
@eruffaldi
eruffaldi / learnexp.el
Last active April 6, 2016 16:16
Lisp Interpreter in Python with Code Generation tailored to Matrix manipulation
(
list
(defun makefactor (n)
(define q dict)
(set! q.vars dict)
(set! q.uS dict)
(set! q.Jhg (gaussianc n))
q
)
(define f1 (makefactor 2))
@eruffaldi
eruffaldi / reusablememory.cpp
Created May 16, 2016 16:01
Memory pool shared ptr
#include <memory>
#include <vector>
#include <iostream>
#include <list>
template <class T>
class VectorPool
{
public:
~VectorPool()
@eruffaldi
eruffaldi / CMakeLists.txt
Last active May 27, 2016 04:02 — forked from allanmac/assert_cuda.c
A tiny example of CUDA + OpenGL interop with write-only surfaces and CUDA kernels. Uses GLFW+GLAD.
#sudo pip install --upgrade git+https://github.com/dav1dde/glad.git#egg=glad
#python main.py --api gl=3.3 --generator=c --out-path=GL
find_package(CUDA)
find_package(GLFW)
include_directories(${GLFW_INCLUDE_DIRS})
include_directories(GL/include)
cuda_add_executable(main main.c assert_cuda.c interop.c GL/src/glad.c kernel.cu)
target_link_libraries(main ${GLFW_LIBRARY})
@eruffaldi
eruffaldi / pygamebottom.py
Last active July 28, 2016 22:05
Always keep window on bottom in Python for Windows and pygame
# pygame always background
# Emanuele Ruffaldi 2016
import sys, pygame
import win32gui, win32con
import sys, ctypes
class WINDOWPOS(ctypes.Structure):
_fields_ = [
('hwnd', ctypes.c_ulong),
('hwndInsertAfter', ctypes.c_ulong),
@eruffaldi
eruffaldi / writehere.sb
Created August 29, 2016 09:56
OSX Sandboxing Writing
(version 1)
(deny default)
(allow file-read*)
(allow process-exec)
(allow sysctl-read)
(allow signal)
(allow file-write* (regex (string-append "^" (regex-quote (param "target")) ".*")))
@eruffaldi
eruffaldi / gist:268aec63d5cf44f2497caf1afaa888b6
Created September 2, 2016 13:23
C++ List Snippet Tools
struct List
{
ListNode * first = 0, * last = 0;
void append(ListNode*p)
{
if(first)
{
last->next = p;
last = p;
}
@eruffaldi
eruffaldi / stack_array
Last active September 16, 2016 11:46
stack_array and hstack_array for examples of stack arrays based respectively on alloca and pre-allocated size
/**
* A little exercise on stack_array
*
* FOUND (too late) https://tlzprgmr.wordpress.com/2008/04/02/c-how-to-create-variable-length-arrays-on-the-stack/
* - desctruction removal
* - note about parameter issue
* - alignment management
* - generic construction
* - hybrid version using a fixed buffer Q and then heap
*
@eruffaldi
eruffaldi / debruijgrid.py
Last active September 20, 2016 04:35
De Bruijin Grid
# Emanuele Ruffaldi line pattern generator using De Bruij sequences 2016
#
# Supports arithmetic, geometric and custom alphabet
# Supports also basic uniform for comparison
from PIL import Image, ImageDraw
def colorparse(s):
try:
x, y, z = map(int, s.split(','))
return x, y, z
#!/usr/bin/python
#
# Catking Subfolders creator => FOCUS
# Emanuele Ruffaldi @ SSSA 2016
import argparse
import xml.etree.ElementTree as ET
import os,sys
known = "catkin,roscpp,cmake_modules,geometry_msgs,tf,message_generation,urdf,xacro,message_runtime,std_msgs,std_srvs"
def commonpath(path1,path2):