Skip to content

Instantly share code, notes, and snippets.

View alloyking's full-sized avatar
🎧
.

Tim Shultis alloyking

🎧
.
View GitHub Profile
@alloyking
alloyking / videooffscreen.js
Last active May 11, 2016 02:43
off screen pause
play_in_view: function() {
percent_of_video_visible = 0.2;
function check_videos_in_view() {
$('.ambient video').each(function() {
var x = $(this).offset().left,
y = $(this).offset().top,
@alloyking
alloyking / canvas-upload.php
Created May 5, 2016 03:30 — forked from fazlurr/canvas-upload.php
Function to save base64 image to png with PHP
<?php
// requires php5
define('UPLOAD_DIR', 'images/');
$img = $_POST['img'];
$img = str_replace('data:image/png;base64,', '', $img);
$img = str_replace(' ', '+', $img);
$data = base64_decode($img);
$file = UPLOAD_DIR . uniqid() . '.png';
$success = file_put_contents($file, $data);
print $success ? $file : 'Unable to save the file.';
@alloyking
alloyking / nginx.conf
Created April 7, 2016 16:19 — forked from thoop/nginx.conf
Official prerender.io nginx.conf for nginx
# Change YOUR_TOKEN to your prerender token and uncomment that line if you want to cache urls and view crawl stats
# Change example.com (server_name) to your website url
# Change /path/to/your/root to the correct value
server {
listen 80;
server_name example.com;
root /path/to/your/root;
index index.html;
<?php
/**
* Plugin Name: Multisite: Passwort Reset on Local Blog
* Plugin URI: https://gist.github.com/eteubert/293e07a49f56f300ddbb
* Description: By default, WordPress Multisite uses the main blog for passwort resets. This plugin enables users to stay in their blog during the whole reset process.
* Version: 1.0.0
* Author: Eric Teubert
* Author URI: http://ericteubert.de
* License: MIT
*/
@alloyking
alloyking / install_ffmpeg_ubuntu.sh
Last active February 25, 2016 15:51 — forked from xdamman/install_ffmpeg_ubuntu.sh
Install latest ffmpeg on ubuntu 14.04
#!/bin/bash
# Bash script to install latest version of ffmpeg and its dependencies on Ubuntu 12.04 or 14.04
# Inspired from https://gist.github.com/faleev/3435377 && https://gist.github.com/xdamman/e4f713c8cd1a389a5917
# Remove any existing packages:
sudo apt-get -y remove ffmpeg x264 libav-tools libvpx-dev libx264-dev
# Add multiverse. Not all deps are in the main repo
sudo apt-add-repository multiverse && sudo apt-get update
@alloyking
alloyking / functions.php
Created June 29, 2015 17:01
WP multisite lost password redirection
add_action('lostpassword_post', 'validate_reset', 99, 3);
function validate_reset(){
if(isset($_POST['user_login']) && !empty($_POST['user_login'])){
$email_address = $_POST['user_login'];
//is this an email reset?
if(filter_var( $email_address, FILTER_VALIDATE_EMAIL )){
if(!email_exists( $email_address )){
wp_redirect( $_POST['redirect_to'].'/register' );
@alloyking
alloyking / 02_npm_nodejs.config
Created March 19, 2015 13:16
install nodejs & npm on beanstalk aws
commands:
01_node_install:
# run this command from /tmp directory
cwd: /tmp
# don't run the command if node is already installed (file /usr/bin/node exists)
test: '[ ! -f /usr/bin/node ] && echo "node not installed"'
# install from epel repository
# flag -y for no-interaction installation
command: 'yum install -y nodejs --enablerepo=epel'
02_npm_install:
@alloyking
alloyking / when.apply
Created February 26, 2015 18:17
when apply
// 1. Declare an array of 4 elements
var data = [1,2,3,4]; // the ids coming back from serviceA
// 2. Declare an array of Deferred objects
var processItemsDeferred = [];
// 3. For each element of data, create a Deferred push push it to the array
for(var i = 0; i < data.length; i++){
processItemsDeferred.push(processItem(data[i]));
}
@alloyking
alloyking / sw.js
Created February 11, 2015 13:48
service worker test
//
@alloyking
alloyking / index.html
Last active August 29, 2015 14:04
square / rectangle entry position
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
</head>
<body>
<div id="square" style="background-color: #ccc; width:200px; height:140px;">