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
Meteor.call('method1', /* params, */ function (err, result) {
// method1 has returned.
if (!err) {
// there is no error so let's call method2
Meteor.call('method2', /* params, */ function (err, result) {
// method 2 has returned.
if (err) {
// alert to the user there was an error.
alert(err.reason);
}
@cou929
cou929 / detect-private-browsing.js
Last active Jul 15, 2019
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()) {
window.clearInterval(id);
next(is_timeout);
}
if (current_trial++ > max_retry) {
window.clearInterval(id);
@connortreacy
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
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 == ' ') {
break;
@cobyism
cobyism / gh-pages-deploy.md
Last active Sep 13, 2019
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).
View gh-pages-deploy.md

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) {
e.preventDefault();
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.