Skip to content

Instantly share code, notes, and snippets.

View kjantzer's full-sized avatar
👨‍💻
Likely writing JavaScript

Kevin Jantzer kjantzer

👨‍💻
Likely writing JavaScript
View GitHub Profile
@kjantzer
kjantzer / toggleFullscreen.js
Created March 23, 2016 18:16
Toggle the fullscreen API on an element. `toggleFullscreen(document.body)`
// https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API
function toggleFullscreen(el, fallback){
var body = document.body
// fullscreen API not supported, use fallback if given
if( !body.requestFullscreen &&
!body.webkitRequestFullScreen &&
!body.msRequestFullscreen &&
!body.mozRequestFullScreen
determineFn = function(fn, ctx){
// look for function name on the context
if( _.isString(fn) ){
if( !ctx ){
console.error('Could not bind onClick “'+fn+'”; please provide a context')
fn = null;
}else if( ctx[fn] && _.isFunction(ctx[fn]) ){
@kjantzer
kjantzer / csv_to_array.php
Created November 12, 2015 22:35 — forked from jaywilliams/csv_to_array.php
Convert a comma separated file into an associated array.
<?php
/**
* Convert a comma separated file into an associated array.
* The first row should contain the array keys.
*
* Example:
*
* @param string $filename Path to the CSV file
* @param string $delimiter The separator used in the file
* @return array
@kjantzer
kjantzer / demo-base.less
Created September 22, 2015 17:34
Demo Doc Styles
/*
Demo styles
*/
@import 'lib/elements.less'; // http://lesselements.com/
@import 'lib/flexbox-mixins.less'; // https://gist.github.com/kjantzer/7948269
body {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
font-smoothing: antialiased;
@kjantzer
kjantzer / mac-screen-record.applescript
Last active September 9, 2015 15:26
Open QuickTime for New Screen Recording
tell application "QuickTime Player"
activate
new screen recording
tell application "System Events" to key code 49
end tell
@kjantzer
kjantzer / README.md
Last active November 26, 2020 13:23
Create a GIF from Alfred App

Install Dependencies

$ brew install ffmpeg
$ brew install gifsicle
@kjantzer
kjantzer / Util.Frame.m
Created September 3, 2015 22:15
Objective-C View Frame Methods
void setFrame(UIView* view, NSNumber* x, NSNumber* y, NSNumber* w, NSNumber* h)
{
CGRect f = view.frame;
if( x ) f.origin.x = x.floatValue;
if( y ) f.origin.y = y.floatValue;
if( w ) f.size.width = w.floatValue;
if( h ) f.size.height = h.floatValue;
view.frame = f;
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management
@kjantzer
kjantzer / previous-git-tag.sh
Created March 2, 2015 20:01
Get Previous Git Tag (the one before the latest tag)
# http://stackoverflow.com/a/28818420/484780
git describe --abbrev=0 --tags `git rev-list --tags --skip=1 --max-count=1`
@kjantzer
kjantzer / README.md
Last active August 29, 2015 14:15
Backbone.js Attachment Uploader

The script uses Backbone Modal to display spinners and alerts

You must update apiURL to reflect your internal upload api.

If you wish to use the useImgur option, make sure to set imgurClientID (get it here http://api.imgur.com/)

Use:

var attachment = new Attachment({el: yourElement})
attachment.on('upload:success', function(resp, file, xhttp){