Skip to content

Instantly share code, notes, and snippets.

View teledirigido's full-sized avatar

Miguel Garrido teledirigido

View GitHub Profile
@teledirigido
teledirigido / newsite.sh
Created August 2, 2014 12:25
Add new website via Bash script. Working with Ubuntu server.
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "You must be a root user" 2>&1
exit 1
fi
echo "<VirtualHost *:80>
ServerAdmin admin@example.co.nz
ServerName $1
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/query.php
*/
$args = array(
@teledirigido
teledirigido / git-pre-commit-mysql-dump.sh
Last active August 29, 2015 14:09
MySQL dump on pre-commit
#!/bin/bash
# Pre-commit hook to make a mysql dump right before committing and add it to the commit.
#
# Change the following values to suit your local setup.
# Add this file on your .git/hooks/ and name it as 'pre-commit'
#
# The name of a database user with read access to the database.
DBUSER=[dbuser]
@teledirigido
teledirigido / git-post-merge-mysql-update.sh
Created November 14, 2014 00:33
MySQL backup on post-merge
#!/bin/bash
# Post-merge hook to add a mysql db when post-merge occurs.
#
## Change the following values to suit your local setup.
# The name of a database user with read access to the database.
DBUSER=[dbuser]
# The password associated with the above user. Leave commented if none.
DBPASS=[dbpass]
@teledirigido
teledirigido / div_is_on_top.js
Last active August 29, 2015 14:10
Check when divs have reached the top of the window
var custom_menu = {
handle_colors: function(){
// by default this works with $(window).on('load resize scroll')
$('.scroller').on('load resize scroll', function(){
var index_item = custom_menu._get_index(),
class_item = $('.wrapper-milkguard:eq('+index_item+')').data('menu-color')
@teledirigido
teledirigido / cs_sidebar.js
Last active August 29, 2015 14:14
Sticky sidebar.js
/*
* This plugin requires jquery and modernizr :)
* The goal of this plugin is to stick the sidebar on top and bottom when you scroll
* Websites examples:
* http://www.carncot.school.nz/
*
* Example:
*
* var sidebar = new cs_sidebar({
* id: '#main-sidebar',
@teledirigido
teledirigido / .htaccess
Created March 18, 2015 21:51
Compress and Cache files
ExpiresActive On
ExpiresDefault A0
# 1 WEEK - possible to be changed, unlikely
<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
ExpiresDefault A604800
</FilesMatch>
# 3 HOUR - core content, changes quickly
<FilesMatch "\.(txt|xml|js|css)$">
@teledirigido
teledirigido / .bash_profile
Last active August 29, 2015 14:21
Useful alias for your bash_profile
# Open your bashprofile
alias openbash="subl ~/.bash_profile";
# Thanks to jamie@blacksheepdesign.co.nz
alias showFiles="defaults write com.apple.finder AppleShowAllFiles YES; killall Finder /System/Library/CoreServices/Finder.app";
alias hideFiles="defaults write com.apple.finder AppleShowAllFiles NO; killall Finder /System/Library/CoreServices/Finder.app";
@teledirigido
teledirigido / commands.sh
Last active August 29, 2015 14:21
Useful commands on shell
# Find .htaccess and do chmod
sudo find / -type f -name '.htaccess' -exec chmod 604 {} \;
# Find wp-config.php and do chmod
sudo find / -type f -name 'wp-config.php' -exec chmod 644 {} \;
@teledirigido
teledirigido / animation.js
Created May 25, 2015 04:11
Animate element with jQuery
/*
# Usage for your Javascript
$(document).ready(function(){
var animate_squared = new animation({
obj: '#your-tag .item',
});