Skip to content

Instantly share code, notes, and snippets.

View ivanrosolen's full-sized avatar
:octocat:
....

Ivan Rosolen ivanrosolen

:octocat:
....
  • Stone
  • São Paulo, Brasil
View GitHub Profile
@ivanrosolen
ivanrosolen / .zshrc
Last active October 20, 2020 20:45
Numberpad zsh mac
# Fix numeric keypad
# 0 . Enter
bindkey -s "^[Op" "0"
bindkey -s "^[On" "."
bindkey -s "^[OM" "^M"
# 1 2 3
bindkey -s "^[Oq" "1"
bindkey -s "^[Or" "2"
bindkey -s "^[Os" "3"
@ivanrosolen
ivanrosolen / CsvReader.php
Created September 11, 2018 18:37
Ler CSV com PHP
<?php
// tem que ser separado por , e não por ;
$csvArray = array_map('str_getcsv', file('Arquivo.csv'));
// poderia rolar assim, mas não :(
//$csvArray = array_map(['str_getcsv', ';'], file('Arquivo.csv'));
// anonymous
$csvArray = array_map( function ($val) {
@ivanrosolen
ivanrosolen / todo.md
Last active September 26, 2018 20:51
React Pokedex

React Pokedex

Pages

  • Initial
  • List all
  • Search by number/name
  • Show infos on click

components

  • Search
@ivanrosolen
ivanrosolen / sendMessage.php
Created November 2, 2018 02:22
Machine Monitor Telegram Message
<?php
// Create bot
// https://core.telegram.org/bots#6-botfather
//
//
// Get Channel ID - https://api.telegram.org/bot$api_token/getUpdates
// chat": { "id": -123456,
// Telegram
@ivanrosolen
ivanrosolen / named_groups_regex.php
Created November 9, 2018 13:42
Named Capturing Group REGEX
<?php
$regex = "/(?'group1'[0-9]+)_(?'group2'.+)_(?'group3'[0-9A-Z]+).(?'ext'.+)$/";
$files = [
'01_lero_1X.pdf',
'02_lerolero_13.pdf',
'03_1k_KK.pdf'
];
@ivanrosolen
ivanrosolen / check_size.sql
Created December 18, 2018 20:36
How to get the size of mysql tables?
-- All Databases and Tables
SELECT
table_schema AS `Database`,
table_name AS `Table`,
round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB`
FROM
information_schema.TABLES
ORDER BY
(data_length + index_length)
DESC;
@ivanrosolen
ivanrosolen / download_one_gitlab.md
Created March 15, 2019 14:29
Baixar um arquivo do gitlab
@ivanrosolen
ivanrosolen / concurrency.js
Created March 15, 2019 22:16
NodeJS Concurrency
const http = require('http');
const cluster = require('cluster');
if (cluster.isMaster) {
console.info('Starting...');
console.info('Worker master started');
const numCpus = require('os').cpus().length;
@ivanrosolen
ivanrosolen / dump.sql
Last active April 19, 2019 15:42
Dump a specific table or few rows (MySQL)
mysqldump -h host_ip -u user -ppassword database_name > database_dump.sql
mysqldump -h host_ip -u user -ppassword database_name table_name > table_dump.sql
mysqldump -h host_ip -u user -ppassword database_name table_name --where="date_created='2019-04-19'" > rows_dump.sql
Big table, use nohup command &
If user is not root, you may add --lock-tables=false
@ivanrosolen
ivanrosolen / remove.sh
Created April 24, 2019 19:24
Quick remove first line from file
tail -n +2 file.sql > newfile.sql