Skip to content

Instantly share code, notes, and snippets.

@maztch
maztch / backupdb.sh
Created November 16, 2016 12:51
database backup script
#!/bin/bash
# this script makes a database backup and delete files older than 15 days
# to make script execuable use 'chmod +x backupdb.sh'
# change username, password and database for yours and modify your path if needed
mysqldump -u [username] -p[password] [database_name] > /root/backups/db_backup_`date +"%Y%m%d%H%M%S"`.sql
# change '-mtime +15' to keep more or less days (and path if needed)
find /root/backups/* -mtime +15 -exec rm {} \;
@maztch
maztch / iterm2.md
Created November 4, 2016 08:31
iterm2 cheatsheet

Tabs and Windows

Function Shortcut
Previous Tab + Left Arrow
Next Tab + Right Arrow
Go to Tab + Number
Go to Window + Option + Number
Go to Split Pane by Direction + Option + Arrow
Go to Split Pane by Order of Use + ] , + [
@maztch
maztch / light-css.txt
Created October 7, 2016 09:22
ligth-css
<script>
window.addEventListener('devicelight', function(e) {
var lux = e.value;
if (lux < 50) { // luz tenue
document.body.className = 'tenue';
}
if (lux >= 50 && lux <= 1500) { //luz normal
document.body.className = 'normal';
}
@maztch
maztch / sage-gulpfile.js
Last active July 1, 2016 18:29
Gulpfile and sitemap for UnCSS + Gulp + Sage
// ## Globals
var argv = require('minimist')(process.argv.slice(2));
var autoprefixer = require('gulp-autoprefixer');
var browserSync = require('browser-sync').create();
var changed = require('gulp-changed');
var concat = require('gulp-concat');
var flatten = require('gulp-flatten');
var gulp = require('gulp');
var gulpif = require('gulp-if');
var imagemin = require('gulp-imagemin');
@maztch
maztch / git-promt
Last active June 10, 2016 21:10
git branch in promt
# Git branch in prompt.
# from http://mfitzp.io/article/add-git-branch-name-to-terminal-prompt-mac/
# add to ~/.bash_profile
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u@\h \W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ "
@maztch
maztch / sublime-alias.md
Created June 8, 2016 14:32
call sublime from console

Make an alias to sublime bin subl. Edit file

~/.bash_profile

add

alias sublime="'/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl'"

restart bash if needed

@maztch
maztch / bitbucket-webhook.php
Last active September 7, 2021 00:49
A simple php script for deploy using bitbucket webhook
<?php
//edit with your data
$repo_dir = '~/repository.git';
$web_root_dir = '~/project';
$post_script = '~/project/scripts/post_deploy.sh';
$onbranch = 'master';
// A simple php script for deploy using bitbucket webhook
// Remember to use the correct user:group permisions and ssh keys for apache user!!
// Dirs used here must exists on server and have owner permisions to www-data
@maztch
maztch / reaplace space file names
Created March 14, 2016 18:55
Replace spaces for undescore in file names
$ for f in *\ *; do mv "$f" "${f// /_}"; done
@maztch
maztch / remove_dockers.sh
Last active December 10, 2015 18:35
Docker: Remove all images and containers
#!/bin/bash
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
@maztch
maztch / .htaccess
Created August 18, 2015 18:10
htaccess for angular html5
Options +FollowSymLinks
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !index
RewriteRule (.*) index.html [L]
</ifModule>