Skip to content

Instantly share code, notes, and snippets.

View mariomartinezsz's full-sized avatar

Mario Martínez Sánchez mariomartinezsz

View GitHub Profile
@mariomartinezsz
mariomartinezsz / rmimage.py
Created September 1, 2011 02:05
Python script that finds and deletes image files by extension and size
# Deletes image files by size and extension
import os, glob, Image, sys
inipath = '/your/path/'
fileSize = (24,24)
fileExt = '.png' #.png .gif .jpg
def scandirs(path):
for currentFile in glob.glob( os.path.join(path, '*') ):
if os.path.isdir(currentFile):
@mariomartinezsz
mariomartinezsz / buscapdf.py
Created January 5, 2013 20:20
Find links to pdf files in HTML with BeautifulSoup (Just one level)
import urllib2
from bs4 import BeautifulSoup
my_url = 'http://slav0nic.org.ua/static/books/python/'
html=urllib2.urlopen(my_url).read()
sopa = BeautifulSoup(html)
current_link = ''
for link in sopa.find_all('a'):
current_link = link.get('href')
if current_link.endswith('pdf'):
print('Tengo un pdf: ' + current_link)
#!/bin/sh
if [ -z "$6" ]
then
echo "Usage: `basename $0` [-n] <filename> <start time> <duration> <scale to width> <framestep> <resultname.gif>\n-n — turn off subtitles"
else
OPT=
if [ "$1" = "-n" ]
then
OPT="-nosub -noautosub"
shift
@mariomartinezsz
mariomartinezsz / new_table_sqlite.py
Created January 5, 2013 22:38
Create a SQLite db and a table with Python
import sqlite3
cnn = sqlite3.connect('mydata.db')
mycursor = cnn.cursor()
# create table
sql_new_table = '''create table products
(code text, desc text, value real)'''
mycursor.execute(sql_new_table)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Simple script to create geojson from osm files.
Prints geojson features line by line.
Currently we don't support relations.
Requires (unmodified) imposm and imposm.parser
Inspired by https://github.com/emka/OSMCouch
'''
@mariomartinezsz
mariomartinezsz / install-couchdb-1.4.0.sh
Last active December 25, 2015 10:59
Install CouchDB 1.4.0 on Ubuntu Server (Tested with Ubuntu Server 12.04 LTS Precise Pangolin)
#!/bin/sh
# Based on http://jswiki.lab-01.com/wiki/doku.php?id=install-couch
echo "Downloading Linux build tools and Erlang"
sudo apt-get install build-essential libicu-dev libcurl4-gnutls-dev libtool erlang-dev erlang zip -y
# Work on tmp directory
cd /tmp
# Spidermonkey is required
@mariomartinezsz
mariomartinezsz / newandroiddir.java
Created November 9, 2013 09:58
Create directory in Android
// External storage
String root = Environment.getExternalStorageDirectory().toString();
// Internal storage
//String root = Environment.getRootDirectory().toString();
File myDir = new File(root + "/mynewdir");
myDir.mkdirs();
@mariomartinezsz
mariomartinezsz / writeandroidfile.java
Last active December 27, 2015 20:19
Create and write file in Android
private void writeFile(){
String root = Environment.getExternalStorageDirectory().toString();
//String root = Environment.getRootDirectory().toString();
File myDir = new File(root + "/mydir");
myDir.mkdirs();
String fname = "myfile.txt";
File file = new File (myDir, fname);
if (file.exists ()) file.delete ();
try {
BufferedWriter buf = new BufferedWriter(new FileWriter(file, true));
@mariomartinezsz
mariomartinezsz / gist:7405775
Last active April 20, 2017 00:24 — forked from clsung/gist:6822574
"A simple crop image to 80x80 jpeg file script" with GoLang
package main
import (
"fmt"
"os"
"log"
"flag"
"image"
_ "image/gif"
"image/jpeg"
public class RestClient {
private ArrayList<NameValuePair> params;
private ArrayList<NameValuePair> headers;
private String url;
private int responseCode;
private String message;