Skip to content

Instantly share code, notes, and snippets.

View fideloper's full-sized avatar
🏠
Working from home

Chris Fidao fideloper

🏠
Working from home
View GitHub Profile
@fideloper
fideloper / .htaccess
Created April 27, 2012 14:50
htaccess to display markdown only if file exists
#Turn on Rewrite
RewriteEngine On
#Check if requested file ends in .md or .markdown
RewriteCond $1 \.(md|markdown)$ [NC]
#Check if file exists
RewriteCond %{REQUEST_FILENAME} -f
#Rewrite so $_GET['file'] is available to PHP code
@fideloper
fideloper / pubsub.js
Created May 3, 2012 19:39
PubSub Example
/*
See it in action: http://jsbin.com/iyinux/edit#javascript,html,live
Also Fun: http://jsbin.com/oyanih/7/edit#javascript,html,live
Better Fun: http://jsbin.com/uhakaw/34/edit#javascript,html,live
*/
/*
EXAMPLE USE OF JAVASCRIPT PUBSUB -
https://github.com/mroderick/PubSubJS
*************************************************************/
@fideloper
fideloper / mysql.backup-alt.sh
Last active October 4, 2015 13:58
Bash Shell for backing up database and copying it to remote location
#!/bin/bash
# THIS VERSION WILL ASK YOU FOR THE DATABASE NAME AND WHERE TO SAVE IT LOCALLY
function show_usage {
echo "Usage: $0 database-name save-directory"
exit 1
}
#Need two parameters
@fideloper
fideloper / no_more_msm.php
Created May 10, 2012 13:36 — forked from amacneil/no_more_msm.php
Extract a single ExpressionEngine site from a MSM install
<?php
/*
* Instructions:
* First add your database connection details below.
* Then either upload this script to your server and visit the page,
* or run it using the command line: php no_more_msm.php
*/
// database connection details
<?php
function _get_plugin_info($filename = '')
{
if ( ! $filename)
{
return FALSE;
}
$path = PATH_PI.'pi.'.$filename.'.php';
@fideloper
fideloper / bookmarket.js
Created May 15, 2012 21:02
Bookmarklet Skeleton JS
(function() {
var Namespace = function() {
//Private
_init = function(jq) {
if(!jq) {
_getScript('http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js', _run);
return;
}
_run();
@fideloper
fideloper / h.sh
Created June 16, 2012 15:51
Shortcut for searching bash history using grep
#! /bin/bash
function show_usage {
cat <<- _EOF_
Search Bash History using Grep
Examples:
$ h ssh
$ h 'ssh user@'
@fideloper
fideloper / find.sh
Created September 12, 2012 15:20
Find 'print_r' in php files, with file name and line number
#Reference: http://stackoverflow.com/questions/7600313/find-command-that-returns-line-number-of-the-string
find . -name '*.php' -print | xargs grep -Hn 'print_r'
@fideloper
fideloper / cleanmac.sh
Created September 24, 2012 18:33
Clean mac files from linux
#!/bin/bash
function show_usage {
echo "Use to clean .DS_Store and ._* files which macintosh loves to add to your file system."
echo "This works recursively"
echo "Usage: $ cleanmac /path/of/dir"
echo "Defaults to current directory '.' "
exit 1
}
@fideloper
fideloper / MongoDB Backup Script
Created September 28, 2012 21:35 — forked from wahyusumartha/MongoDB Backup Script
MongoDB Backup Script
#!/bin/bash
#!/usr/bin/env ruby
#########################################
# Define source and destinations
MONGO_DBS=""
BACKUP_TMP=~/tmp
BACKUP_DEST=~/backups
MONGODUMP_BIN=/Users/wahyusumartha/Documents/mongodb-db/bin/mongodump
TAR_BIN=/usr/bin/tar