Skip to content

Instantly share code, notes, and snippets.

View alesegdia's full-sized avatar
😸

Alejandro Seguí alesegdia

😸
View GitHub Profile
@alesegdia
alesegdia / multisource.lua
Created April 14, 2018 12:46
multisource.lua adapted for LÖVE2D 11.0
--[[
-- multisource lib
-- A multisource is a wrapper on top of a LÖVE source. It allows
-- creating multiple sounds easily. It uses an internal pool of
-- resources.
-- * multisource:play() finds a stopped resource from the pool,
-- or creates a new one, and plays and returns it.
-- * multisouce:cleanup() liberates the memory of old unplayed sources.
]]
@alesegdia
alesegdia / git-cheats
Last active April 20, 2018 11:33
Git cheats
# undo last N commits
git reset --hard HEAD~3
git push origin HEAD --force
# push to several remotes
git remote add all origin-host:path/proj.git
git remote set-url --add all a-host:path/proj.git
git remote set-url --add all b-host:path/proj.git
@alesegdia
alesegdia / gist:136facb3f3d0134e05f0ef18a6dc0c8d
Created January 11, 2018 13:21
Useful Symfony commands
# Symfony2 uses app/console, while Symfony3 uses bin/console
# Clear cache and update db data
php app/console cache:clear
php app/console doctrine:schema:update --force
@alesegdia
alesegdia / bytecount.php
Created March 31, 2016 19:17
utility to count bytes in a USB descriptor
<?php
$buffer = "";
while($f = fgets(STDIN))
{
$buffer = $buffer . $f;
}
function valid_byte($str)
{
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <assert.h>
/**
* http://c.learncodethehardway.org/book/ex20.html
*/
#define clean_errno() (errno == 0 ? "None" : strerror(errno))
@alesegdia
alesegdia / vecsfrommat.glsl
Last active November 6, 2015 19:03
Get Backward/Up/Right vectors from mat4
// http://roy-t.nl/index.php/2010/03/04/getting-the-left-forward-and-back-vectors-from-a-view-matrix-directly/
mat4 matrix;
vec3 right ( matrix(0,0), matrix(1,0), matrix(2,1) );
vec3 up ( matrix(0,1), matrix(1,1), matrix(2,2) );
vec3 back ( matrix(0,2), matrix(1,2), matrix(2,2) );
@alesegdia
alesegdia / install-luarocks.sh
Created October 29, 2015 09:50
LuaRocks for 5.1 and 5.2
# LuaRocks for 5.1
./configure --lua-version=5.1 --versioned-rocks-dir --lua-suffix=5.1
make build
sudo make install
# LuaRocks for 5.2
./configure --lua-version=5.2 --versioned-rocks-dir --lua-suffix=5.2
make build
sudo make install
@alesegdia
alesegdia / pyfunc.py
Created June 11, 2015 10:55
python: functions i.
def upload_to_rename(instance, filename):
# handle instance and filename
return "sample"
def build_concat(basepath, f):
def _ret(instance, filename):
return basepath + f(instance, filename)
return _ret
@alesegdia
alesegdia / glfuncgen.py
Created May 28, 2015 19:13
Generate OpenGL function names from a file
import sys
import re
infile = open( sys.argv[1], 'r' )
ret = " return\n"
for line in infile.readlines():
try:
funcname = line.rstrip()
@alesegdia
alesegdia / mongodb_startup.md
Last active September 24, 2017 22:11
MongoDB startup

MONGODB STARTUP

  • Install MongoDB

  • Make sure noauth = true is uncommented at /etc/mongodb.conf (enabled by default, but just in case)

  • Create admin user: