Skip to content

Instantly share code, notes, and snippets.

View wildlyinaccurate's full-sized avatar
🐕‍🦺

Joseph Wynn wildlyinaccurate

🐕‍🦺
View GitHub Profile
@wildlyinaccurate
wildlyinaccurate / rebase1
Created May 21, 2013 13:50
Complete the `rebase1` level of Learn Git Branching in 6 moves - http://pcottle.github.io/learnGitBranching/
git checkout another
git rebase side
git rebase bugFix
git rebase master
git checkout master
git rebase another
@wildlyinaccurate
wildlyinaccurate / xranr-force-resolution.sh
Created September 27, 2013 14:49
Force X to use a certain screen resolution
# Ad-hoc
xrandr --newmode 1920x1080 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync
xrandr --addmode VBOX0 1920x1080
xrandr --output VBOX0 --mode 1920x1080
# Or in ~/.i3/config
# exec_always xrandr --newmode 1920x1080 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync
# exec_always xrandr --addmode VBOX0 1920x1080
# exec_always xrandr --output VBOX0 --mode 1920x1080
@wildlyinaccurate
wildlyinaccurate / monitor-concurrent-commands.sh
Created October 3, 2013 08:56
A simple way of checking the exit code of commands which have been run concurrently.
sleep_times=('4' '1' '2' '5' '0')
pids=()
for sleep_time in ${sleep_times[@]}
do
sleep $sleep_time &
pids=(${pids[@]} $!)
done
for pid in ${pids[@]}
@wildlyinaccurate
wildlyinaccurate / recursive_array_search.php
Created April 23, 2012 21:39
PHP Recursive Array Search
<?php
/**
* Recursively search an array for a given value. Returns the root element key if $needle
* is found, or FALSE if $needle cannot be found.
*
* @param mixed $needle
* @param array $haystack
* @param bool $strict
* @return mixed|bool
@wildlyinaccurate
wildlyinaccurate / morph-module-checklist.md
Last active April 18, 2017 14:33
Morph module PR checklist
@wildlyinaccurate
wildlyinaccurate / morph-duplicate-style-checker.js
Last active May 31, 2017 07:51
Check any Morph-powered page for duplicate styles.
var page = require('webpage').create()
var system = require('system')
if (system.args.length === 1) {
console.log('Usage: morph-style-checker.js <URL>')
phantom.exit(1)
}
var url = system.args[1]
@wildlyinaccurate
wildlyinaccurate / client.js
Last active June 4, 2017 20:04
Simplified approach for hydrating statically-rendered React components on the client.
import React from 'react'
import ReactDOM from 'react-dom'
const hydrateComponent = (scriptEl) => {
const componentId = scriptEl.getAttribute('data-hydration-data-id')
const componentElement = document.querySelector(`[data-hydration-component-id="${componentId}"]`)
const props = JSON.parse(scriptEl.innerHTML)
import(componentId).then(Component => ReactDOM.render(<Component {...props} />, componentElement))
}
@wildlyinaccurate
wildlyinaccurate / safe-component.jsx
Created June 21, 2017 17:28
Proof-of-concept for making React components "safe" or "optional" by catching errors during rendering.
// Paste this into https://preactjs.com/repl to see it working
// This function takes any component, and returns a higher-order (wrapper)
// component. This wrapper attempts to render the wrapped component, catching
// any errors.
const safeComponent = (Component) => function WrappedComponent () {
// Handle both class components and stateless functional components
const wrappedRender = Component.prototype.render || Component
try {
@wildlyinaccurate
wildlyinaccurate / AccountControllerTest.php
Created July 9, 2012 22:00
Laravel Controller Test Case
<?php
require_once 'ControllerTestCase.php';
class AccountControllerTest extends ControllerTestCase
{
public function testSignupWithNoDataRedirectsAndHasErrors()
{
$response = $this->post('account@signup', array());
@wildlyinaccurate
wildlyinaccurate / Preferences.sublime-settings
Last active January 13, 2021 00:43
My Sublime Text configuration
{
"theme": "Soda Dark.sublime-theme",
"color_scheme": "Packages/Theme - Refined/Color Schemes/Monokai Refined.tmTheme",
"font_face": "Droid Sans Mono",
"font_size": 12,
"font_options": ["no_italic"],
"highlight_line": true,
"line_padding_top": 3,
"line_padding_bottom": 3,