It's now here, in The Programmer's Compendium. The content is the same as before, but being part of the compendium means that it's actively maintained.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const MODULE_DIR = /(.*([\/\\]node_modules|\.\.)[\/\\](@[^\/\\]+[\/\\])?[^\/\\]+)([\/\\].*)?$/g; | |
{ | |
loader: 'babel-loader', | |
test: /\.jsx?$/, | |
include(filepath) { | |
if (filepath.split(/[/\\]/).indexOf('node_modules')===-1) return true; | |
let pkg, manifest = path.resolve(filepath.replace(MODULE_DIR, '$1'), 'package.json'); | |
try { pkg = JSON.parse(fs.readFileSync(manifest)); } catch (e) {} | |
return !!(pkg.module || pkg['jsnext:main']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See https://blog.isquaredsoftware.com/presentations/react-redux-ts-intro-2020-12/#/36 for slides | |
// My basic render function structure: | |
function RenderLogicExample({ | |
someBoolean, // 1) Destructure values from `props` object | |
someList, | |
}) { | |
// 2) Declare state values | |
const [a, setA] = useState(0); | |
const [b, setB] = useState(0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$start = abs(date('w')-1); //monday = 0 | |
$start = $start . "1"; //monday = 01 (first index), friday = 41 | |
$feed = implode(file('https://www.googleapis.com/customsearch/v1?alt=atom&cx=xxx:yyy&key=abc&q=timesheet+meme&searchType=image&start='.$start)); | |
$xml = simplexml_load_string($feed); | |
$json = json_encode($xml); | |
$array = json_decode($json,TRUE); | |
$img = ""; | |
shuffle($array["entry"]); //random selection from ten results starting from $start to avoid meme repetition |
Most of the modules I write are "agnostic" in that they should work in Node, browserify, webpack, Rollup, jspm... hell, even Unreal.js. It's just ES5, CommonJS and a few quirks like process.nextTick
or require('path')
(which browserify and webpack will shim).
Other modules are a bit trickier, and need to include a static asset like HTML, GLSL or another file.
In Node you might see this:
var fs = require('fs')
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import h from 'virtual-dom/h' | |
export default function(tag, props, ...children) { | |
if (typeof tag === 'function') { | |
return tag(props, ...children) | |
} else { | |
return h(tag, transformProps(props), children) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ubuntu has a stupid policy of not cleaning up boots because they deem | |
# unknowable whether a kernel is valid or not (even if booted). Combined with | |
# the default Ubuntu setup that creates a ridiculously small /boot that is | |
# bound to be filled in a few months worth of updates, you have a recipe for a | |
# failure during upgrade, leading to being unable to update or remove anything | |
# and having to mess with apt and dpkg innards by hand. | |
# This may work for Debian too. | |
# This one liner keeps /boot fresh and clean by removing the currently | |
# running kernel version as well as the latest one (which may not be |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ------------ | |
// counterStore.js | |
// ------------ | |
import { | |
INCREMENT_COUNTER, | |
DECREMENT_COUNTER | |
} from '../constants/ActionTypes'; | |
const initialState = { counter: 0 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A xterm-256color based TERMINFO that adds the escape sequences for italic. | |
# | |
# Install: | |
# | |
# tic xterm-256color-italic.terminfo | |
# | |
# Usage: | |
# | |
# export TERM=xterm-256color-italic | |
# |