This file contains hidden or 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
for file in /dir/* | |
do | |
# command | |
done |
This file contains hidden or 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
pushd `dirname $0` > /dev/null | |
SCRIPT_DIR=`pwd` | |
popd > /dev/null |
This file contains hidden or 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 | |
/** | |
* Post-order traversal of the dom starting at given node. Remove any | |
* nodes that have no children and no attributes. Nodes named in the | |
* AMP_Rule_Spec::node_types_to_allow_empty array will not be removed. | |
*/ | |
private function remove_empty_descendants( $node ) { | |
$stack = array(); | |
$next_traversal = 'child'; | |
$nodes_to_remove = array(); |
This file contains hidden or 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
FROM wordpress:4.6.1-php5.6-apache | |
RUN yes | pecl install xdebug \ | |
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \ | |
&& echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini \ | |
&& echo "xdebug.remote_autostart=on" >> /usr/local/etc/php/conf.d/xdebug.ini \ | |
&& echo "xdebug.idekey=bonkers" >> /usr/local/etc/php/conf.d/xdebug.ini |
This file contains hidden or 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
mkdir <repo> | |
cd <repo> | |
git init | |
git remote add -f origin <url> | |
# This creates an empty repository with your remote, and fetches all objects | |
# but doesn't check them out. | |
# Then do: | |
git config core.sparseCheckout true |
This file contains hidden or 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
// Returns black if the given background color is light or white if the given color is dark | |
func textColor(bgColor: UIColor) -> UIColor { | |
var r: CGFloat = 0.0 | |
var g: CGFloat = 0.0 | |
var b: CGFloat = 0.0 | |
var a: CGFloat = 0.0 | |
var brightness: CGFloat = 0.0 | |
bgColor.getRed(&r, green: &g, blue: &b, alpha: &a) |
This file contains hidden or 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
extension UIColor { | |
var rgbComponents:(red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat) { | |
var r:CGFloat = 0 | |
var g:CGFloat = 0 | |
var b:CGFloat = 0 | |
var a:CGFloat = 0 | |
if getRed(&r, green: &g, blue: &b, alpha: &a) { | |
return (r,g,b,a) | |
} | |
return (0,0,0,0) |
This file contains hidden or 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
// Google Forms Slack Notification | |
// Andy Chase <github.com/andychase> | |
// License: CC0 1.0 Universal <creativecommons.org/publicdomain/zero/1.0> | |
// Install 1: This code goes in ( tools > script editor... ) of your google docs form | |
// Install 2: ( resources > current project triggers ) ( [onSubmit], [from Form], [On form submit] ) | |
// Setup 1: Put your slack api url below | |
var POST_URL = "https://hooks.slack.com/services/"; | |
function onSubmit(e) { |
This file contains hidden or 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
find /home/www -type f -print0 | xargs -0 sed -i 's/replace this string/with that string/g' |
This file contains hidden or 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
mkdir repo_name | |
cd repo_name | |
git init | |
git remote add origin [email protected]:username/repo_name.git | |
git config core.sparsecheckout true | |
echo "dir_to_clone/*" >> .git/info/sparse-checkout | |
git pull origin master |