Skip to content

Instantly share code, notes, and snippets.

View theseyi's full-sized avatar
💭
making the world's data actionable

Seyi Adebajo theseyi

💭
making the world's data actionable
  • Metaphor Data
View GitHub Profile
@theseyi
theseyi / demo.html
Created September 17, 2013 00:28 — forked from dciccale/demo.html
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Styling radios &amp; checkboxes using CSS3</title>
<link rel="stylesheet" media="screen" href="styles.css" >
</head>
<body>
<h1>Styling radios &amp; checkboxes using CSS3</h1>
@theseyi
theseyi / json.md
Last active August 29, 2015 14:09 — forked from tmcw/json.md

Moral Concerns

JSONP is not actually JSON with padding, it's Javascript code that's executed. JSON is not a real subset of Javascript and the way it is not is important to us: via UTFGrid, we are all UTF-8 masters.

JSONP is not safe: it's Javascript that's executed. It's trivial to XSS with JSONP, because JSONP is XSS. Just have a call like mapbox.load('foo.tilejson', …) and if foo.tilejson gets replaced with destroyYoursite(), it gets run. Compare to JSON.parse, which is, on purpose, not eval.

Practical Concerns

JSONP is questionable in terms of performance. To be fast, you want to have the same callback all the time so that you can cache the response. But this leads to a page like

@theseyi
theseyi / onShow.js
Last active August 29, 2015 14:25 — forked from mxriverlynn/onShow.js
ItemView = Marionette.ItemView.extend({
// ...
onShow: function(){
// I am guaranteed to be called from the CollectionView
// because the CollectionView registers me in a promise
}
});
CollectionView = Marionette.CollectionView.extend({
@theseyi
theseyi / BridgeManager.h
Created May 21, 2016 15:14 — forked from nickhudkins/BridgeManager.h
RN Relay "Reset" LOLROFLCOPTER.
//
// BridgeManager.h
//
// Created by Nick Hudkins on 12/13/15.
//
#import <Foundation/Foundation.h>
#import "RCTBridgeModule.h"
@interface BridgeManager : NSObject <RCTBridgeModule>
@theseyi
theseyi / cancel.js
Created October 26, 2016 20:31
Cancelable Promise
const makeCancelable = (promise) => {
let hasCanceled_ = false;
const wrappedPromise = new Promise((resolve, reject) => {
promise.then((val) =>
hasCanceled_ ? reject({isCanceled: true}) : resolve(val)
);
promise.catch((error) =>
hasCanceled_ ? reject({isCanceled: true}) : reject(error)
);
@theseyi
theseyi / object-watch.js
Created October 24, 2017 03:01 — forked from eligrey/object-watch.js
object.watch polyfill in ES5
/*
* object.watch polyfill
*
* 2012-04-03
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
@theseyi
theseyi / router.js
Last active August 21, 2018 07:23
Integration link-to
import EmberRouter from '@ember/routing/router';
import config from './config/environment';
const Router = EmberRouter.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
this.route('photos', function() {
@theseyi
theseyi / auto-bind.js
Last active February 20, 2019 06:00
auto-bind
import { action } from '@ember-decorators/object';
export default class AutoBind {
end = false;
constructor() {
window.addEventListener('beforeunload', this.onDestroy);
}
@action
@theseyi
theseyi / .txt
Created February 23, 2019 18:43
stack trace
util.js:23 Uncaught TypeError: Cannot read property 'value' of undefined
at getMethod (util.js:23)
at util.js:80
at buildComputedDesc (computed.js:81)
at Object.initializeComputedProperty [as finisher] (computed.js:182)
at decorator.js:79
at __decorate (wherehows-web.js:1684)
at Module.callback (dataset-authors.ts:166)
at Module.exports (loader.js:106)
at requireModule (loader.js:27)
@theseyi
theseyi / document-title-router.js
Created February 28, 2019 03:23 — forked from machty/document-title-router.js
document.title integration in ember
// Extend Ember.Route to add support for sensible
// document.title integration.
Ember.Route.reopen({
// `titleToken` can either be a static string or a function
// that accepts a model object and returns a string (or array
// of strings if there are multiple tokens).
titleToken: null,