Skip to content

Instantly share code, notes, and snippets.

View aleroddepaz's full-sized avatar

Alex Rodas aleroddepaz

  • Telefónica
  • Madrid, Spain
View GitHub Profile
@aleroddepaz
aleroddepaz / HelloWorld.java
Created March 3, 2014 21:10
JavaFX example application
public class HelloWorld extends Application {
private Calculator calculatorService;
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws MalformedURLException {
@aleroddepaz
aleroddepaz / pure-js-treeview.html
Last active August 29, 2015 14:25
Pure JS Treeview, based on nested unordered lists
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
<style>
.treeview ul {
padding-left: 24px;
list-style-type: none;
}
.treeview li > div {
@aleroddepaz
aleroddepaz / app.js
Created July 27, 2015 20:39
Backbone example with a Model, Collection and View
(function ($) {
// Create a model to hold friend atribute
Friend = Backbone.Model.extend({
name: null
});
// This is our Friends collection and holds our Friend models
Friends = Backbone.Collection.extend({
initialize: function (models, options) {
// Listen for new additions to the collection and call a view function if so
import os
import shutil
import filecmp
from itertools import combinations
DIR = 'C:/Alotofwildphotos'
DEST_DIR = 'C:/Alotofwildphotos/Repeated'
files = filter(os.path.isfile, map(lambda f: os.path.join(DIR, f), os.listdir(DIR)))
@aleroddepaz
aleroddepaz / rgb2cie.py
Created April 5, 2013 12:40
Script to convert RGB color to CIE color space
import sys
def rgb_to_xy(r, g, b):
X = 0.412453 * r + 0.357580 * g + 0.180423 * b
Y = 0.212671 * r + 0.715160 * g + 0.072169 * b
Z = 0.019334 * r + 0.119193 * g + 0.950227 * b
x = X / (X+Y+Z)
y = Y / (X+Y+Z)
return x, y
@aleroddepaz
aleroddepaz / rename_songs.py
Last active December 16, 2015 04:39
Script to rename all the .mp3 files of a directory with a custom pattern. It uses the module eye3d. To find more information about it, check http://eyed3.nicfit.net/
import os
import re
import sys
import eyed3
def rename_songs(path, pattern):
if not check_arguments(path, pattern):
exit(1)
listdir = [os.path.join(path, f) for f in os.listdir(path)]
files = filter(os.path.isfile, listdir)
@aleroddepaz
aleroddepaz / md5sum.py
Created June 11, 2013 23:49
Script to verify data integrity using the MD5 hash.
import sys
import hashlib
from functools import partial
def md5sum(filename):
with open(filename, mode="rb") as f:
md5 = hashlib.md5()
buf_size = md5.block_size * 64
for buf in iter(partial(f.read, buf_size), b''):
@aleroddepaz
aleroddepaz / music2time.py
Created June 15, 2013 19:48
Script to keep track of keydown events during playing music.
import pygame
import time
import sys
def main(ogg_file, output_file):
pygame.display.init()
pygame.display.set_mode((100, 100))
pygame.mixer.init()
pygame.mixer.music.load(ogg_file)
f = open(output_file, 'w')
@aleroddepaz
aleroddepaz / flex.html
Created November 10, 2016 21:58
Flexbox navigation menu
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>Flex navigation menu</title>
<style>
body {
font-family: sans-serif;
margin: 0;
}
@aleroddepaz
aleroddepaz / counter.html
Last active April 13, 2017 21:22
ES6 class for a counter widget
<!DOCTYPE html>
<html>
<head>
<title>Hello, ES6</title>
<script src="counter.js"></script>
</head>
<body>
<my-counter></my-counter>
</body>
</html>