Skip to content

Instantly share code, notes, and snippets.

View sambatyon's full-sized avatar

Alexander Rojas sambatyon

View GitHub Profile
@sambatyon
sambatyon / gist:9134348
Created February 21, 2014 13:37
Extracts headers from a source tree.
#!/bin/bash
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: extractheaders src dest"
exit
@sambatyon
sambatyon / joinpdf.sh
Last active November 9, 2021 16:25
small scripts used to create a full pdf document.
#!/bin/bash
if [[ `uname` =~ MINGW.* ]]; then
GS=gswin64c
else
GS=gs
fi
output=$1
shift
@sambatyon
sambatyon / save-jpeg.cc
Created July 24, 2012 14:04
Encode an rgb to jpeg and save it to a buffer
void EncodeJPEG(boost::uint8_t *rgb, const int &width, const int &height,
boost::shared_array<boost::uint8_t> &outbuffer, int *size) {
jpeg_compress_struct cinfo = {0};
jpeg_error_mgr jerror = {0};
jerror.trace_level = 10;
cinfo.err = jpeg_std_error(&jerror);
jerror.trace_level = 10;
cinfo.err->trace_level = 10;
jpeg_create_compress(&cinfo);
@sambatyon
sambatyon / .emacs
Last active February 19, 2019 12:42
Latest OS agnosic version
;;; package -- Sumary
;;; Commentary:
;;; Code:
;;; Set load path
(add-to-list 'load-path "~/.emacs.d/custom/")
;;;; PACKAGE SYSTEM
;; For some reason, this must be one of the first things to be loaded.
(require 'package)
@sambatyon
sambatyon / Sha1Sum.cc
Created February 13, 2012 19:17
Small function to compute the sha1 sum of data in c++
#include <boost/uuid/sha1.hpp>
#include <sstream>
#include <cstddef>
#include <string>
std::string Sha1sum(void *data, std::size_t count) {
boost::uuids::detail::sha1 hasher;
char hash[20];
hasher.process_bytes(data, count);
unsigned int digest[5];
@sambatyon
sambatyon / .bashrc
Created February 13, 2012 19:15
My own bashrc file
if [ -n "$PS1" ]; then
alias ls='ls -h --color'
alias grep='grep --color'
alias egrep='egrep --color'
alias fgrep='fgrep --color'
else
alias ls='ls -h'
fi
alias ll='ls -l --group-directories-first'
@sambatyon
sambatyon / rgb2yuv.cc
Created February 13, 2012 16:02
Transforms a bitmap int RGB 8:8:8 24bpp into an equivalent YUV420p 4:2:0 12bpp
void Bitmap2Yuv420p(boost::uint8_t *destination, boost::uint8_t *rgb,
const int &width, const int &height) {
const std::size_t image_size = width * height;
boost::uint8_t *y = destination;
boost::uint8_t *u = destination + image_size;
boost::uint8_t *v = destination + image_size + image_size / 4;
boost::uint8_t *r = rgb;
boost::uint8_t *g = rgb + 1;
boost::uint8_t *b = rgb + 2;