This file contains hidden or 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 merge = (a: any, b: any): any => { | |
if ((typeof b !== "undefined" && typeof b !== "object") || Array.isArray(b)) | |
return b; | |
if ((typeof a !== "undefined" && typeof a !== "object") || Array.isArray(a)) | |
return a; | |
a ||= {}; | |
b ||= {}; | |
const keys = [...new Set([...Object.keys(a), ...Object.keys(b)])]; | |
return keys.reduce( |
This file contains hidden or 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 { createTodo, updateTodo, deleteTodo } from './real-todo-api-client' | |
import React from 'react' | |
// create a context where the default value is the "real" production implementation | |
export const TodoApi = useContext({ | |
getTodos, | |
createTodo, | |
updateTodo, | |
deleteTodo | |
}) |
This file contains hidden or 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
for file in *.wav ; do ffmpeg -i "$file" -b:a 320k "${file%.*}.mp3" ; done |
This file contains hidden or 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
/* Conway's Life in pl/pgsql */ | |
/* The 8 directions for finding neighbors of a cell */ | |
create temp table directions(dx int, dy int); | |
insert into directions(dx, dy) values(-1, -1), (0, -1), (1, -1), (-1, 0), (1, 0), (-1, 1), (0, 1), (1, 1); | |
/* alive cells, one row per */ | |
create temp table cells(x int, y int); | |
/* setup seed cells */ |
This file contains hidden or 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
// @flow | |
import * as React from 'react'; | |
import queryString from 'query-string'; | |
import { withRouter } from 'react-router-dom'; | |
export default function withQuery(WrappedComponent: any): any { | |
function QueryWrapper (props: Props) { | |
const query = queryString.parse(props.location.search) || {}; | |
const pushQuery = (query) => { |
This file contains hidden or 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 precedence = ['rock', 'scissors', 'paper']; | |
const results=['TIE', 'FIRST_PLAYER', 'SECOND_PLAYER']; | |
const ordinal = x => precedence.indexOf(x); | |
const circularDirection = (a, b) => (ordinal(b) - ordinal(a) + 3) % 3; | |
const rps = (a, b) => results[circularDirection(a, b)]; |
This file contains hidden or 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
DB_URLS = ( \ | |
postgres://localhost/test_1 \ | |
postgres://localhost/test_2 \ | |
) | |
for db_url in "${DB_URLS[@]}"; do | |
echo "creating database `basename $db_url`" | |
createdb `basename $db_url` > /dev/null 2>&1 | |
psql $db_url -c 'drop schema public cascade; create schema public;' -o /dev/null 2>/dev/null | |
psql $db_url -f "path/to/your/schema.sql" > /dev/null 2>/dev/null |
This file contains hidden or 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
mysqldump \ | |
-u $REMOTE_USER \ | |
-p$REMOTE_PASS \ | |
-h $REMOTE_HOST \ | |
-P $REMOTE_PORT $REMOTE_DB > ./test-dump | |
mysql -h host.docker.internal -P 3306 --password=wordpress -u wordpress wordpress < ./test-dump | |
# Make local-dev-specific modifications | |
mysql -h host.docker.internal -P 3306 --password=wordpress -u wordpress wordpress \ | |
-e "update wp_options set option_value='http://localhost:8080' where option_name in ('siteurl', 'home');" |
This file contains hidden or 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
version: '3' | |
services: | |
db: | |
image: mysql:5.7 | |
volumes: | |
- site_db_data:/var/lib/mysql | |
restart: always | |
ports: | |
# bind to host port so we can run mysql tools on host |
This file contains hidden or 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
#! /bin/bash | |
# flow check prints all of its output to stdout. | |
# In CI, we want to print only failures to stderr to make them easier to find in the build log. | |
# ignore flow diag messages, get rid of 'success' message', then redirect to stderr | |
# grep -v exits non-zero on match match, so we flip the exit code | |
! flow check 2>/dev/null | grep -v 'Found 0 errors' 1>&2 |
NewerOlder