Skip to content
View regexMultiMatch.js
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)
View extract-table-names.js
const fs = require('fs');
fs.readFile(process.argv[2], 'utf8', (err,data) =>{
if (err) {
return console.log(err);
}
fs.writeFile(process.argv[3]+'.md', extractTableNames(data), err => {
if(err) {
console.log(err);
View add-remote-rsa-key.sh
#!/bin/sh
cat ~/.ssh/id_rsa.pub | (ssh user@host "cat >> ~/.ssh/authorized_keys")
View windows-ubuntu-rsa-ssh
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:
View setup-git-login-pass-cache.sh
#!/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'
View get-absolute-path.sh
#!/bin/bash
# REFERENCE: http://stackoverflow.com/a/1638397/1260526
# Absolute path to this script, e.g. /home/user/bin/foo.sh
SCRIPT=$(readlink -f "$0")
# Absolute path this script is in, thus /home/user/bin
SCRIPTPATH=$(dirname "$SCRIPT")
echo $SCRIPTPATH
View ubuntu-14-04-environment-setup.sh
wget https://github.com/leodutra/shell-scripts/archive/master.zip
unzip master.zip
rm -f master.zip
cd shell-scripts-master/environment/ubuntu-14-04/
bash environment-setup.sh
rm -Rf ./shell-scripts-master
View manual-hd-partiton-scheme-ubuntu-14
(MiB) Sector Type FS
------------------------------
8192 (swap) primary ext4
2048 /boot primary ext4
262144 / primary ext4
* /home logical ext4
View municipios-brasileiros-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á
View municipios-brasileiros-2016-01-05.sql
CREATE TABLE IF NOT EXISTS `pais` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`nome` varchar(60) DEFAULT NULL,
`sigla` varchar(10) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
INSERT INTO `pais` (`id`, `nome`, `sigla`) VALUES (1, 'Brasil', 'BR');
Something went wrong with that request. Please try again.