Skip to content

Instantly share code, notes, and snippets.

View paulera's full-sized avatar

Paulo Amaral paulera

View GitHub Profile
@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 / 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 / scriprocrastinator.md
Last active November 16, 2020 11:42
Pretend your terminal is doing techy things

Fake process script

Simulates a build/configuration/installation-like process, using a random message with a nice fake progress, with percentage, random total and variable pace. The command does it as many times and as fast as you set in 2 first variables (maxsteps and pace). Goes really well with a cup of coffee! ;)

  • maxsteps = number of steps to run until "finish".
  • pace = step increment speed. Lower numbers are faster. 500 works well.
  • Arrays a, b and c = word lists. change them as you like, words separated by space.

Minified version (for quick procrastination)

@paulera
paulera / Chapter24_PinkFloyd.java
Last active March 20, 2018 11:44
This is the Java implementation of Pink Floyd's song "Chapter 24"
/* This is the Java implementation of the song
Chapter 24, by Pink Floyd.
Album: The Piper at the Gates of Dawn
Year: 1967
References:
https://en.wikipedia.org/wiki/Chapter_24
https://www.youtube.com/watch?v=CqMBQptI7Nk
It expects that some external object call
@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 / fn-toggle.scpt
Last active April 19, 2021 19:58
Script to toggle the FN Lock state in MacOS.
# toggle-fn.scpt
#
# This AppleScript toggles the FN key state.
#
# To assign a keyboard shortcut (long story short):
# Export this AppleScript to an app (a service to just run the script won't have accessibility privileges)
# ----> In the script editor, go to File -> Export, change format to "Application" and save. It will create a .app file.
# When you try to run for the first time, it will ask for access to Accessibility control. Allow it.
# Create a service in Automator to open the app.
# Create a keyboard shortcut to run the service created in Automator.
@paulera
paulera / url_regex_seo_funnel.md
Last active November 16, 2020 11:14
How to write a regex to match and validate URL params, in no specific order.

URL Regex for SEO funnel

Here you will find a brief explanation of how to write a regex to match parameters in a URL, without a specific order.

For use in SEO to identify what users are doing and where are they going.

Filtering by URL parameters

One param with expected value

@paulera
paulera / queryWithProperTypes.php
Created February 24, 2017 16:55
Code Igniter db engine return datasets with all values as strings. This function allows a controller to run a query and return an array of arrays with the correct object types. One might want to tweak it to support bindings.
<?php
class MY_Model extends CI_Model {
/*
... you might have some logic of your own ...
*/
/**
@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);