Skip to content

Instantly share code, notes, and snippets.

View crisu83's full-sized avatar
🎩
Coding

Christoffer Niska crisu83

🎩
Coding
View GitHub Profile
class VehicleResolver extends AbstractResolver
{
public function resolveFoo()
{
return 'foo';
}
public function resolveType($rootValue, $contextValues, $info)
{
if ($rootValue instanceof Airplane) {
@crisu83
crisu83 / example.js
Last active September 9, 2017 23:15
A work-in-progress implementation of Foundation Reveal for React-Foundation http://react.foundation
import React from 'react';
import { reveal, revealContext, revealOpen } from './reveal';
const Open = revealOpen({ name: 'example' })(
({ openReveal }) => (
<a onClick={() => openReveal({ a: 10 }}>Open me!</a>
)
);
const Modal = reveal({ name: 'example' })(
@crisu83
crisu83 / general-purpose-reducers.js
Last active June 6, 2017 17:59
General-purpose reducers for Redux.
/**
* This gist was inspired by the video course titled "Building React Applications with Idiomatic Redux"
* available on Egghead.io by the creator of Redux, Dan Abramov.
*
* The purpose of this gist is to demonstrate general purpose reducers that can be used via Redux's combineReducers
* to compose more complex reducers and therefore maximize code reuse.
*
* Feedback is more than welcome!
*
* @author Christoffer Niska <christofferniska@gmail.com>
yarn run v0.19.1
$ flow; test $? -eq 0 -o $? -eq 2
The flow server's version didn't match the client's, so it exited.
Going to launch a new one.
Launching Flow server for /Users/juuso/projects/poc
Spawned flow server (pid=15149)
Logs will go to /private/tmp/flow/zSUserszSjuusozSprojectszSpoc.log
src/hello/saga.js:13
13: fork(function* () {
@crisu83
crisu83 / createEntityCrudSaga.js
Last active September 20, 2016 08:19
A work-in-progress implementation of an entity CRUD saga for redux-saga.
import isArray from 'lodash/isArray';
import isFunction from 'lodash/isFunction';
import isString from 'lodash/isString';
import { takeLatest } from 'redux-saga';
import { call, fork, put } from 'redux-saga/effects';
import { arrayOf, Schema } from 'normalizr';
import { callApi } from '../../api/helper';
import { normalizeEntityResponse } from '../../common/helper';
/**
@crisu83
crisu83 / auth-reducer.js
Created April 11, 2016 20:04
Authentication reducer for OAuth2.
/*eslint no-unused-vars: 0*/
import { fromJS, Map } from 'immutable';
import { createReducer } from '../helpers/store';
import { AuthActionTypes } from '../actions/auth';
import {
setSession,
setUser,
getSession,
getIsAuthenticated,
@crisu83
crisu83 / RenderGroup.js
Last active February 17, 2016 21:47
Custom Phaser Group that allows for sorting all of it's children recursively.
import { Group } from 'phaser';
/**
* Renders the given display objects using the given render session.
* @param {Array} displayObjects
* @param {Object} renderSession
*/
function renderDisplayObjects(displayObjects, renderSession) {
for (let i = 0; i < displayObjects.length; i++) {
displayObjects[i]._renderWebGL(renderSession);
@crisu83
crisu83 / inherit.js
Last active January 4, 2016 18:19
Simple function for extending objects in JavaScript without breaking the prototype chain (uses underscore.js and Object.create()).
/*!
Usage:
// define a base class called 'A'
// inheriting 'null' will inherit an empty constructor,
// this is convenient because you can define all your classes using the inherit method.
// protip: use upper case for classes, lower case for instances
var A = inherit(null, {
doSomething: function() {}
});
<?php
/**
* TbJqueryFileUpload class file.
* @author Christoffer Niska <christoffer.niska@gmail.com>
* @copyright Copyright &copy; Christoffer Niska 2013-
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @package yiistrap-widgets.widgets
*/
/**
@crisu83
crisu83 / codrops-provider.js
Last active December 25, 2015 19:38
Codrops provider for StartHQ
[
  {
    query: 'http://tympanus.net/codrops/?s={{term}}',
    translate: 'parseHTML(response)',
    icon:{
      selector: '.ct-row > article > .ct-latest-thumb',
      expression: 'app.url|icons'
    },
    name:{
      selector: '.ct-row > article > h3 > a',