Skip to content

Instantly share code, notes, and snippets.

View apisandipas's full-sized avatar

Bryan Paronto apisandipas

View GitHub Profile
@apisandipas
apisandipas / functional_utils.js
Created June 6, 2014 20:10
Functional-style Javascript functions
var __slice = Array.prototype.slice;
function getWith(attr) {
return function (object) { return object[attr]; };
}
function mapWith(fn) {
return function (list) {
return Array.prototype.map.call(list, fn);
};
@apisandipas
apisandipas / wp-multisite-nginx.conf
Created June 10, 2014 19:45
NGINX / WordPress Multisite
map $uri $blogname{
~^(?P<blogpath>/[^/]+/)files/(.*) $blogpath ;
}
map $blogname $blogid{
default -999;
#Ref: http://wordpress.org/extend/plugins/nginx-helper/
#include /var/www/wordpress/wp-content/plugins/nginx-helper/map.conf ;
}
@apisandipas
apisandipas / wp.sh
Last active August 29, 2015 14:03
Bash script to install WordPress latest, set up wp-config.php and then remove itself, like a responsible citizen.
#!/bin/bash
echo "Database Name: "
read -e dbname
echo "Database User: "
read -e dbuser
echo "Database Password: "
read -s dbpass
echo "run install? (y/n)"
read -e run
if [ "$run" == n ] ; then
@apisandipas
apisandipas / wp-upload-scraper.sh
Created July 18, 2014 15:54
Scrape images from a site, ignoring robots.txt and indexes
wget -r -P . -A jpeg,jpg,png,gif,bpm --reject="index.html" -e robots=off http://domain.com/path/to//wp-content/uploads
@apisandipas
apisandipas / picture-element.html
Last active August 29, 2015 14:04
Picture element
<picture>
<source media="(min-width: 600px)" srcset-"large.jpg, large-@2x.jpg 2x">
<img src="small.jpg" alt="alternative text">
</picture>
@apisandipas
apisandipas / picturefill.html
Last active August 29, 2015 14:04
Picturefill 1.0 in action
<span data-picture>
<span data-src="small.jpg"></span>
<span data-src="small-@x2.jpg" data-media="(min-device-pixel-ratio: 2.0)"></span>
<span data-src="medium.jpg" data-media="(min-width: 1030px)"></span>
<span data-src="medium-@2x.jpg" data-media="(min-width: 1030px) and (min-device-pixel-ratio: 2.0)"></span>
<span data-src="large.jpg" data-media="(min-width: 1240px)"></span>
<span data-src="large-@2x.jpg" data-media="(min-width: 1240px) and (min-device-pixel-ratio: 2.0)"></span>
<noscript>
<img src="medium.jpg"/>
@apisandipas
apisandipas / picturefill-better.php
Last active August 29, 2015 14:04
With Retina.js in the mix, retina images are picked up automagically.
<?php
$images = get_children(array(
'post_parent' => get_the_ID(),
'post_type' => 'attachment',
'post_mime_type' => 'image',
);
if ( $images ) : ?>
<?php foreach( $images as $image ) : ?>
<span data-picture>
@apisandipas
apisandipas / gist:61ca94944c7617ae04a8
Created September 15, 2014 14:28
wordpress - truncate title
function truncated_title($limit = 49){
$title = substr(get_the_title(), 0, $limit);
if (strlen($title) > $limit) {
$title .= " ...";
}
return $title;
}
@font-face {
font-family: 'francois_oneregular';
src: url('francoisone.eot');
src: url('francoisone.eot?#iefix') format('embedded-opentype'),
url('francoisone.woff') format('woff'),
url('francoisone.ttf') format('truetype'),
url('francoisone.svg#francois_oneregular') format('svg');
font-weight: normal;
font-style: normal;
@apisandipas
apisandipas / gist:cc7797adbaae70f075a6
Created September 18, 2014 15:50
CSS Greyscale hover
img:hover{
filter: grayscale(100%);
-webkit-filter: grayscale(100%);
-moz-filter: grayscale(100%);
-ms-filter: grayscale(100%);
-o-filter: grayscale(100%);
}