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 cookie from 'tiny-cookie' | |
console.log(cookie) |
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
/** | |
* Applies a Caesar shift to all alphabetical characters in a string. | |
* Characters are converted to uppercase in the returned string. | |
* @param {int} key - Positions to shift (0-25). | |
* @param {string} str - The string to shift. | |
* @return {string} The shifted string. | |
*/ | |
function caesarShift(str, key) { | |
return str.toUpperCase().replace(/[A-Z]/g, c => String.fromCharCode((c.charCodeAt(0)-65+key)%26+65)) | |
} |
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 | |
// src/plugins/redirects.php | |
function htmlRedirect($to) { | |
$to = esc($to); | |
echo <<<EOF | |
<html> | |
<head> | |
<meta http-equiv="Refresh" content="0; url=$to" /> | |
</head> |
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 | |
function relativePath($from, $to) { | |
$fromAry = explode('/', $from); | |
$toAry = explode('/', $to); | |
while (count($fromAry) && count($toAry) && $fromAry[0] === $toAry[0]) { | |
array_shift($fromAry); | |
array_shift($toAry); | |
} | |
$up = count($fromAry); |
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
function weightedChoice(weights) { | |
const weightSum = weights.reduce((sum, w) => sum + w) | |
let choice = Math.floor(Math.random() * weightSum) + 1 | |
let idx = weights.length - 1 | |
while ((choice -= weights[idx]) > 0) { | |
idx -= 1 | |
} | |
return idx | |
} |
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
NAME = main | |
_DEPS = | |
_OBJ = $(NAME).o | |
SDIR = . | |
ODIR = . | |
CC = gcc | |
CFLAGS = -std=c99 -O2 -W -g -I. |
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
var loaderUtils = require('loader-utils'); | |
module.exports = function(source) { | |
this.cacheable && this.cacheable(); | |
var query = loaderUtils.parseQuery(this.query); | |
var args = []; | |
// apply?config=key => sourceFn(require('webpack.config').key) | |
if (typeof query.config === 'string') { | |
if (!query.config in this.options) |
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
###* | |
* Helper function which returns a reference to a value in an object hierarchy. | |
* Call with path to parent object if you wish to mutate a value in-place, as | |
* assignment on reference variables will only set the variable in the local scope. | |
* | |
* AngularJS: Available in 'app' module as 'pathToRef' constant. | |
* | |
* @param path {Array | String} Path components | |
* @param root {Object | Array} Root object to start at | |
* @param initIntermediary {Boolean} Initialize and continue on non-existant values (false = bail) |
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
gbump () { | |
what=${1:-patch} | |
echo "Bumping $what version and pushing to origin" | |
changed=$(git diff-index --name-only HEAD --) | |
[ -n "$changed" ] && git stash | |
git pull --rebase && npm version $what && git push && git push --tags | |
[ -n "$changed" ] && git stash pop | |
} |
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
var data = { | |
id: trackID(track), | |
uri: track, // spotify:track:... | |
artists: [ | |
{ name: 'Unknown', uri: 'spotify:artist:518rTAIFPwQjLUSi4Pdzzn' } | |
], | |
title: track, // track name (title) | |
requests: 1, // number of requests | |
requesters: [ // length == requests | |
{ user: 'Anonymous', url: 'http://', time: new Date() } |