Skip to content

Instantly share code, notes, and snippets.

View fernandofig's full-sized avatar

Fernando Figueiredo fernandofig

  • Campinas, Brazil
View GitHub Profile
@fernandofig
fernandofig / .rc_firewall
Last active December 30, 2015 00:09
DD-WRT Startup script with host blocking (MAC-Address based) during "sleep hours"
#!/bin/sh
sleep 5;
/tmp/ebt_setup.sh
/tmp/fw_setup.sh
sleep 5;
/tmp/check_consist.sh
@fernandofig
fernandofig / DataManipulationUtils.vb
Last active August 12, 2021 05:35
Useful VBA / Excel Macros for Maillisting Normalization
Sub GeraEndereco()
Dim endFinal As String
Dim myRange As Range
Set myRange = Selection
lf = myRange.Row + myRange.Rows.Count - 1
cf = myRange.Column + myRange.Columns.Count - 1
For l = myRange.Row To lf
For c = myRange.Column To cf
@fernandofig
fernandofig / README
Last active August 29, 2015 14:25
See README for description
For Android devices: Script for setting CPU Scaling parameters (governor, min_freq, max_freq)
for all CPU cores.
Doesn't work for all devices - e.g. for my SGS4 the max_freq for additional cores (core != 0)
gets reset to the nominal CPU maximum frequency (cpuinfo_max_freq) when the cpu reawakens from
sleep state. So I'm leaving this here only for educational purposes and future reference for
myself.
This was tested on CyanogenMod 12.1. It should in theory work (as in the script should execute
without errors) on any rooted device with busybox installed.
@fernandofig
fernandofig / terraria-server.sh
Created August 1, 2015 00:33
Init.d script for starting multiple and concurrent Terraria Server instances
#!/bin/bash
### BEGIN INIT INFO
# Provides: terraria_server
# Required-Start: $local_fs $remote_fs $network
# Required-Stop: $local_fs $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# X-Interactive: true
# Short-Description: Start/stop terraria_server
### END INIT INFO
@fernandofig
fernandofig / uninstall-pkg.sh
Last active March 6, 2016 21:12
Quick and dirty script to remove .PKG installs on OSX
#!/bin/bash
SPECIALEXTLIST=(app action caction definition bundle kext prefPane plugin jdk fs framework)
function joinList { local IFS="$1"; shift; echo "$*"; }
function getListWithTerminators {
PROCLIST=()
for EXT in "${SPECIALEXTLIST[@]}"; do
@fernandofig
fernandofig / Model.Context.tt
Last active July 11, 2016 03:18
Useful extensions / helpers + t4 template to add ActiveRecord behavior for Entity Framework objects, and add DbContext persistent context (mainly for web requests)
<#@ template language="C#" debug="false" hostspecific="true"#>
<#@ include file="EF6.Utility.CS.ttinclude"#><#@
output extension=".cs"#><#
const string inputFile = @"PRDataModel.edmx";
var textTransform = DynamicTextTransformation.Create(this);
var code = new CodeGenerationTools(this);
var ef = new MetadataTools(this);
var typeMapper = new TypeMapper(code, ef, textTransform.Errors);
var loader = new EdmMetadataLoader(textTransform.Host, textTransform.Errors);
@fernandofig
fernandofig / pegaAmostra.cmd
Created May 30, 2018 23:13
Referência de uso de geração de pastas / arquivos com timestamp
@ECHO OFF
setlocal
FOR /F "tokens=1-4 delims=/:," %%a in ("%TIME%") do (set MYTIME=%%a%%b%%c%%d)
REM DEPENDENDO DE QUAL O IDIOMA OU COMO ESTIVER CONFIGURADO AS CONFIGURAÇÕES REGIONAIS DO WINDOWS, PODE SER NECESSÁRIO USAR A
REM PRIMEIRA OU SEGUNDA LINHA ABAIXO. COMENTE/DESCOMENTE A QUE FUNCIONAR MELHOR
SET TS=%date:~6,4%%date:~3,2%%date:~0,2%_%MYTIME%
@REM !! ALTERE AS DUAS LINHAS ABAIXO PARA SE ADEQUAR SUAS NECESSIDADES !!
@SET "SEG=PE1"
@SET "EXT=txt"
@REM ******** NAO ALTERE NADA DAQUI PRA BAIXO! ********
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
FOR /R %%G IN (*.%EXT%) DO (
@fernandofig
fernandofig / CommandPrompts.reg
Last active October 19, 2023 22:43
Command Prompts (CMD & Powershell) Context Menu
Windows Registry Editor Version 5.00
[-HKEY_CLASSES_ROOT\Directory\shell\01MenuCmd]
[-HKEY_CLASSES_ROOT\Directory\shell\cmd]
[-HKEY_CLASSES_ROOT\Directory\Background\shell\cmd]
[-HKEY_CLASSES_ROOT\Directory\Background\shell\01MenuCmd]
[-HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuCmd]
[-HKEY_CLASSES_ROOT\Directory\shell\02MenuPowerShell]
[-HKEY_CLASSES_ROOT\Directory\shell\powershellmenu]
@fernandofig
fernandofig / SHA1Util.cs
Last active April 3, 2019 17:42 — forked from jchandra74/SHA1Util.cs
SHA1 Hash for Unicode string
//Forked from kristopherjohnson/SHA1Util.cs gist
using System.Security.Cryptography;
using System.Text;
namespace Snippets
{
public static class SHA1Util
{
/// <summary>
/// Compute hash for string encoded as UTF8, return as base64 encoded string