Skip to content

Instantly share code, notes, and snippets.

:shipit:
hg commit

Dan Harper danharper

:shipit:
hg commit
Block or report user

Report or block danharper

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@danharper
danharper / Redirector.js
Last active Aug 29, 2015
Mess to transition in async action creators for redux-react-router
View Redirector.js
import { Component, PropTypes } from 'react'
import { connect } from 'react-redux'
import { transitionTo } from 'redux-react-router'
const NEXT_URL = 'REDIRECTOR(NEXT_URL)'
const CLEAR_NEXT_URL = 'REDIRECTOR(CLEAR_NEXT_URL)'
export const transitionNext = url => ({ type: NEXT_URL, payload: url })
export const clearNextUrl = () => ({ type: CLEAR_NEXT_URL })
@danharper
danharper / validators.md
Last active Aug 29, 2015
Validation Library
View validators.md

To define your validation rules, provide a Map. Keys are field names, values are either a validation rule, or an array of validation rules.

// one rule
const rules = new Map([
  ['name', required]
])

// multiple rules
const rules = new Map([
@danharper
danharper / how.md
Created Jun 26, 2015
enable Chrome Dev Tools debugging of PhoneGap Build apps on Android
View how.md

Inside config.xml add the following attribute to the widget element:

xmlns:android="http://schemas.android.com/apk/res/android"

(For example, it looks like this for me:)

<widget id="com.radweb.ibgo"
@danharper
danharper / demo.md
Last active Jun 23, 2019
Open native Maps apps on iOS and Android in Cordova
View demo.md
iOS (with pin, iOS will lookup address too and show that as label)
maps://?q=LAT,LNG
Android, no pin (just open at location)
geo:LAT,LNG
View gist:a07f939673ce108077dc
jQuery("ul.popover.level0").menuAim({
activate: function(row) { jQuery(row).addClass('active') },
deactivate: function(row) { jQuery(row).removeClass('active') },
rowSelector: 'li.level1.parent',
exitMenu: function() { return true; }
});
@danharper
danharper / query-params.php
Last active Aug 29, 2015
query params. experiment in something a little different
View query-params.php
<?php
namespace param {
class QueryParam {
const SINGLE = 'single';
const MANY = 'many';
const MANY_CSV = 'csv';
public $queryField;
private $nullable = false;
@danharper
danharper / CatchAllOptionsRequestsProvider.php
Last active Sep 8, 2019
Lumen with CORS and OPTIONS requests
View CatchAllOptionsRequestsProvider.php
<?php namespace App\Providers;
use Illuminate\Support\ServiceProvider;
/**
* If the incoming request is an OPTIONS request
* we will register a handler for the requested route
*/
class CatchAllOptionsRequestsProvider extends ServiceProvider {
View decorators.js
@ngInject('bus', '$ionicModal')
class Adder {
constructor(num) {
this.num = num
}
// order matters
// if you @swallow first, then @log won't log caught exceptions
@log
@swallow
@danharper
danharper / BorderedInput.js
Last active May 16, 2016
BorderedInput, with Material design style focus animation. Preview: https://i.imgur.com/Fek7rXF.gif
View BorderedInput.js
// note there may be a better way to abuse flexbox than this :)
var React = require('react-native')
var { View, TextInput } = React
var BorderedInput = React.createClass({
getInitialState() {
return { i: 0 }
},
View async-await.js
async function sleep(ms) {
return new Promise(r => setTimeout(r, ms))
}
async function foo() { console.log('s foo'); await sleep(2000); console.log('d foo'); return 'foo'; }
async function bar() { console.log('s bar'); await sleep(1000); console.log('d bar'); return 'bar'; }
async function baz() { console.log('s baz'); await sleep(2000); console.log('d baz'); return 'baz'; }
async function run() {
console.log('start')
You can’t perform that action at this time.