Skip to content

Instantly share code, notes, and snippets.

@jesusgoku
jesusgoku / find_exclude_directories.sh
Created March 10, 2015 19:50
Exclude directories with find command
# Use the prune switch, for example if you want to exclude the misc
# directory just add a -path ./misc -prune -o to your find command:
find . -path ./misc -prune -o -name '*.txt' -print
# Here is an example with multiple directories:
find . -type d \( -path dir1 -o -path dir2 -o -path dir3 \) -prune -o -print
# Here we exclude dir1, dir2 and dir3, since in find expressions it is an action,
# that acts on the criteria -path dir1 -o -path dir2 -o -path dir3
# (if dir1 or dir2 or dir3), ANDed with type -d. Further action is -o print, just print.
@jesusgoku
jesusgoku / change_wallpaper.bat
Created March 11, 2015 14:40
Change wallpaper from command line on Windows
@echo off
reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v Wallpaper /t REG_SZ /d %1 /f
rundll32.exe user32.dll,UpdatePerUserSystemParameters
@jesusgoku
jesusgoku / httpd-vhosts.conf
Created March 11, 2015 14:44
Example to config a Virtual Host for Symfony2 project
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot "C:\xampp\htdocs\site"
ServerName site.com
ServerAlias www.site.com
DirectoryIndex app.php index.php index.html
<Directory "C:\xampp\htdocs\site">
Options Indexes FollowSymLinks
Order allow,deny
Allow from all
@jesusgoku
jesusgoku / create_local_tracking_branch.sh
Created March 12, 2015 15:14
Create a local tracking branch
git checkout -b experimental origin/experimental
@jesusgoku
jesusgoku / rename_branch_locally_and_remotely.sh
Created March 17, 2015 11:54
Rename branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@jesusgoku
jesusgoku / add_script.js
Created March 24, 2015 17:32
Added JavaScript and CSS files to page
function addScript(url) {
var head, script;
head = document.querySelector('head');
script = document.createElement('script');
script.type = 'text/javascript';
script.src = url; head.appendChild(script);
};
function addStylesheet(url) {
var head, link;
@jesusgoku
jesusgoku / html_decode.js
Created March 25, 2015 14:19
Unescape HTML from Javascript
(function (document) {
var Utility = function(){};
utility.prototype.htmlDecode = function (html) {
var e = document.createElement('div');
e.innerHTML = html;
return 0 < e.nodeChilds.length ? e.nodeChilds[0].nodeValue : null;
};
@jesusgoku
jesusgoku / mysql_create_db_and_user.sh
Last active August 17, 2020 06:22
Create a new database and a user and password to MySQL
#!/usr/bin/env bash
if [ $# -lt 3 ]; then
echo "Error, bad command call"
echo "Example:"
echo "command.sh dbname dbuser dbpass"
exit
fi
dbhost='localhost'
@jesusgoku
jesusgoku / kill_process_on_cmd.bat
Created April 7, 2015 14:25
Kill process on CMD
REM Find process to kill
tasklist /FO TABLE /FI "status eq running"
REM Kill process by NAME
taskkill /IM notepad.exe
REM Kill process by PID
taskkill /PID 409
REM Kill process and secondary process
@jesusgoku
jesusgoku / manage_vpn.bat
Created April 7, 2015 14:50
Manage VPN connection from CMD
REM create rasphone.pbk on C:\Windows\System32\ras
REM For connect
rasdial "Connection Name" username [password|*]
REM For disconnect
rasdial "Connection Name" /DISCONNECT