This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* listen for tap and swipe on the same element, simultaneously... | |
*/ | |
let tapSwipe = (()=>{ | |
var lastSwipe = 0; | |
return (ele, cb) => { | |
let isAction = false; | |
let downAt = {x:0, y:0}; | |
let downHandler = (e) => { | |
downAt = {x: e.touches[0].pageX, y: e.touches[0].pageY}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Anonymous image upload using imgur API | |
* @param $client_id String - The client ID (See: https://imgur.com/account/settings/apps) | |
* @param $img_path String - The path to image to be uploaded (or tempname of uploaded image) | |
* @return String|Bool - false on failure or URL of uploaded image on success. | |
*/ | |
function imgur_anon_upload($client_id, $img_path){ | |
if(!file_exists($img_path) || !is_readable($img_path)) return false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class upScroller{ | |
constructor(ele = document.body){ | |
this.renderedItems = 0; | |
this.ele = ele; var i=0; | |
this.initBoxContents(); | |
} | |
initBoxContents(){ | |
if(this.ele.scrollHeight == this.ele.clientHeight) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Determine if the first element in a jQuery set is accessible to the user | |
*/ | |
$.fn.isClickable = function() { | |
if (!this.length) return false; | |
const getZIndex = e => { | |
if (e === window || e === document) return 0; | |
var z = document.defaultView.getComputedStyle(e).getPropertyValue('z-index'); | |
if (isNaN(z)) return getZIndex(e.parentNode); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Break an array into chunks of a certain size | |
* @param {array} array - The array to break up | |
* @param {integer} chunksSize - The size of each subarray | |
* @returns {Array} - Array of subarrays | |
*/ | |
function arrayChunk(array, chunksSize){ | |
var i, j, chunk = chunksSize, chunks = []; | |
for (i = 0, j = array.length; i < j; i += chunk) { | |
chunks.push(array.slice(i, i + chunk)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Makes an HTTP request via GET or POST, and can download a file | |
* @returns - Returns the response of the request | |
* @param $url - The URL to request, including any GET parameters | |
* @param $params - An array of POST values to send | |
* @param $filename - If provided, the response will be saved to the | |
* specified filename | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Execute the loopBody function once for each item in the items array, | |
* waiting for the done function (which is passed into the loopBody function) | |
* to be called before proceeding to the next item in the array. | |
* @param {Array} items - The array of items to iterate through | |
* @param {Function} loopBody - A function to execute on each item in the array. | |
* This function is passed 3 arguments - | |
* 1. The item in the current iteration, | |
* 2. The index of the item in the array, | |
* 3. A function to be called when the iteration may continue. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.geneticcoder.Versionator; | |
// Check here for updates: https://gist.github.com/Pamblam/53cb2b1c90dea09d4872084956d17b5c | |
import android.content.Context; | |
import android.content.DialogInterface; | |
import android.content.Intent; | |
import android.content.pm.PackageManager; | |
import android.net.Uri; | |
import android.os.AsyncTask; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Format a date using PHP date shorthand | |
* @param {Date} date - A Javascript Date object | |
* @param {String} format - The format of the outputted date | |
* @returns {String} - The formatted date | |
*/ | |
function formatDate(date, format) { | |
if (isNaN(date.getTime())) return "Invalid Date"; | |
var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; | |
var days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# uninstall | |
# | |
# Helper script to deep uninstall stuff from Mac | |
# | |
# Usage example 1 | |
# uninstall firefox | |
# Will find all files installed by firefox and ask for confirmation before removing them | |
# |