Skip to content

Instantly share code, notes, and snippets.

View svagionitis's full-sized avatar

stavros vagionitis svagionitis

View GitHub Profile
@svagionitis
svagionitis / PythonClassAssignSetter.sh
Created November 25, 2015 11:46
Read a python class and extract the attributes from the constructor
#!/bin/sh -ex
# Read an python class file and extraact the attributes
# from the constructor. Then assign them and creates setters
PYTHON_CLASS_FILE=${1}
get_constructor_definition=$(sed -n '/__init__(self,/,/):/p' ${PYTHON_CLASS_FILE} | tr -s ' ')
get_mandatory_attributes=$(echo ${get_constructor_definition} | sed 's/def\|__init__\|self//g' | sed 's/, /\n/g' | tr -d ' (,):' | grep -v '=None')
get_optional_attributes=$(echo ${get_constructor_definition} | sed 's/def\|__init__\|self//g' | sed 's/, /\n/g' | tr -d ' (,):' | grep '=None' | cut -d '=' -f 1)
@svagionitis
svagionitis / fsql.py
Created November 16, 2015 17:50 — forked from jcarbaugh/fsql.py
convert a MySQL dump into SQLite
#!/usr/bin/env python
# Convert a mysql dump into a sqlite-compatible format.
# I wrote this for just one script... no guarantess that it will work with others...
# python fsql.py < mysqldump.sql > readyforsqlite.sql
import re
import sys
content = sys.stdin.read()
@svagionitis
svagionitis / java_decompile.sh
Created November 12, 2015 14:21
Script for decompiling a jar file using JAD.
#!/bin/sh
# Decompile a jar file and create a compressed
# file with the sources.
# The [JAD decompiler](http://varaneckas.com/jad/)
# is used.
if [ $# -eq 0 ]; then
echo "Usage: $0 [jar]"
exit 1
fi
@svagionitis
svagionitis / svn-to-git.sh
Last active December 7, 2015 18:29
Convert a subversion repo to git
#!/bin/sh -ex
# Convert a subversion repo to git
# according to this link http://john.albin.net/git/convert-subversion-to-git
if [ $# -eq 0 ]; then
echo "Usage: $0 [svn repo url]"
exit 1
fi
# Checkout an svn repo
@svagionitis
svagionitis / spectrogram.py
Created September 28, 2015 19:11 — forked from maurisvh/spectrogram.py
ANSI art spectrogram viewer that reads audio from a microphone
#!/usr/bin/python
import numpy
import pyaudio
import re
import sys
WIDTH = 79
BOOST = 1.0
@svagionitis
svagionitis / noexit.sh
Last active August 29, 2015 14:27 — forked from vvv/noexit.sh
Surprise of the day
$ cat noexit.sh
#!/bin/sh
seq 100 | while read; do exit; done # If `exit' terminated the script ..
echo 'Still alive!' # .. this message would not be printed.
$
$ sh noexit.sh
Still alive!
@svagionitis
svagionitis / preprocessor_fun.h
Last active August 29, 2015 14:27 — forked from aras-p/preprocessor_fun.h
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@svagionitis
svagionitis / Makefile
Last active September 27, 2020 11:59
The odometer algorithm for an alphabet.
all: odometer_alphabet
odometer_alphabet: odometer_alphabet.c
gcc -o odometer_alphabet -O2 -Wall -W -ansi -pedantic -std=gnu99 odometer_alphabet.c
clean:
rm -rf odometer_alphabet
@svagionitis
svagionitis / gstreamer_build.sh
Last active September 28, 2015 08:01
Build gstreamer and plugins from the git repositories specifying the branch
#!/bin/sh -ex
mkdir -p sysroot
PREFIX_DIR=$(readlink -e sysroot)
mkdir -p $PREFIX_DIR/include
INCLUDE_DIR=$(readlink -e $PREFIX_DIR/include/)
mkdir -p $PREFIX_DIR/lib
LIB_DIR=$(readlink -e $PREFIX_DIR/lib/)
mkdir -p $LIB_DIR/pkgconfig
PKG_CONFIG_PATH=$(readlink -e $LIB_DIR/pkgconfig/)
@svagionitis
svagionitis / Makefile
Last active August 29, 2015 14:18 — forked from isaacs/Makefile
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.