Skip to content

Instantly share code, notes, and snippets.

View leodutra's full-sized avatar
🦙
Llama and other LLMs

Leo Dutra leodutra

🦙
Llama and other LLMs
View GitHub Profile
@leodutra
leodutra / municipios-brasileiros-2016-01-05.csv
Last active January 25, 2016 19:59
Municípios brasileiros extraídos da Wikipedia e do IBGE 2016-01-05 CSV
UF Municipio Desambiguação
GO Abadia de Goiás
MG Abadia dos Dourados
GO Abadiânia
MG Abaeté Abaeté (Minas Gerais)
PA Abaetetuba
CE Abaiara
BA Abaíra
BA Abaré
PR Abatiá
@leodutra
leodutra / npm-globals
Last active January 29, 2016 04:01
NPM global tools and packages for easy development
npm i -g nvm express express-generator tape mocha grunt gulp swagger pm2 cheerio istanbul bower nodemon jade
npm cache clean -g
@leodutra
leodutra / manual-hd-partiton-scheme-ubuntu-14
Created January 29, 2016 06:30
Manual partitioning scheme - 1TB 7200 HD + 8Gb RAM + Ubuntu 14.04
(MiB) Sector Type FS
------------------------------
8192 (swap) primary ext4
2048 /boot primary ext4
262144 / primary ext4
* /home logical ext4
@leodutra
leodutra / windows-ubuntu-rsa-ssh
Created February 16, 2016 04:13
SSH RSA generation / usage on Windows Git tools SSH client + Ubuntu OpenSSH
http://serverfault.com/questions/224810/is-there-an-equivalent-to-ssh-copy-id-for-windows
These answers didn't help me out. I really didn't need any crazy scripts. I had created a public key on my client machine in git bash and was trying to copy it to a VPS.
After creating your public key, the key should be stored as "(whatever folder you started in)/.ssh/id_rsa.pub"
So use this command:
cat ~/.ssh/id_rsa.pub | ssh user@123.45.67.89 "cat >> ~/.ssh/authorized_keys" where user is your username (sometimes "root", or whatever you may have set up), and replace 123.45.67.89 with your machine / host / VPS's IP address.
If the directory .ssh is not yet created on the host machine, use this small variation:
@leodutra
leodutra / add-remote-rsa-key.sh
Created February 17, 2016 18:39
Add RSA key remote SSH service authorized keys
#!/bin/sh
cat ~/.ssh/id_rsa.pub | (ssh user@host "cat >> ~/.ssh/authorized_keys")
@leodutra
leodutra / decimal to binary algorithm
Last active April 21, 2016 19:08
Decimal to binary algorithm
number = positive integer ;
bitstring = ""
while (number > 0 )
{
bit = number mod 2 ;
quotient = number div 2 ; // or "n * 0.5" or "n >>> 1" (verify precision for large ints)
put bit to the left of any previous bits in the bitstring;
number = quotient ;
}
@leodutra
leodutra / setup-git-login-pass-cache.sh
Last active April 22, 2016 20:03
Setup Git login, e-mail and password cache | sudo wget -q -O - https://gist.github.com/leodutra/ad82f4d9e86083b5901f/raw | sh -x -
#!/bin/sh
git config --global credential.helper 'cache --timeout=3600'
git config --global user.name "Leo Dutra"
git config --global user.email "leodutra.br@gmail.com"
echo 'git has been set for leodutra.br@gmail.com'
@leodutra
leodutra / highlight-and-filter.css
Last active April 26, 2016 03:27
Filter elements and Highlight text ( find , search , string )
.js-filtered-highlight {
color: yellow;
}
@leodutra
leodutra / regexMultiMatch.js
Last active June 30, 2016 06:49
Simple multiple Regular Expresion (Regex) matches.
function regexMultiMatch(str, regex, fn) {
// clone for no regex.lastIndex problems
var cloneRegExp = new RegExp(regex.source, regex.flags ||
(regex.global ? 'g' : '') + (regex.ignoreCase ? 'i' : '') + (regex.multiline ? 'm' : ''))
fn.apply(null, regex.exec(str))
if (regex.global) {
var match
while((match = regex.exec(str))) fn.apply(null, match)
@leodutra
leodutra / find-package-json.js
Created July 4, 2016 18:33
Find the closest package.json file, starting at process.cwd (by default) and working up to root.
/**
* Find the closest package.json file, starting at process.cwd (by default),
* and working up to root.
*
* @param {string} [startDir=process.cwd()] Starting directory
* @returns {string} Absolute path to closest package.json file
*/
function findPackageJson(startDir) {
var dir = path.resolve(startDir || process.cwd());