This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# HAVE A LOOK AT https://gist.github.com/3135855 FIRST ON HOW THIS WORKS | |
# keyring_password.sh [ "name of key" [, "store-this_Password ]] | |
# It either echoes the stored password, or stores a new item | |
if [ ! "$1" ]; then | |
exit 1 | |
fi | |
_PWNAME="$1" # A placeholder name for this password in the keychain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias _sa='sudo apt-get' | |
alias _sai='sudo apt-get install' | |
alias _sar='sudo apt-get remove' | |
alias _sarp='sudo apt-get remove --purge' | |
alias _saa='sudo apt-get autoremove' | |
alias _saap='sudo apt-get autoremove --purge' | |
alias _sau='sudo apt-get update' | |
alias _sag='sudo apt-get upgrade' | |
alias _saug='sudo apt-get update && sudo apt-get upgrade' | |
alias _scaug='sudo apt-get update && sudo apt-get upgrade && sudo apt-get clean' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// deny user login for all non admin users | |
function restrict_access_admin_panel(){ | |
global $current_user; | |
get_currentuserinfo(); | |
// other tips I've read forgets that admin-ajax.php is used | |
// for ajax requests which breaks (almost) all plugins with ajax | |
if ($current_user->user_level < 4 && !defined('DOING_AJAX')) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python -tt | |
# from: http://www.techgaun.com/2012/03/extracting-all-hyperlinks-from-webpages.html | |
import re, urllib2, sys | |
def main(): | |
''' Usage: url_extractor.py "http://example.com/" | |
NOTICE: Intended for root urls; ie no */file or /subfolder/* | |
In that case you need to edit this file first |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// This replaces the included jQuery file from WP and uses the cdn hosted version from Google | |
// PLUS removes the ?ver=1.x.x from the url, making it more likely to be cached already | |
function rssv_scripts() { | |
global $wp_scripts; | |
if ( !is_a( $wp_scripts, 'WP_Scripts' ) ) | |
return; | |
$wp_scripts->registered[jquery]->ver = null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Selects all matching elements who's first letter is 'x' | |
// Ignores any leading whitespace. | |
// | |
// Usage: | |
// <p>Hello!</p> | |
// <p>Honestly...</p> | |
// <p>Goodbye!</p> | |
// | |
// var allHes = $("p:startswith('h')"); // == [ "<p>Hello!</p>", "<p>Honestly...</p>" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# When you edit your tools, "Manage external tools", wrap your code in brackets and send it to /dev/null | |
#!/bin/bash | |
{ | |
#some code | |
} &>/dev/null | |
# this way you can suppress warnings otherwise sent to the console. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# usage in bash/sh | |
# $ NODERESULT=`node worker.js $(echo -n "Variable / file content" | base64 -w 0)` | |
# encode variable in bash and decode it in node using atob package | |
# , and finally decode the result in bash. | |
# $ NODERESULT=$(echo -n "$NODERESULT" | base64 --decode -w 0) | |
# This makes every argument given to node foolproof. | |
if ( !process.argv[2] ) { | |
throw new Error( "No valid argument given!" ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IMAGE=/path/to/image | |
if [[ "$(file -b $IMAGE)" =~ ^JPEG ]]; then | |
# EX: JPEG image data, JFIF standard 1.01 | |
echo "Valid JPEG image" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# paste into .bashrc or your aliases file | |
# Usage: | |
# $> downloadmanager "http://domain.com/file1.zip" "http://domain.com/file2.zip" "http://domain.com/file3.zip" | |
downloadmanager () { | |
if [ ! "$1" ] || [ ! "$@" ]; then | |
exit 1 | |
fi | |
OLDDIR="$PWD" | |
DCOUNT=1 |