Skip to content

Instantly share code, notes, and snippets.

View paulera's full-sized avatar

Paulo Amaral paulera

View GitHub Profile
@paulera
paulera / Auto close plink.exe tunnel after timer
Created February 19, 2016 17:49
This command opens a tunnel using plink and automatically closes it after seconds specified in secs=$((<time in seconds>));
@paulera
paulera / Melhorar a performance de programas usando RAMDISK
Last active March 7, 2016 10:32
Truque pra melhorar a performance de programas, alocando pastas inteiras na memória RAM e deixando um link simbólico no lugar. Essas instruções são para windows mas é possível fazer no linux também. Eu uso para o Eclipse mas serve pra qualquer programa.
É mãozada forte, mantenha backup de todos os arquivos envolvidos! Sério, chorei e quebrei meu Eclipse várias vezes
até aprender a fazer isso que nem gente. Agora virou rotina.
Basicamente eu coloco os arquivos mais acessados pelo programa em uma uma unidade virtual montada na memória RAM
(ao invés de usar parte do HD), que chega a uma transferência de mais de 2GB/s. O nome disso é "ramdisk" pra quem
quiser buscar no Google. Aqui tem um PDF explicando como fazer, com um benchmark comparando a performance:
http://paulera.insomnia247.nl/docs/ramdisk.pdf - Obviamente, estamos abrindo mão de um teco da memória, então é bom
ter de sobra.
TL;DR: Eu uso um script para isso, basta rodar um prompt como admin, e executar a BAT passando
@paulera
paulera / devrant-darkside-userscript.js
Last active November 4, 2016 12:46
Dark theme for devRant. Still a work in progress. Requires TamperMonkey / GreaseMonkey
// ==UserScript==
// @name devRant dark theme listing mode
// @namespace cosmicspace
// @version 0.1
// @description Make devRant listing black. Because white bg sucks.
// @author https://www.devrant.io/users/paulera
// @match www.devrant.io/*
// @grant GM_addStyle
// ==/UserScript==
@paulera
paulera / data-auto-max-heigh.js
Created December 11, 2016 17:41
Reduce a text font-size until div fits maximum height defined in pixels.
/**
* Decrease font-size to limit div's height.
* Requires jQuery and must be called with setTimeout (as below)
* to wait for elements to be rendered before sdjust them.
*
* Example:
* <div data-auto-max-height="50">The font-size of this text will decrease until the div has 50px in height</div>
*/
$(document).ready(function() {
@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 / card.pde
Last active March 8, 2017 03:35
Card idea for teaching processing to kids. The contents of the function "draw2" can be written in the back of the card as they are, no modification needed.
drawGrid = true;
void drawOnce() {
fill(0);
PFont myFont = createFont("Impact", 35);
textFont(myFont);
textAlign(CENTER);
text("TRUCK DELIVERED BOMB", 10, 30, 380, 50);
@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();
// ---------------------------------------