Skip to content

Instantly share code, notes, and snippets.

Tom Cavill cavill

Block or report user

Report or block cavill

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View asyncMeteoerMethods.js'method1', /* params, */ function (err, result) {
// method1 has returned.
if (!err) {
// there is no error so let's call method2'method2', /* params, */ function (err, result) {
// method 2 has returned.
if (err) {
// alert to the user there was an error.
cou929 / detect-private-browsing.js
Last active Mar 26, 2020
Detect private browsing mode (InPrivate Browsing or Incognito).
View detect-private-browsing.js
function retry(isDone, next) {
var current_trial = 0, max_retry = 50, interval = 10, is_timeout = false;
var id = window.setInterval(
function() {
if (isDone()) {
if (current_trial++ > max_retry) {
connortreacy / parsedate
Last active Dec 30, 2015
Function for 'parsing' a datestamp in the format returned by Parse for the createdAt / updatedAt fields. Written in JavaScript, but the regex is portable.
View parsedate
var parseDate = function(parseDateString) {
var pattern = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}).(\d+)Z$/g;
var match = pattern.exec(parseDateString);
var date = new Date(match[1],parseInt(match[2])-1,match[3]-1,match[4],match[5],match[6],match[7]);
return date;
TastyToast / handlebars-truncate-helper.js
Last active Mar 10, 2018
Truncate helper for Handlebars.js
View handlebars-truncate-helper.js
Handlebars.registerHelper ('truncate', function (str, len) {
if (str.length > len) {
var new_str = str.substr (0, len+1);
while (new_str.length) {
var ch = new_str.substr ( -1 );
new_str = new_str.substr ( 0, -1 );
if (ch == ' ') {
cobyism /
Last active Apr 4, 2020
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

View gist:3987875
$(document).on("touchend","#resetForm", function(e) {
var email = $("#passwordResetEmail").val();
if(email === "") return;
Parse.User.requestPasswordReset(email, {
success:function() {
alert("Reset instructions emailed to you.");
You can’t perform that action at this time.