Skip to content

Instantly share code, notes, and snippets.

View skyebook's full-sized avatar

Skye Book skyebook

View GitHub Profile
@skyebook
skyebook / CVPixelBufferPixelFormatNames.swift
Created March 24, 2017 15:26
Easily get the pixel format name of a CVPixelBuffer
public func CVPixelBufferGetPixelFormatName(pixelBuffer: CVPixelBuffer) -> String {
let p = CVPixelBufferGetPixelFormatType(pixelBuffer)
switch p {
case kCVPixelFormatType_1Monochrome: return "kCVPixelFormatType_1Monochrome"
case kCVPixelFormatType_2Indexed: return "kCVPixelFormatType_2Indexed"
case kCVPixelFormatType_4Indexed: return "kCVPixelFormatType_4Indexed"
case kCVPixelFormatType_8Indexed: return "kCVPixelFormatType_8Indexed"
case kCVPixelFormatType_1IndexedGray_WhiteIsZero: return "kCVPixelFormatType_1IndexedGray_WhiteIsZero"
case kCVPixelFormatType_2IndexedGray_WhiteIsZero: return "kCVPixelFormatType_2IndexedGray_WhiteIsZero"
case kCVPixelFormatType_4IndexedGray_WhiteIsZero: return "kCVPixelFormatType_4IndexedGray_WhiteIsZero"

Keybase proof

I hereby claim:

  • I am skyebook on github.
  • I am sbook (https://keybase.io/sbook) on keybase.
  • I have a public key ASB9pH5ppMwX5I_fKyUwX31eddw5yrLUwALDA44PUH-gGAo

To claim this, I am signing this object:

@skyebook
skyebook / gist:4262228
Created December 11, 2012 21:21
WPDB::Prepare Fix for WordPress 3.5
<?php
// Old (single argument) function call
global $wpdb;
$authorIDs = $wpdb->get_col($wpdb->prepare("SELECT post_author FROM " . $wpdb->posts . " WHERE ID = " . intval($postID) . " LIMIT 1");
// New (two argument) function call
global $wpdb;
$authorIDs = $wpdb->get_col($wpdb->prepare("SELECT post_author FROM " . $wpdb->posts . " WHERE ID = " . intval($postID) . " LIMIT 1", array()));
?>
@skyebook
skyebook / gist:3701879
Created September 11, 2012 20:43
Git merge with theirs strategy
# Use the 'theirs' strategy option during a git merge
git merge -Xtheirs original/master
@skyebook
skyebook / gist:3701793
Created September 11, 2012 20:33
Migrate to new git repository and keep history
# Go to the new repository
cd /path/to/new
# Add the original repository as a remote
git remote add original /path/to/old
# Get the original's branch and merge it into yours
git fetch original/master
git merge original/master
@skyebook
skyebook / gist:3698357
Created September 11, 2012 13:12
Delete WordPress transients
DELETE FROM `wp_options` WHERE `option_name` LIKE '_transient_%'
skyebookpro:Party skyebook$ rhc app restart -a MPCParty
Password: ************
Problem reported from server. Response code was 500.
Re-run with -d for more information.
RESULT:
Node execution failure (invalid exit code from node). If the problem persists please contact Red Hat support.
skyebookpro:Party skyebook$ rhc app force-stop -a MPCParty
@skyebook
skyebook / backup_postgres.sh
Last active April 16, 2016 13:20
Backup OpenShift PostgreSQL Database
#!/bin/bash
# Backs up the OpenShift PostgreSQL database for this application
# by Skye Book <skye.book@gmail.com>
NOW="$(date +"%Y-%m-%d")"
FILENAME="$OPENSHIFT_DATA_DIR/$OPENSHIFT_APP_NAME.$NOW.backup.sql.gz"
pg_dump $OPENSHIFT_APP_NAME | gzip > $FILENAME
@skyebook
skyebook / gist:3288293
Created August 7, 2012 18:50
wp_options cleanser
<?php
/**
* Remove expired transients from the wp_options table.
* This script cycles through a number of expired transients until it doesn't find anymore.
* Our wp_options tables has over 2 million stale entries at time of writing, this limiting is really needed
* @author Skye Book
*/
$user = "";
$pass = "";
@skyebook
skyebook / gist:3231657
Created August 1, 2012 23:52
Post Body to Javascript Fail
function doRequest(request, headers, http_method, request_body, successCallback, failureCallback){
$.ajax({
url: api+request,
headers: headers,
data:JSON.stringify(request_body),
//data:request_body,
processData:false,
type: http_method,
contentType: "application/json",
error: function(XMLHttpRequest, textStatus, errorThrown){