Skip to content

Instantly share code, notes, and snippets.

View jmorenoamor's full-sized avatar
🚀
Software craftsman, Master of nothing. I love space stuff.

Jesús Moreno Amor jmorenoamor

🚀
Software craftsman, Master of nothing. I love space stuff.
View GitHub Profile
@jmorenoamor
jmorenoamor / fix_file_dir.sh
Created January 19, 2014 19:37
Fix files being converted to directories
set -x
for qwer in *.{jpg,gif,png}/;
do
if [[ "$qwer" != "*"* ]] ; then
echo "$qwer";
mv "$qwer" "_BCK${qwer}"
cat "_BCK${qwer}" > "${qwer}"
fi
done
set +x
@jmorenoamor
jmorenoamor / maven_slf4j.xml
Created December 10, 2013 11:20
Add SLF4J support in Maven project
<!-- Properties -->
<slf4jVersion>1.6.1</slf4jVersion>
<!-- Dependencies -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4jVersion}</version>
</dependency>
@jmorenoamor
jmorenoamor / python_enums.py
Created December 10, 2013 08:54
Enumerations in Python
################################################################################
# Enumerations in Python
################################################################################
def enum(*sequential, **named):
enums = dict(zip(sequential, range(len(sequential))), **named)
reverse = dict((value, key) for key, value in enums.iteritems())
enums['reverse_mapping'] = reverse
return type('Enum', (), enums)
@jmorenoamor
jmorenoamor / JSON.mte
Last active December 23, 2015 17:59
MP3Tag export script for generating a JSON structured library file
$filename(json,utf-8){
"songs": '['
$loop(%_filename_ext%) {
"title": "%title%",
"album": "%album%",
"artist": "%artist%",
"album_artist": "%albumartist%",
"composer": "$meta(composer,1)",
"publisher": "%publisher%",
"genre": $meta("%genre%",1),
@jmorenoamor
jmorenoamor / gist:6111156
Last active December 20, 2015 09:49
SQLPlus setup file
-- -----------------------------------------------------------------------------
-- SQLPlus dump setup file
-- Jesús Moreno Amor <[email protected]>
-- May 2012
--
-- Execute:
-- sqlplus -S user/password@database @DumpSetup.sql RealQuery.sql
-- -----------------------------------------------------------------------------
-- SQLPlus session configuration
@jmorenoamor
jmorenoamor / download_resource_oneline.py
Created January 4, 2013 10:51
Download a remote resource using python requests library
with open("downloaded_file.html", 'w') as file:
file.write(requests.get('http://www.example.com').content)
@jmorenoamor
jmorenoamor / download_file.py
Created January 4, 2013 10:42
Download a remote resource using python and requests
# All the magic comes from the requests library http://www.python-requests.org
import requests
# URI of the resource we want to download
FILE_URI = 'http://www.example.com'
# Path to the local file where we will save the remote resource
FILE_NAME = 'downloaded_file.html'
# Chunk size that we will keep in memory, in bytes
@jmorenoamor
jmorenoamor / jar_decompile.sh
Last active October 7, 2015 00:17
Decompile a JAR file
#!/bin/bash
JAR=$1.jar
unzip -d $JAR.tmp $JAR
pushd $JAR.tmp
for f in `find . -name '*.class'`; do
jad -d $(dirname $f) -s java -lnc $f
done
popd
@jmorenoamor
jmorenoamor / StackTraceToString.java
Created June 29, 2012 11:47
Stack trace to String
// Inline
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));
String exceptionAsStrting = sw.toString();
// Function
public String stackTraceToString(Throwable e)
{
StringBuilder sb = new StringBuilder();
for (StackTraceElement element : e.getStackTrace())
@jmorenoamor
jmorenoamor / java_properties_example.java
Created June 7, 2012 15:36
Properties file reading and writing example with Java
package com.morenoamor.tutorials;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
/**
* Properties file reading and writing example