Skip to content

Instantly share code, notes, and snippets.

Fernando Vicente fvicente

Block or report user

Report or block fvicente

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@fvicente
fvicente / get_langs.py
Created Dec 18, 2017
Dictionary of most used language by country based on https://stackoverflow.com/a/22202770/2962940
View get_langs.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import xml.etree.ElementTree as etree
import urllib
import pprint
def get_most_used_language_by_territory():
langxml = urllib.urlopen('http://unicode.org/repos/cldr/trunk/common/supplemental/supplementalData.xml')
langtree = etree.XML(langxml.read())
@fvicente
fvicente / world_selector.md
Last active Dec 18, 2017
Minecraft server world selector
View world_selector.md

Minecraft Server World Selector

This a very simple user interface that automatically edits the server.properties file, but it does not restarts the server.

Made in python 2.7 with pyside2. Using miniconda instead of venv, because pyside2 is not available through pip at this time.

Installation

  • Copy world_selector.py to your minecraft server directory.
@fvicente
fvicente / rgb_opacity.js
Last active Aug 5, 2017
RGB opacity calculator
View rgb_opacity.js
function colorHexToRGB(htmlColor) {
var COLOR_REGEX = /^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/;
var arrRGB = htmlColor.match(COLOR_REGEX);
if (arrRGB === null) {
alert("Invalid color passed, the color should be in the html format. Example: #ff0033");
return null;
}
var red = parseInt(arrRGB[1], 16);
var green = parseInt(arrRGB[2], 16);
var blue = parseInt(arrRGB[3], 16);
@fvicente
fvicente / etree_overload.py
Created Mar 31, 2017
When you are creating an XML with ElementTree but you want to manipulate all the values of text nodes
View etree_overload.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
import xml.etree.ElementTree as et
class OverloadedElement(et.Element):
def __setattr__(self, name, value):
if name == "text":
value = value.replace(u'ú', 'u')
value = value.replace(u'ô', 'o')
@fvicente
fvicente / flv.py
Created Feb 22, 2016
Extracting FLV meta tags with Python
View flv.py
from struct import unpack
from datetime import datetime
class FLVReader(dict):
"""
Reads metadata from FLV files
"""
# Tag types
@fvicente
fvicente / sony.py
Created Sep 13, 2015
Sony Entertainment Network spam stopper
View sony.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import requests
import urllib
import urllib2
import datetime
import sys
import time
@fvicente
fvicente / joystick.ino
Created Sep 13, 2015
Arcade Joystick with Teensy 3.0
View joystick.ino
/* Arcade Keyboard-Joystick */
#include <usb_keyboard.h>
#define NUM_BUTTONS 8
int keys[NUM_BUTTONS] = {KEY_RIGHT, KEY_UP, KEY_DOWN, KEY_LEFT, KEY_ENTER, KEY_SPACE, KEY_LEFT_ALT, KEY_Z};
int mask = 0;
int i = 0;
void setup() {
@fvicente
fvicente / compress.iss
Last active Jun 8, 2018
Compress a directory in inno setup
View compress.iss
function MakeBackup(indir, outfile: String): Boolean;
var
res: Boolean;
fso: Variant;
winShell: Variant;
f: Variant;
inObj: Variant;
outObj: Variant;
begin
res := FALSE;
@fvicente
fvicente / denise.py
Last active Sep 13, 2015
Denise’s birthday problem solution (in Python)
View denise.py
# -*- coding: utf-8 -*-
from collections import defaultdict
# (dd, mmm, yyyy)
dates = [
(17, "Feb", 2001),
(13, "Mar", 2001),
(13, "Apr", 2001),
(15, "May", 2001),
(17, "Jun", 2001),
You can’t perform that action at this time.