Skip to content

Instantly share code, notes, and snippets.

View matheus-santos's full-sized avatar
🏠
Working from home

Matheus Santos matheus-santos

🏠
Working from home
View GitHub Profile
@matheus-santos
matheus-santos / select_lines_config
Created February 11, 2015 12:55
Select lines with keyboard Sublime Text 2
/* On Key Bindings - Default/User */
{ "keys": ["shift+alt+up"], "command": "select_lines", "args": {"forward": false} },
{ "keys": ["shift+alt+down"], "command": "select_lines", "args": {"forward": true} }
@matheus-santos
matheus-santos / find
Last active August 29, 2015 14:15
Searching files on Unix terminal
# find $FOLDER -type $DOCUMENT_TYPE -name $ARG
find ~/ -type f -name "wally.txt"
@matheus-santos
matheus-santos / undo
Last active August 29, 2015 14:15
Undo modified file git
# Before commit
git checkout -- $FILE_NAME
@matheus-santos
matheus-santos / mvn-run
Created March 24, 2015 18:48
Building and running assembled Maven Project
# On the Maven project folder
# Compiling current mvn project and assembling it
# into a single .jar file. That way we can execute the
# project without running into 'class not found' errors.
# Ref: http://stackoverflow.com/a/574650/3147039
mvn clean compile assembly:single
# Running java program (generated snapshot from Maven project)
java -jar target/App-0.0.1-SNAPSHOT-jar-with-dependencies.jar
@matheus-santos
matheus-santos / cheat_sheet_socketio
Last active May 1, 2019 19:23
SocketIO cheat sheet to emit messages through sockets
// SocketIO cheat sheet
// SocketIO is a library that makes websockets communications easier.
// Page: http://socket.io/
// ref: http://stackoverflow.com/a/10099325
// send to current request socket client
socket.emit('message', "this is a test");
// sending to all clients, include sender
io.sockets.emit('message', "this is a test");
@matheus-santos
matheus-santos / kill_task
Created April 24, 2015 14:35
Kill mysql-workbench task on Linux
# Killing task 'mysql-workbench'
kill $(ps -A | awk '/[m]ysql-workbench/ {print $1}')
@matheus-santos
matheus-santos / find_xxl_files
Created June 17, 2015 16:23
Searching large files
# Looking for large files
sudo find / -type f -size +1G -exec ls -lh {} \;
@matheus-santos
matheus-santos / delete_by_size
Created July 14, 2015 17:08
Delete all files given its size
find -name "*.txt" -size -2k -delete
@matheus-santos
matheus-santos / tar.gz.cheat_sheet
Last active September 24, 2015 17:14
Managing tar files
tar stores relative paths by default. GNU tar even says so if you try to store an absolute path:
# Create .tar file (with gzip)
tar -zcvf foo.tar /home/foo
# Have a look at what's in the tar file:
tar -tvf foo.tar
# Extracting file from tar file
tar -xvf foo.tar home/foo/bar # Note: no leading slash
@matheus-santos
matheus-santos / kill_them_all.sh
Created September 10, 2015 15:19
Script that kill slow processes running into Mysql DB
#!/bin/sh
# Author: Matheus Cesário <[email protected]>
# Description: Killing all slow queries from bd
# Example: sh kill_them_all.sh -s 100
# Variables
SECONDS=0 # Seconds
USER="" # DB user
PASSWORD="" # DB password
HOST="" # DB host