Skip to content

Instantly share code, notes, and snippets.

View imjakechapman's full-sized avatar
⛓️
@6079.ai

Jake Chapman imjakechapman

⛓️
@6079.ai
View GitHub Profile
@imjakechapman
imjakechapman / example.js
Created August 15, 2019 21:20
Location State
const Example = () => (
<Router>
<h1>Location State Example</h1>
<Route>
{({ location }) => {
<Switch>
<Location state={null} component={Page1} />
<Location state="page2" component={Page2} />
<Location state="page3" component={Page3} />
<Location component={NotFound} />
@imjakechapman
imjakechapman / index.js
Last active September 13, 2018 20:01
Download H1Z1 match placing images.
require('babel-register')({
presets: [ 'env' ]
})
module.exports = require('./task.js')
@imjakechapman
imjakechapman / serializable_hash_from_rails_objects_merge.rb
Last active June 7, 2018 22:32
Serializable Ruby Hash from an array of Rails objects that you need the hash key as object id and extra props
def methodToReturnHashMap
Hash[ self.some_method_that_returns_array_of_rails_objects.collect { |obj|
[obj.id , obj.attributes.merge({
extra: 'value',
another_extra: 'value'
})]
}]
end
@imjakechapman
imjakechapman / redbullgrc-event-page-parser.js
Created June 21, 2016 00:45
RedbullGRC Event Page Parser
// Usage
//
// 1. Copy this script and paste in to the dev tool console in chrome
// 2. type createRedbullGRCEvents().then(function() { console.log('PARSING EVENTS FINISHED'); });
// 3. After the console log appears type copy(window.RedbullGRCEVENTS)
// 4. JSON Object with event listings from that page are now copied to your clipboard, enjoy.
// Load jQuery onto the page, just in case it hasn't already been
function loadjQuery() {
// Load jQuery onto the page
var GaugeWrapper = React.createClass({
componentDidMount(){
var target = React.findDOMNode(this)
var gauge = new Gauge(target).setOptions(this.props.options);
gauge.maxValue = this.props.max;
gauge.set(this.props.value);
},
render(){
return <canvas width={this.props.width} height={this.props.height} />
}
import path from 'path';
import webpack from 'webpack';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
import BundleTracker from 'webpack-bundle-tracker';
import autoprefixer from 'autoprefixer';
const PATHS = {
WEB: path.resolve(__dirname, process.env.WEB_PATH),
DIST: path.resolve(__dirname, process.env.DIST_PATH),
SRC: path.resolve(__dirname, process.env.SRC_PATH)
@imjakechapman
imjakechapman / howto.md
Last active January 16, 2016 04:15
ES2015 Webpack Configs

Before you do this, make sure you've updated your node version :)

  1. rename webpack.config.js to webpack.config.babel.js
  2. npm -i --save-dev babel babel-loader babel-preset-es2015 babel-preset-stage-0
  3. create a .babelrc file in root directory
  4. add the following to .babelrc
{
  "presets": ["es2015", "stage-0"]
}
@imjakechapman
imjakechapman / gist:6de684db9db227c678dc
Created January 9, 2016 07:13
JavaScript APIs you should be using instead of jQuery
// Element Selecting - jQuery $('.some-el')
let el = document.querySelector('.some-el')
let els = document.querySelectorAll('.some-els')
// Element Classes - jQuery el.[addClass/removeClass/toggleClass]('some-class')
el.classList.add('added-class')
el.classList.remove('removed-class')
el.classList.toggle('toggled-class')
// Element Class Checking - el.hasClass('conditional-class')
@imjakechapman
imjakechapman / gist:55e42549363ae8b7fd98
Created September 10, 2015 22:42
basic .travis.yml
language: node_js
node_js:
- "0.12.7"
script: npm run test
@imjakechapman
imjakechapman / nginx.conf
Last active August 29, 2015 14:24 — forked from thoop/nginx.conf
# Change YOUR_TOKEN to your prerender token and uncomment that line if you want to cache urls and view crawl stats
# Change example.com (server_name) to your website url
# Change /path/to/your/root to the correct value
server {
listen 80;
server_name example.com;
root /path/to/your/root;
index index.html;