Skip to content

Instantly share code, notes, and snippets.

@aroc
aroc / fix-mocjha-phantomjs-SIGSRGV.md
Created October 3, 2016 19:03
How to fix phantomjs SIGSEGV error when using mocha-phantomjs on macOS Seierra

1. Install upx with brew:

brew install upx

2. Unpack the binary:

navigate to your project folder and run: upx -d node_modules/phantomjs/lib/phantom/bin/phantomjs

var client = new Keen({
projectId: {PROJECT_ID},
readKey: {READ_KEY}
});
Keen.ready(function(){
var query = new Keen.Query("extraction", {
eventCollection: "CourtesyHoldFunnel",
email: {YOUR_EMAIL}, // Put the email that you want the data extraction sent to here.
timeframe: {"end":"2015-09-15T09:15:00.000+00:00","start":"2015-09-11T09:15:00.000+00:00"}
var videoIds = {
setOne: [1, 2, 3, 4, 5],
setTwo: [6, 7, 8, 9, 10]
};
var query = new Keen.Query("count", {
eventCollection: "videos",
filters: [
{
property_name: 'video_id',
@aroc
aroc / parse-url.js
Created February 9, 2015 17:25
Parse URL into object
var search = location.search.substring(1);
JSON.parse('{"' + decodeURI(search).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g,'":"') + '"}');
@aroc
aroc / simple-server.js
Created July 21, 2014 21:32
Simple node server
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(201, {'Content-Type': 'text/plain'});
res.end('{ "user_id": 1 }');
return;
}).listen(8080, '127.0.0.1');
console.log('Server running at http://127.0.0.1:8080/');
@aroc
aroc / deselectSection.js
Created June 15, 2014 20:54
SideComments deselectSection
sideComments.deselectSection(12);
@aroc
aroc / selectSection.js
Created June 15, 2014 20:51
SideComments selectSection
sideComments.selectSection(12);
@aroc
aroc / insertComment.js
Created June 15, 2014 20:40
SideComments insertComment
var comment = {
sectionId: 12,
comment: "Hey there!",
authorAvatarUrl: "users/avatars/test1.png",
authorName: "Jim Jones",
authorId: 16
};
sideComments.insertComment(comment);
@aroc
aroc / setCurrentUser.js
Created June 15, 2014 20:36
SideComments setCurrentUser
var currentUser = {
"id": 1,
"avatarUrl": "users/avatars/user1.png",
"name": "Jim Jones"
};
sideComments.setCurrentUser(currentUser);
@aroc
aroc / side-comments-listening-to-events
Last active August 29, 2015 14:02
SideComments listening to events example.
// Listen to "commentPosted", and send a request to your backend to save the comment.
// More about this event in the "docs" section.
sideComments.on('commentPosted', function( comment ) {
$.ajax({
url: '/comments',
type: 'POST'
data: comment,
success: function( savedComment ) {
// Once the comment is saved, you can insert the comment into the comment stream with "insertComment(comment)".
sideComments.insertComment(comment);