View flickr-hacky-download.js
var photos = document.getElementsByClassName('photo-list-photo-view');
var photos_length = photos.length;
for ( var i = 0; i < photos_length; i++ ) {
var photo = photos[i];
var style_bg_image = photo.style.backgroundImage;
var url = 'https:' + style_bg_image.replace('url(','').replace(')','');
url = url.replace('"', '');
url = url.replace('"', '');
View jquery.js
(function(){
var init = function () {
};
$(document).ready(function () {
init();
});
$(window).on('load', function () {
});
View instagrams.js
var grams = document.getElementsByTagName('img');
var times = grams.length;
for ( var i=0; i < times; i++ ) {
console.log( grams[i].getAttribute('src') );
}
View ends_with_punctuation.php
<?php
function ends_with_punctuation($string) {
if ( preg_match("/[0-9.!?,;:]$/", $string) ) {
return true;
}
return false;
}
View wp_get_post_by_slug.php
<?php
function get_post_by_slug($slug) {
$args = array(
'name' => $slug,
'post_type' => 'page',
'post_status' => 'publish',
'posts_per_page' => 1,
);
$found_posts = get_posts($args);
if ( count($found_posts) > 0 ) {
View post_meta.php
<?php
class PostMeta {
public function __construct() {
$this->container = HtmlGenerator\HtmlTag::createElement('div')
->addClass('post-meta');
$this->post_title = $this->container
->addElement('div')
->addClass('post-title')
->addClass('hidden');
View join-sentence.php
<?php
/*
Adapted from: http://stackoverflow.com/a/8586179/2535178
Usage:
$items = array('Foo', 'Bar', 'Baz');
echo join_sentence($items).'.';
# Foo, Bar and Baz.
*/
View reorder-elements.coffee
#= include "jquery.js"
#= include "jquery.throttle-debounce.js"
$ ->
$el = {}
$el.window = $(window)
$el.container = $(".footer > div")
$el.other_stuff = $el.container.find(".other-stuff")
$el.social_links = $el.other_stuff.find(".social-links")
breakpoint_width = 768
View _schema-examples
These snippets are my Schema.org examples.
View mac-os-dock-spacer.sh
#! /bin/bash
defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="spacer-tile";}'
killall Dock