Skip to content

Instantly share code, notes, and snippets.

function test(params) {
return {
type: 'TEST',
payload: params
}
}
const metaizeThis = (fn) => {
fn.addMeta = function(meta) {
if(!this._originalFunction) this._originalFunction = this;
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlWebpackPluginConfig = new HtmlWebpackPlugin({
template: './src/index.html',
filename: 'index.html',
inject: 'body'
})
module.exports = {
entry: './src/index.js',
import React from 'react'
import { render } from 'react-dom'
import { hashHistory, Router, Route, Link, withRouter} from 'react-router'
const App = React.createClass({
render() {
return (
<div>
<ul>
import React from 'react'
import { render } from 'react-dom'
import { browserHistory, Router, Route, Link, withRouter} from 'react-router'
import withExampleBasename from '../withExampleBasename'
const App = React.createClass({
render() {
return (
<div>
@BTMPL
BTMPL / dino.js
Created December 23, 2016 13:48
dino cheat ;)
Podium = {};
Podium.keydown = function(k) {
var oEvent = document.createEvent('KeyboardEvent');
// Chromium Hack
Object.defineProperty(oEvent, 'keyCode', {
get : function() {
return this.keyCodeVal;
}
});
class Parent extends React.Component {
constructor(...args) {
super(args);
this.state = {
renderChild: true
}
this.interval = null;
}
var React = require("react");
var Recipe = React.createClass({
updateList: function() {
var list = [];
for (let i = 0; i < window.localStorage.length - 1; i++) {
var key = window.localStorage.key(i);
list.push(window.localStorage.getItem(key));
@BTMPL
BTMPL / immutable.js
Last active December 17, 2016 21:09
ImmutableJS for dummies
function reduce(state = Immutable.fromJS({
items: {
values: []
}
}), action = null) {
if(action) {
switch(action.type) {
case "ADD":
return state.updateIn(['items','values'], (data) => data.push(action.payload));
case "REMOVE":
const EMIT_NOTIFICATION = 'EMIT_NOTIFICATION'
const HIDE_NOTIFICATION = 'HIDE_NOTIFICATION'
const initialState = {
maxItems: 4,
dismissTimeout: 10000, // 10 seconds
items: [],
queue: []
}
<?php
function preventUnnamedPosts($postId) {
$post = get_post($postId);
if(empty($post->post_title)) {
wp_update_post(array(
'ID' => $postId,
'post_title' => $postId
));
}
}