Skip to content

Instantly share code, notes, and snippets.

View ichramm's full-sized avatar

Juan Ramirez ichramm

View GitHub Profile
@ichramm
ichramm / network_logger.cpp
Created November 22, 2012 12:19
Sample network logger
/*!
* Makes sure the log object is available while the program is running
*/
class network_logger
{
public:
network_logger()
{
NNetwork::SetLogger(&m_logger);
}
@ichramm
ichramm / arg_parser.sh
Created November 22, 2012 12:24
bash args parser
#
# Parses and argument from the command line
# the format must be arg <value>
#Ex:
# parse_arg result "-ip" "$@"
# [[ $? -eq 0 ]] && echo "IP: $result" || echo "Param -ip not found"
# parse_arg result "-m" "$@"
# [[ $? -eq 0 ]] && echo "MSG: $result" || echo "Param -m not found"
# where your command line arguments could be: -ip 127.0.0.1 -m "Hello Mr. Sapiens"
#
@ichramm
ichramm / rlimit_core.c
Created November 22, 2012 12:26
set rlimit for core file
struct rlimit rl;
memset(&rl, 0, sizeof(rl));
rl.rlim_cur = RLIM_INFINITY;
rl.rlim_max = RLIM_INFINITY;
if (setrlimit(RLIMIT_CORE, &rl)) {
fprintf(stderr, "Unable to disable core size resource limit: %s\n", strerror(errno));
}
@ichramm
ichramm / change_extension.sh
Created November 22, 2012 12:28
Change file extension
extfrom=$1
extto=$2
for i in *.$extfrom; do
mv $i ${i%%.$extfrom}.$extto;
done
@ichramm
ichramm / remove_track_number.sh
Created November 22, 2012 12:30
UK Top 40 Singles Chart
#
# itera sobre los archivoss de una carpeta
# se fija si el archivo arranca con un numero
# si arranca con un numero se lo quita
# usado para quitar los duplicados de los UK Top 40
# lo que hago es mover todos a una unica carpeta, sin lo numeros porque, por lo general, estan en distinta posicion de semana a semana
#
@ichramm
ichramm / wine2unix.sh
Created November 22, 2012 12:31
Run linux command from within wine
#!/bin/bash
#Z:\bin\bash $HOME/Dropbox/linux/wine2unix.sh kate "%1"
exec=$1;
[[ -n "$2" ]] && path=`winepath -u "$2"`;
[[ -n "$3" ]] && path2=`winepath -u "$3"`;
@ichramm
ichramm / boost_install.sh
Created November 22, 2012 12:35
Compiles and installs boost with selected libraries
#!/bin/bash
# should run as root
./bootstrap.sh
./b2 --show-libraries
./b2 --build-type=complete \
--layout=versioned \
@ichramm
ichramm / logger.h
Created November 23, 2012 16:08
Log wrapper with extended info
/*!
* \file logger.h
* \author ichramm
*/
#ifndef logger_h__
#define logger_h__
#define inconcert_log_debug(fmt, ...) if(logger::is_level_enabled(logger::LevelDebug)) \
inconcert_log(logger::LevelDebug, "%s:%d %s - " fmt, logger::get_filename_part(__FILE__), __LINE__, __FUNCTION__ , ## __VA_ARGS__)
@ichramm
ichramm / longclaw.sh
Last active October 13, 2015 03:58
longclaw: dependency-based personal builder (runs a DFS in the dependency-tree)
#!/bin/bash
#
# Smart builder for inConcert... ... ... ...
#
set -e
function info()
{
@ichramm
ichramm / cppredis_raii.cpp
Created December 3, 2012 19:42
RAII in cppredis
struct CRedisDriver::scoped_connection
{
scoped_connection(CppRedis::Pool& pool)
: _pool(pool)
, _connection(_pool.GetConnection())
{
}
~scoped_connection()
{