Skip to content

Instantly share code, notes, and snippets.

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 October 9, 2022 19:30
Detect private browsing mode (InPrivate Browsing or Incognito).
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 December 30, 2015 09:18
Function for 'parsing' a datestamp in the format returned by Parse for the createdAt / updatedAt fields. Written in JavaScript, but the regex is portable.
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 April 21, 2021 09:08
Truncate helper for Handlebars.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 March 11, 2024 08:20
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

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).

$(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.");
},