Skip to content

Instantly share code, notes, and snippets.

View raekul's full-sized avatar
💭
✨Magic ✨

Luke Roberts raekul

💭
✨Magic ✨
View GitHub Profile
// setup props function
export function setup<Props>(props: Props) {
return (testProps: Props | {} = {}): Props => ({
...props,
...testProps
});
}
// usage
const partialProps = setup<Props>({
London
Gatwick
Manchester
Birmingham
Dubai
import React, { Component } from 'react';
const Inputs = ({ handleChange }) => (
<div className="inputs">
<input type="text" value="somat" onChange={() => handleChange()} />
<input type="text" value="somat" onChange={() => handleChange()} />
<input type="text" value="somat" onChange={() => handleChange()} />
</div>
);
<?php
class blah extends blah {
public function getDetails($place_id)
{
$googlePlaces = new PlacesApi($this->key);
try {
$this->response = $googlePlaces->placeDetails($place_id);
// Dependencies
import React, { Component, PropTypes } from 'react';
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux';
import Waypoint from 'react-waypoint';
import ReactCSSTransitionGroup from 'react-addons-css-transition-group';
// Functional
import * as postActionCreators from '../actions/postsActionCreators';
import { responseImage, responseImageAlt, responseImageTitle } from '../helpers/images/';
/**
* Fix for uploads specifically in our case (svg) files
* See here - https://wordpress.org/support/topic/wp-4-7-1-kills-svg/
*
* This corrects a bug in WP 4.7.1 which tries to enforce agressive
* mimetype checking which is too verbose.
*/
add_filter('wp_check_filetype_and_ext', function($data, $file, $filename, $mimes) {
$wp_filetype = wp_check_filetype($filename, $mimes);
$ext = $wp_filetype['ext'];
// The mixin
@mixin set-ratio($width, $height, $selectors...) {
// needed on the parent so the absolute childs reference it
position: relative;
// create our ratio with the psuedo before
&:before {
display: block;
content: "";
@raekul
raekul / docker-inspect.sh
Created November 7, 2016 11:48
Inspect ips of a running container by its ID
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' container_name_or_id
<?php
// Register Custom Post Type - Hardware
function adaptive_hardware_post_type() {
$labels = array(
'name' => _x( 'Hardware', 'Post Type General Name', 'hardware_post_type' ),
'singular_name' => _x( 'Hardware', 'Post Type Singular Name', 'hardware_post_type' ),
'menu_name' => __( 'Hardware', 'hardware_post_type' ),
'name_admin_bar' => __( 'Hardware', 'hardware_post_type' ),
'archives' => __( 'Hardware Archives', 'hardware_post_type' ),
'parent_item_colon' => __( 'Parent Hardware:', 'hardware_post_type' ),
@raekul
raekul / custom-post-taxonomy-permalinks.php
Created April 26, 2016 15:20 — forked from kasparsd/custom-post-taxonomy-permalinks.php
Create permalink structure URLs for custom post types that include all parent terms from a custom taxonomy
<?php
/*
Term Archive Pages:
- http://example.com/recipes/dinner/
- http://example.com/recipes/breakfast,brunch/
Single Recipe Pages:
- http://example.com/recipes/dinner/soup-title/