Skip to content

Instantly share code, notes, and snippets.

@jbraithwaite
jbraithwaite / ControlledRouter.js
Last active October 19, 2016 01:22 — forked from gaelollivier/ControlledRouter.js
React Router v4 ControlledRouter
// Code taken from:
// https://gist.github.com/gaelduplessix/050e5cce31f9fabb1030f4ba47663db5
// gaelduplessix/ControlledRouter.js
import React, { Component } from 'react'
import BrowserHistory from 'react-history/BrowserHistory'
import { Push } from 'react-history'
import { StaticRouter } from 'react-router'
class RouterWrapper extends Component {
import React, { Component, PropTypes } from 'react'
import { TouchableHighlight } from 'react-native'
const Nav = ({ to, children, replace=false, ...rest }, { router }) => (
<TouchableHighlight
onPress={() => {
(replace ? router.replaceWith : router.transitionTo)(to)
}}
{...rest}
>{children}</TouchableHighlight>
@dgieselaar
dgieselaar / gist:8b20e9d593e1806a098b
Last active July 5, 2017 10:39
Code splitting, lazy-loading, import statements, Angular + newNgRouter + ocLazyLoad + webpack
import _ from 'lodash';
import angular from 'angular';
import 'angular-new-router';
import 'oclazyload';
function AppController ( ) {
}
AppController.$routeConfig = [];
/*eslint no-console: 0*/
import React, { PropTypes } from 'react'
import { historyContext as historyContextType } from 'react-history/PropTypes'
import StaticRouter from './StaticRouter'
// intitial key is `null` because JSON.stringify turns undefined into null, and
// we use this value as the "initial key"
const initialKeys = [ null ]
const IS_DOM = typeof window !== 'undefined'
@avafloww
avafloww / PhpJava.java
Last active October 16, 2022 18:50
This snippet of code is syntactically valid in both PHP and Java, and produces the same output in both.
/*<?php
//*/public class PhpJava { public static void main(String[] args) { System.out.printf("/*%s",
//\u000A\u002F\u002A
class PhpJava {
static function main() {
echo(//\u000A\u002A\u002F
"Hello World!");
}}
//\u000A\u002F\u002A
PhpJava::main();
@acdlite
acdlite / app.js
Last active January 20, 2023 08:23
Quick and dirty code splitting with React Router v4
// getComponent is a function that returns a promise for a component
// It will not be called until the first mount
function asyncComponent(getComponent) {
return class AsyncComponent extends React.Component {
static Component = null;
state = { Component: AsyncComponent.Component };
componentWillMount() {
if (!this.state.Component) {
getComponent().then(Component => {
@tappleby
tappleby / 0_concept.js
Created July 7, 2015 01:52
Redux => To web worker
const composedCreateStore = compose(
applyMiddleware(
thunkMiddleware,
dispatchIdMiddleware,
webWorkerMiddleware('/build/worker.js'),
() => promiseMiddleware,
loggerMiddleware
),
createStore
);
<?php
namespace App\Http\Middleware;
use Closure;
use App\Services\Cache\ActionCacheManager;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
/**
* Middleware that will cache controller action responses
@wbroek
wbroek / genymotionwithplay.txt
Last active February 12, 2024 03:22
Genymotion with Google Play Services for ARM
NOTE: Easier way is the X86 way, described on https://www.genymotion.com/help/desktop/faq/#google-play-services
Download the following ZIPs:
ARM Translation Installer v1.1 (http://www.mirrorcreator.com/files/0ZIO8PME/Genymotion-ARM-Translation_v1.1.zip_links)
Download the correct GApps for your Android version:
Google Apps for Android 6.0 (https://www.androidfilehost.com/?fid=24052804347835438 - benzo-gapps-M-20151011-signed-chroma-r3.zip)
Google Apps for Android 5.1 (https://www.androidfilehost.com/?fid=96042739161891406 - gapps-L-4-21-15.zip)
Google Apps for Android 5.0 (https://www.androidfilehost.com/?fid=95784891001614559 - gapps-lp-20141109-signed.zip)