Skip to content

Instantly share code, notes, and snippets.

View posva's full-sized avatar
🙏
sponsor me on GitHub

Eduardo San Martin Morote posva

🙏
sponsor me on GitHub
View GitHub Profile
@posva
posva / boot-key.sh
Last active August 29, 2015 13:55
Creates a bootable key on OSX
#! /bin/bash
good() {
echo "$@"
}
msg() {
echo "$@"
}
@posva
posva / vv
Last active August 29, 2015 13:57
#! /bin/bash
# Open multiple files in vim
# Every hpp, cpp couple is opened in a separted tab
# by Eduardo San Martin Morote aka Posva
# http://posva.net
HPP="hpp"
CPP="cpp"
function _set_T() {
@posva
posva / tmux.conf
Created July 28, 2014 19:55
Some conf I need to edit
set-window-option -g utf8 on
set-window-option -g mode-keys vi
set -s escape-time 0
setw -g window-status-current-attr underscore
set-option -g default-terminal "screen-256color"
set-option -g status-interval 5
set -g pane-active-border-fg white
@posva
posva / diff.js
Created August 14, 2014 13:31
Advanced diff between arrays
var diff = function(a, b) {
var c = [], dels = [], delsIndex = [];
var i = 0, j = 0, k,
x, y, z;
var t = 0; //debug
while (i < a.length || j < b.length) {
x = a[i];
y = b[j];
t++;
@posva
posva / fancy-header.vim
Created August 17, 2014 16:13
Use Ctr+H to add the classic header with defines guards for C/C++ files
" fill rest of line with characters
function! FillLine( str, l )
" strip trailing spaces first
.s/[[:space:]]*$//
" calculate total number of 'str's to insert
let reps = (a:l - col("$")) / len(a:str)
" insert them, if there's room, removing
" trailing spaces (though forcing
" there to be one)
if reps > 0
@posva
posva / watcher.sh
Created August 22, 2014 14:50
Watch for files changes
#! /bin/sh
WHEN=$(stat -c "%Y" report.tex)
while true; do
NOW=$(stat -c "%Y" report.tex)
if [ "$NOW" -gt "$WHEN" ]; then
make
fi
WHEN="$NOW"
sleep 1
@posva
posva / lines.sh
Created September 2, 2014 14:09
Generates a dirtree (LaTex) view with line count
#! /bin/bash
L=$(echo index_a6_se_ast.html index_a6_se_tst.html js_a6_se_ast/*.js js_a6_se_tst/*.js js/lib/qtBinding.js js/lib/nuntius.js js_a6_se_tst/css/main.css json/README.md json/genjs.sh json/genjson.py json/a6JSONValidator.js)
N=$(cat $L | wc -l)
echo "Total $N"
old=''
for i in $L; do
T=$(wc -l $i)
lines=$(echo "$T" | cut -d " " -f1)
@posva
posva / quote
Created May 17, 2013 19:45
Color formatted code for zsh (may work in other terminals) to display a random quote from http://www.quotationspage.com/random.php3
#! /bin/zsh
Q=$(curl -s "http://www.quotationspage.com/random.php3" | grep -m 1 "dt ")
TXT=$(echo "$Q" | sed -e 's/<\/dt>.*//g' -e 's/.*html//g' -e 's/^[^a-zA-Z]*//' -e 's/<\/a..*$//g')
W=$(echo "$Q" | sed -e 's/.*\/quotes\///g' -e 's/<.*//g' -e 's/.*">//g')
echo "\e[0;33m${W}\033[0\e[0;30m: \e[0;35m“${TXT}”\e[m"
@posva
posva / FPS.hpp
Created July 22, 2013 10:24
Simple FPS display for SFML2
#pragma once
#include <SFML/Graphics/Text.hpp>
#include <SFML/System/Clock.hpp>
#include <sstream>
class FPS : public sf::Text {
sf::Clock myClock;
unsigned int mySteps;
@posva
posva / Makfile
Created August 18, 2013 17:40
Simple Makefile for C/C++ projects that work even adding new files. The dependencies are not fully correct though. Yet this Makefiles is really useful. Use the src/, obj/, bin/ structure
CXX = g++
OBJ = obj
SRC = src
BIN = bin
STD := -std=c++0x
EXT_IL := -I$(SRC)
MAIN := Test
TEST_DIR := tests