Skip to content

Instantly share code, notes, and snippets.

@edpittol
edpittol / gist:3492b086affcc5100708
Created September 14, 2014 04:49
Parse Facebook Login
// Initialize the Facebook SDK with Parse as described at
// https://parse.com/docs/js_guide#fbusers
window.fbAsyncInit = function() {
// init the FB JS SDK
Parse.FacebookUtils.init({
appId : '289802934544559', // Facebook App ID
cookie : true, // enable cookies to allow the server to access
// the session
xfbml : true, // parse social plugins on this page
version : 'v1.0' // use version 1
@aral
aral / transcript.coffee
Last active September 4, 2020 15:44
Quick and dirty regexp that we use to format video transcripts (CoffeeScript)
#!/usr/bin/env coffee
fs = require 'fs'
# Get the file name that’s passed as the first argument
nameOfFile = process.argv.slice(2)[0]
# Read the file and convert it from bytes to a string
file = fs.readFileSync(nameOfFile).toString()
@rickychilcott
rickychilcott / gist:8599a4cba9a05c9b6a62
Last active August 29, 2015 14:04
Parse REST API post in Javascript
PARSE_APPLICATION_ID = 123456789;
PARSE_REST_API_KEY = 123456789;
var messageText = "canned alert";
var parseMessage = {
"channels": "",
"type": "ios",
"expiration_interval": 86400,
"data": {
"alert": messageText,
@yetithefoot
yetithefoot / parsecom2csv
Created December 26, 2013 14:31
Retrieves Parse.com object, filter it and converts to CSV(without header)
# converts Parse.com json object presentation to CSV with simple filtering
# dependency - jq command line tool
# NOTE: Parse.com API does not allow to get more than 1000 records per request, so you need to vary skip and limit params
# https://www.parse.com/docs/rest#general-quick
# NOTE: Also you can download exported Parse.com backup (Parse.com\Settings\Export) and read via "cat filename | jq '.'".
echo `curl -H 'X-Parse-Application-Id: <PASTE_YOUR_APP_ID_HERE>' -H 'X-Parse-REST-API-Key: <PASTE_YOUR_REST_API_KEY_HERE>' -H 'Content-Type: application/json' -L https://api.parse.com/1/classes/Email\?skip=0\&limit=1000 -s` | jq '.results[] | .email +","+.type +","+ .createdAt'
@danlucraft
danlucraft / disqus.js
Last active March 19, 2020 20:33
Disqus embed code for a single page javascript app, with optional SSO.
// Enable or reset Disqus for this page as required, with optional SSO.
// There must be a div with id "disqus_thread" when called.
//
// config is required and should have the format:
//
// {
// shortname: "..",
// title: "..",
// identifier: "..",
// url: ".."
@missinglink
missinglink / prices.regexp.js
Last active April 15, 2021 14:05
Extract price information from any page using regex stolen from this annoying superfish script.
var regexp = /(([\$\£\€\u20AC]|eur|ils|rs)\.?\s*(<[^>]+>|&nbsp;|\s)?([0-9]+[\,\.])?[0-9]+([\,\.][0-9]+)?)|(([0-9]+[\,\.])?[0-9]+([\,\.][0-9]+)?)(<[^>]+>|&nbsp;|\s|\s\,\-\s)?(€|\u20AC|eur|ils|rs)\.?/ig;
document.body.innerHTML.match(regexp);
@Mattieuga
Mattieuga / parse+sendgrid.js
Last active December 13, 2015 22:18
Sample of using Parse with the SendGrid Cloud Module. This example will send an email when other users comment on a picture in Anypic (https://parse.com/anypic).
// Require the SendGrid Cloud Module
var sendgrid = require("sendgrid");
sendgrid.initialize("you@parse.com", "your_password");
// Run this Cloud Function every time a new Activity (such as a comment)
// is saved
Parse.Cloud.afterSave("Activity", function(request, response) {
// Check if the activity type is a comment
var activity = request.object;
if (activity.get("type") === "comment") {
@founddrama
founddrama / moment-in-node.js
Created March 24, 2012 12:53
Moment.js examples
// node:
var moment = require('moment');
moment().add('days', 2).fromNow();
// 'in 2 days'
moment().subtract('days', 2).fromNow();
// '2 days ago'
moment('November 1977').fromNow()