Skip to content

Instantly share code, notes, and snippets.

View Ahrengot's full-sized avatar
🤟

Jens Ahrengot Boddum Ahrengot

🤟
View GitHub Profile
<?php
class AhrMovesNotificationsHandler {
public function __construct() {
add_action('rest_api_init', function() {
register_rest_route('moves/v1', '/notify', array(
'methods' => 'POST',
'callback' => array($this, 'on_receive_update'),
));
Parse.Cloud.beforeSave('rating', function(request, response) {
/**
* Ensure that the video is shortlisted
*/
var videoId = request.object.get('video')
var videoQuery = new Parse.Query('video');
videoQuery.get(videoId).then(function(video) {
if ( !video.get('shortlisted') ) {
// Events (Plucked out of backbone.js source)
// ---------------
// A module that can be mixed in to *any object* in order to provide it with
// a custom event channel. You may bind a callback to an event with `on` or
// remove with `off`; `trigger`-ing an event fires all callbacks in
// succession.
//
// var object = {};
// _.extend(object, Backbone.Events);
import _ from 'underscore';
import '../lib/gsap/TweenMax';
import '../lib/preloadjs-0.6.1.combined';
import EventEmitter from '../util/event-emitter';
class CanvasPlayer {
constructor(opts) {
this.opts = _.defaults(opts || {}, this.getDefaultOpts());
this.state = this.getInitialState();
@Ahrengot
Ahrengot / package.json
Created October 28, 2016 13:01
Bare-bones webpack configuration
{
"name": "google-analytics-plugin",
"version": "1.0.0",
"private": true,
"scripts": {
"test:lint": "eslint ./scripts",
"dev-js": "webpack --config webpack-dev.config.js --progress --profile --colors --watch",
"build-js": "webpack --config webpack-production.config.js --progress --colors",
"dev": "npm run dev-js",
"build": "npm run test:lint && npm run build-js"
/**
* Promise-based wrapper around fetch that will reject promises for
* requests that fail with a non-200 response code.
*/
import _ from 'underscore'
import Promise from 'promise'
const getDefaultOpts = () => {
return {
type: 'json'
import Promise from 'promise'
export const loadPolyfills = () => {
return new Promise((resolve) => {
let promises = []
if ( !global.fetch ) {
promises.push(new Promise((subResolve) => {
require(['whatwg-fetch'], subResolve)
}))
import $ from 'jquery'
export default class ImageLoader {
constructor(images) {
if ( typeof images === 'string' ) {
images = [images];
}
let promises = images.map(this.loadImage);
return $.when.apply($, promises);
@Ahrengot
Ahrengot / parse-rest-api-get.php
Last active September 21, 2015 14:14
Helper to perform GET requests on Parse REST API
<?php
function parse_get($url) {
$app_id = 'PARSE_APP_ID';
$api_key = 'PARSE_API_KEY';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);