Skip to content

Instantly share code, notes, and snippets.

View twslade's full-sized avatar

Thomas Slade twslade

View GitHub Profile
@twslade
twslade / webpack.config.js
Created January 25, 2021 12:47
Using gatsby image in storybook
// @ts-check
const path = require("path");
/**
* NOTE:
*
* See the following section of Storybook's docs for more information
* on how the exported function in this file integrates with Storybook's
* existing webpack config:
*
@twslade
twslade / gatsby-image.js
Created January 25, 2021 12:45
Custom loader for gatsby images in storybook
const path = require("path");
const loaderUtils = require("loader-utils");
const { fluid, fixed } = require("gatsby-plugin-sharp/index");
function getFileObject(absolutePath, hash, name, extension) {
return {
id: `${absolutePath}${hash}`,
name: name,
absolutePath,
import React from "react";
import styled from "styled-components";
import { storiesOf } from "@storybook/react";
import { text, withKnobs } from "@storybook/addon-knobs";
import { mobileViewport, addFullWidthWrapperDecorator } from "../utils";
import { Instagram } from "../../src/components/shared/Instagram";
/** Important pieces here. Images located in ../static/ */
import Instagram1 from "gatsby-image-fluid!../static/instagram_1.jpg";
const path = require("path");
const loaderUtils = require("loader-utils");
const { fluid, fixed } = require("gatsby-plugin-sharp/index");
function getFileObject(absolutePath, hash, name, extension) {
return {
id: `${absolutePath}${hash}`,
name: name,
absolutePath,
const path = require("path");
const CopyPlugin = require("copy-webpack-plugin");
module.exports = ({ config }) => {
config.plugins.push(
new CopyPlugin([
{ from: "stories/static", to: "public/images" }, // Copy static files
{ from: "public/static", to: "./static/" } // Copy gatsby generated static files.
])
<?php
class Only{
protected $_container = null;
public function __construct($value){
$this->_container = $value;
}
public function get(){
<?php
require '/home/thomas/projects/functional-php/vendor/autoload.php';
//Manually currying
$test = function($start){
return function($length) use ($start){
return function($string) use ($start, $length){
return substr($string, $start, $length);
};
<?php
function compose($a, $b){
return function() use ($a, $b){
$args = func_get_args();
return $b(call_user_func_array($a, $args));
};
}
class Just{
<?php
interface Functor{
public function __invoke($function);
}
abstract class AFunctor implements Functor{
protected $_storage = null;
public function __construct($data = null){
$this->set($data);
<?php
$arr = ['one', 'two', 'three', 'four'];
//First class functions
//Functions in variables
$filter = function($item){
return strlen($item) > 3;
};
var_dump(array_filter($arr, $filter));