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 / tk_asyncio.py
Created August 26, 2021 19:14
Tkinter and asyncio proof of concept
import asyncio
import tkinter as tk
# Concepts
# https://www.tcl.tk/man/tcl8.7/TkLib/MainLoop.html
# https://www.tcl.tk/man/tcl8.7/TclLib/DoOneEvent.html
# https://www.tcl.tk/man/tcl8.7/TclCmd/update.html
# https://www.tcl.tk/man/tcl8.7/TclCmd/after.html
# SO related questions
@aleroddepaz
aleroddepaz / pyheartbeat_client.py
Created August 26, 2021 19:12
PyHeartBeat example
import sys
import time
import socket
import asyncio
DEFAULT_IP = '127.0.0.1' # local host, just for testing
DEFAULT_PORT = 43278 # an arbitrary UDP port
BEATWAIT = 1 # number of seconds between heartbeats
async def main():
@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 / persistence.xml
Last active June 28, 2023 17:54
Sample JPA 2.1 persistence units
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
version="2.1">
<!-- Hibernate + H2 -->
<persistence-unit name="standalonePu" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>com.acme.MyEntity</class>
<properties>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Event delegation example (with jQuery)</title>
<style>
button { margin: 5px; }
</style>
</head>
<body>
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 / 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
@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>
@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 / 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 {