<?php
/**
* Bootstrap auto clearfix from inside loops.
* Put this function at the start of the loop before other bootstrap cols are called.
*
* @param int $i The count from within the loop where the function is called. Starting with 0.
* @param array $args ['xs'=> 12, 'sm' => 6, 'md' => 4, 'lg' => 3]
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 | |
use RecursiveDirectoryIterator; | |
use RecursiveIteratorIterator; | |
use SplFileInfo; | |
# http://stackoverflow.com/a/3352564/283851 | |
/** | |
* Recursively delete a directory and all of it's contents - e.g.the equivalent of `rm -r` on the command-line. |
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
$file = 'http://www.example.com/path/to/file.ext'; | |
$headers = array_change_key_case(get_headers($file, TRUE)); | |
$filesize = $headers['content-length'][1]; | |
if ( $headers[0] != 'HTTP/1.1 404 Not Found' ) { | |
header('Content-Description: File Transfer'); | |
header('Content-Type: application/octet-stream'); | |
header('Content-Disposition: attachment; filename='.basename($file)); |
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
location ~* ^/remote-files/(http[s]*://)(.*?)/(.*) { | |
# Do not allow people to mess with this location directly | |
# Only internal redirects are allowed | |
internal; | |
# nginx has to be able to resolve the remote URLs | |
resolver 8.8.8.8; | |
# Location-specific logging | |
#access_log /usr/local/etc/nginx/logs/internal_redirect.access.log main; |
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 | |
/* | |
* Usage for a custom post type named 'movies': | |
* unregister_post_type( 'movies' ); | |
* | |
* Usage for the built in 'post' post type: | |
* unregister_post_type( 'post', 'edit.php' ); | |
*/ | |
function unregister_post_type( $post_type, $slug = '' ){ |
#launchd
Usage
I have a bash script called foo.sh
that takes one command line argument, bar
. I want it to run every 60
seconds and load at startup.
- an XML
plist
is Apple Property List com.mydomain.foo.plist
Name of launchd plist file should be a reverse fqdn, like (this may not be required, but convention)com.mydomain.foo.plist
lives in$HOME/Library/LaunchAgents
and is ran as that user.com.mydomain.foo.plist
can also live/Library/LaunchDaemons
or/Library/LaunchAgents
, have requirements, ran asroot
- Load
plist
withlaunchctl load com.mydomain.foo.plist
- Unload
plist
withlauchctl unload com.mydomain.foo.plist
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
var elements = document.querySelectorAll("div"), | |
callback = (el) => { console.log(el); }; | |
// Spread operator | |
[...elements].forEach(callback); | |
// Array.from() | |
Array.from(elements).forEach(callback); | |
// for...of statement |
I've been using a lot of Ansible lately and while almost everything has been great, finding a clean way to implement ansible-vault wasn't immediately apparent.
What I decided on was the following: put your secret information into a vars
file, reference that vars
file from your task
, and encrypt the whole vars
file using ansible-vault encrypt
.
Let's use an example: You're writing an Ansible role and want to encrypt the spoiler for the movie Aliens.
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 namespace App\Providers; | |
use Illuminate\Support\ServiceProvider; | |
/** | |
* If the incoming request is an OPTIONS request | |
* we will register a handler for the requested route | |
*/ | |
class CatchAllOptionsRequestsProvider extends ServiceProvider { |
OlderNewer