Skip to content

Instantly share code, notes, and snippets.

type StopItProps<T> = {
items: T[]
callback: (item: T, index: number) => JSX.Element
}
const stopIt = <T,>(items: StopItProps<T>['items']) => (
callback: StopItProps<T>['callback']
): JSX.Element[] =>
items.map((item, i) => (
<React.Fragment key={`corey-was-here-${i}-${Date.now()}`}>{callback(item, i)}</React.Fragment>
@simpleshadow
simpleshadow / machine.js
Last active April 17, 2020 19:09
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@simpleshadow
simpleshadow / PermissionUtil.java
Created March 28, 2016 22:40 — forked from andhie/PermissionUtil.java
Marshmallow Permission Level
public static void printPermissions(Context context) {
PackageInfo android;
try {
android = context.getPackageManager().getPackageInfo("android", PackageManager.GET_PERMISSIONS);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
return;
}
PermissionInfo[] permissions = android.permissions;
@simpleshadow
simpleshadow / gist:5811749
Last active December 18, 2015 16:29
/convesrations/:convesration_id tempalte does not render when loaded directly.
/*jshint expr: true, curly: false, unused: false, browser: true*/
/*global $, Ember, iScroll, ExpandScroll*/
'use strict';
var App = Ember.Application.create({
LOG_TRANSITIONS: true,
ready: function () {
document.addEventListener('touchmove', function (e) {
e.preventDefault();
@simpleshadow
simpleshadow / gist:5786276
Created June 15, 2013 00:40
Boom! This allows `{{linkTo}}` transitions and direct URL loads. Needed to utilize `Ember.Route`'s `model` function (for direct URL) and `setupController` (for `{{linkTo}}` transitions).
App.Router.map(function() {
this.resource('happs', function() {
this.route('new');
this.resource('happ', { path: ':happ_name'}, function() {
this.route('edit');
});
});
});
App.HappsRoute = Ember.Route.extend({
@simpleshadow
simpleshadow / gist:5595944
Created May 16, 2013 23:30
Fixtures handlebars template. Fixtures no workie. :'(
<section class="navigation"></section>
<section id="content">
<section id="conversations">
<div class="wrapper">
{{#each model}}
{{#linkTo 'conversation' this}}
{{log this.messages.content.[0]}}
@simpleshadow
simpleshadow / gist:5595941
Created May 16, 2013 23:30
Fixture structure. Fixtures no workie. :'(
var now = new Date();
App.Conversation.FIXTURES = [
{
id: 1,
messages: [{
id: 1,
user: 2,
text: "We are having such a blast at Sam's birthday party!",
conversation_id: 0,
captures: [{
@simpleshadow
simpleshadow / gist:5595940
Last active December 17, 2015 10:39
Fixtures no workie. :'(
/*jshint expr: true, curly: false, unused: false, browser: true*/
/*global $, Ember, iScroll, ExpandScroll*/
'use strict';
var App = Ember.Application.create({
LOG_TRANSITIONS: true,
ready: function () {}
@simpleshadow
simpleshadow / gist:5154119
Created March 13, 2013 17:04
It's not working. :'(
var trackEvent = {
"event": "test tracking pixel",
"properties": {
"token": "SHHH!IT'S_SECRET!",
"time": Date.now(),
"campaign": "ad4game"
}
};
var str = btoa(JSON.stringify(test));
info: Creating snapshot 0.0.1-38
info Uploading: [=============================] 100%
info: Updating app Buskly
info: Activating snapshot 0.0.1-38 for Buskly
info: Starting app Buskly
error: Error running command deploy
error: socket hang up
info: The nodejitsu api reset the connection
help: This error may be due to the application or the drone server
help: For help with this error contact Nodejitsu Support: