Skip to content

Instantly share code, notes, and snippets.

View luanlmd's full-sized avatar

Luan Almeida luanlmd

View GitHub Profile
@luanlmd
luanlmd / clearFiles.sh
Last active August 29, 2015 14:06
Remove files if disc is almost full
if [ $(df -P /dev/sda1 | awk '{ gsub("%",""); capacity = $5 }; END { print capacity }') -gt 95 ]
then
find /var/www/html/ -type f | sort -n | head -50 | xargs rm
fi
#!/bin/sh
COUNT=$(ps ax | grep <command> | wc -l)
if [ $COUNT -gt 1 ]; then
exit 0
fi
run <command>
@luanlmd
luanlmd / webm_convert.sh
Created October 10, 2014 19:54
Convert avi files in a folder to webm
#!/bin/sh
COUNT=$(ps ax | grep avconv | wc -l)
if [ $COUNT -gt 1 ]; then
echo "running already"
exit 0
fi
i=1
while [ $i -le 3 ]; do
@luanlmd
luanlmd / sublime-refresh-browser.sh
Created February 6, 2015 01:32
Refresh browser from sublime text
#!/bin/sh
# keybind: { "keys": ["ctrl+d"], "command": "exec", "args": { "cmd": ["/home/luan/scripts/sublime-refresh-browser.sh"]} }
xdotool search --onlyvisible --class "chromium" windowfocus key ctrl+r
xdotool search --onlyvisible --class "sublime-text" windowfocus
@luanlmd
luanlmd / benchdrive.sh
Last active November 9, 2016 17:55
Test your drive speed
#!/bin/bash
printf "\nBlowing up your hard drive... please wait.\n"
printf "\nWriting:\n"
dd if=/dev/zero of=testfile bs=1024k count=512
printf "\nReading:\n"
dd if=testfile of=/dev/null
@luanlmd
luanlmd / git_remove_files.sh
Last active December 16, 2015 20:11
git remove old commit files
# change the 'filename.ext' part and run
git filter-branch -f --index-filter "git rm -r --cached --ignore-unmatch filename.ext" --tag-name-filter cat -- --all
@luanlmd
luanlmd / teamspeak.service
Created April 27, 2016 23:13
Ubuntu 16.04 Systemd TeamSpeak service file
[Unit]
Description=Teamspeak Service
After=network.target
[Service]
WorkingDirectory=/opt/teamspeak3-server_linux_amd64
ExecStart=/opt/teamspeak3-server_linux_amd64/ts3server_minimal_runscript.sh
ExecStop=/opt/teamspeak3-server_linux_amd64/ts3server_startscript.sh stop
ExecReload=/opt/teamspeak3-server_linux_amd64/ts3server_startscript.sh restart
PIDFile=/opt/teamspeak3-server_linux_amd64/ts3server.pid
@luanlmd
luanlmd / Vagrantfile
Created July 6, 2016 19:22
Vagrantfile LAMP
$script = <<SCRIPT
apt-get update
apt-get install sudo
gpasswd -a vagrant sudo
echo "mysql-server mysql-server/root_password password password" | debconf-set-selections
echo "mysql-server mysql-server/root_password_again password password" | debconf-set-selections
apt-get -y install mysql-server
sed -i "s/.*bind-address.*/bind-address = 0.0.0.0/" /etc/mysql/my.cnf
@luanlmd
luanlmd / vuejs-todo.html
Created July 28, 2017 19:50
VueJS simplest todo ever
<html>
<head>
<title>VueJS simplest todo ever</title>
<script src="https://unpkg.com/vue"></script>
</head>
<body>
<div id="app">
<ul>
@luanlmd
luanlmd / backtrace.php
Last active November 1, 2017 20:25
just a test
<?php
function log_exec()
{
$stack = json_encode(debug_backtrace(), JSON_PRETTY_PRINT) . "\n\n";
file_put_contents('/tmp/log.txt', $stack, FILE_APPEND);
}
function middle_func()
{