Skip to content

Instantly share code, notes, and snippets.

View joshbuchea's full-sized avatar

Josh Buchea joshbuchea

View GitHub Profile
@joshbuchea
joshbuchea / ionic-directive-navclear.js
Last active August 29, 2015 14:12
Ionic navClear directive replacement for beta 14+
.directive('navClear', [
'$ionicHistory',
'$state',
'$location',
'$window',
'$rootScope',
function($ionicHistory, $location, $state, $window, $rootScope) {
$rootScope.$on('$stateChangeError', function() {
$ionicHistory.nextViewOptions(null);
});
@joshbuchea
joshbuchea / angular-filter-tel.js
Last active August 29, 2015 14:14
AngulaJS Telephone Format Filter
.filter('tel', function () {
return function (tel) {
if (!tel) { return ''; }
var value = tel.toString().trim().replace(/^\+/, '');
if (value.match(/[^0-9]/)) {
return tel;
}
@joshbuchea
joshbuchea / cordova-native-notifications.js
Created February 5, 2015 19:15
Cordova - window.alert → Native Notifications
document.addEventListener('deviceready', function () {
if (navigator.notification) { // Override default HTML alert with native dialog
window.alert = function (message) {
navigator.notification.alert(
message, // message
null, // callback
"Notification Title", // title
'OK' // buttonName
);
};
@joshbuchea
joshbuchea / get-url-params.js
Last active October 11, 2022 23:13
JavaScript - Get URL Query Params
/**
* Returns a bare object of the URL's query parameters.
* You can pass just a query string rather than a complete URL.
* The default URL is the current page.
*/
function getUrlParams (url) {
// http://stackoverflow.com/a/23946023/2407309
if (typeof url == 'undefined') {
url = window.location.search
}
@joshbuchea
joshbuchea / osx-10.10-setup-COPY.md
Last active August 29, 2015 14:15 — forked from kevinelliott/osx-10.10-setup.md
Mac OS X 10.10 Yosemite Setup
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Single-Column Responsive Email Template</title>
<style>
@media only screen and (min-device-width: 541px) {
.content {
@joshbuchea
joshbuchea / canvas-upload.php
Last active February 19, 2016 21:33
Canvas Upload
<?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.';
require 'fileutils'
# An OS X System Service for quickly filing image files to a Jekyll blog folder,
# putting Markdown links to the files on the clipboard.
# Copyright Brett Terpstra 2013
# Config
# ======
# Where to store the images
base_path = '~/Sites/dev/octopress/source/uploads/'
// REQUIRES:
// moment.js - https://github.com/moment/momentjs.com
// USAGE:
// {{ someDate | moment: [any moment function] : [param1] : [param2] : [param n]
// EXAMPLES:
// {{ someDate | moment: 'format': 'MMM DD, YYYY' }}
// {{ someDate | moment: 'fromNow' }}
if (typeof window.localStorage == 'undefined' || typeof window.sessionStorage == 'undefined') (function () {
var Storage = function (type) {
function createCookie(name, value, days) {
var date, expires;
if (days) {
date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
expires = "; expires="+date.toGMTString();