Skip to content

Instantly share code, notes, and snippets.

View paulera's full-sized avatar

Paulo Amaral paulera

View GitHub Profile
@paulera
paulera / fontListing.pde
Last active March 6, 2017 13:27
List some fonts in Processing and save the result as a png.
PFont defaultFont;
int paddingLeft = 25;
int paddingTop = 20;
int row = 0;
int fontSize = 24;
int lineHeight = fontSize * 4;
int examplesPerColumn = 9;
int exampleCount = 0;
int columnWidth = 900;
@paulera
paulera / AccelerometerReader class.pde
Created March 7, 2017 16:42
To read accelerometer values from LightBlue Bean
// Required library to communicate with Serial port
import processing.serial.*;
// variables to store rectangle X position, Y position, Width and Height
int x, y;
// The object that wil communicate with the Serial port
AccelerometerReader reader;
void setup() {
@paulera
paulera / processing-run-script-example.pde
Created April 3, 2017 11:55
Processing example of how to dynamically run javascript code from a String, passing objects to be read and manipulated in the script scope. Originated in this Processing Forum thread: https://forum.processing.org/two/discussion/comment/93357
import javax.script.*;
void setup() {
// creates and object to be manipulated by
// the script
MyClass obj = new MyClass();
// object state BEFORE running the script
println("Before:");
@paulera
paulera / checkdates.sh
Last active April 6, 2017 16:34
Monitor GNIB renewal dates
#!/bin/bash
# Command to monitor the available dates for booking a working permit renewal in GNIB office:
watch -n 60 "curl -s 'https://burghquayregistrationoffice.inis.gov.ie/Website/AMSREG/AMSRegWeb.nsf/(getAppsNear)?openpage&cat=Work&sbcat=All&typ=Renewal' | sed 's/\"/+/g' | tr '{' '\n' | grep time | awk -F+ '{ print \$4; }'"
# TO USE IT WITHOUT WATCH, REMOVE THE BACKSLASH OF \$4 IN AWK COMMAND:
# curl -s 'https://burghquayregistrationoffice.inis.gov.ie/Website/AMSREG/AMSRegWeb.nsf/(getAppsNear)?openpage&cat=Work&sbcat=All&typ=Renewal' | sed 's/\"/+/g' | tr '{' '\n' | grep time | awk -F+ '{ print $4; }'
# Sample output:
@paulera
paulera / color_clock.pde
Created April 19, 2017 11:57
A clock that changes background color according to current time. Hours = hue and seconds (considering minutes) = saturation. Brightness always maximum.
void setup() {
// ---------------------------------------
// screen mode (pick one)
// ---------------------------------------
size (220,130);
surface.setResizable(true);
// -- OR ---------------------------------
// fullScreen();
// ---------------------------------------
@paulera
paulera / userscript_teamwork-to-resolveticket-link.js
Last active May 10, 2017 11:10
Greasemonkey (or TamperMonkey) script to tweak Teamwork.com and turn 4 digit numbers (ticket numbers) into links to Resolve CRM.
@paulera
paulera / js-html-templating.html
Last active September 22, 2022 00:32
Example of javascript templating using {placeholders}. No framework, just pure js.
<html>
<body>
<!-- Adapted from http://codoki.com/2015/09/01/native-javascript-templating/ -->
<!-- Implemented Marcos Correia's suggestion - refer to article comments -->
<ul id="list"></ul>
<script id="my-template" type="x-template">
@paulera
paulera / gorilla.bas
Created July 10, 2017 14:06
Source code for the game GORILLA.BAS from 1991, delivered with MS-DOS operating systems.
' Q B a s i c G o r i l l a s
'
' Copyright (C) IBM Corporation 1991
'
' Your mission is to hit your opponent with the exploding banana
@paulera
paulera / remote-socket-forwarding.sh
Last active July 27, 2017 13:29
Exposes a remote mysql socket locally
#!/bin/bash
# ################################################################
#
# This is a sample script, modify it according to your needs.
# SSH password access won't work, you must have your RSA key
# added to server's authorizedkeys file, or use ssh's -i option.
#
# https://gist.github.com/paulera/582033379327de63bf7f7d82aaf3d3cc
@paulera
paulera / ClipboadToFile.vbs
Created August 17, 2017 07:38
VBScript to save clipboard contents to a text file.
Option Explicit
' Gets clipboard's contents as pure text and saves it
' to the file set in filePath variable.
' author https://github.com/paulera
' see https://gist.github.com/paulera/b9af6f44aa553b6063d928547c26eab9
' File path to save clipboard contents
Dim filePath : filePath = "C:\clipboard.txt"