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
#!/bin/bash | |
__randomWithRange() { | |
# http://www.tldp.org/LDP/abs/html/randomvar.html | |
# USAGE: __randomWithRange FLOOR CEILING | |
local number=0 #initialize | |
while [ "$number" -le $1 ] | |
do | |
number=$RANDOM | |
let "number %= $2" # Scales $number down within $RANGE. |
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
# Generated by iptables-save v1.4.21 on Wed Jul 8 15:12:54 2015 | |
*nat | |
:PREROUTING ACCEPT [0:0] | |
:INPUT ACCEPT [0:0] | |
:OUTPUT ACCEPT [0:0] | |
:POSTROUTING ACCEPT [0:0] | |
:DOCKER - [0:0] | |
-A PREROUTING -m addrtype --dst-type LOCAL -j DOCKER | |
-A OUTPUT ! -d 127.0.0.0/8 -m addrtype --dst-type LOCAL -j DOCKER | |
-A POSTROUTING -s 172.17.0.0/16 ! -o docker0 -j MASQUERADE |
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
#!/bin/bash | |
# Returns latest measurement from a series | |
# $1 = Series name | |
__getMeasurement() { | |
curl "http://weatherspot.us/db/query.php?db=weather&q=SELECT+temperature+FROM+${1}+LIMIT+1" 2>/dev/null | |
} | |
# Returns latest timestamp from a series | |
# $1 = Series name |
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
; Escape Key = {ESC} | |
; End Key = {END} | |
; Page Down = {PGDN} | |
; Page Up = {PGUP} | |
; For more: Google "Autoit Send" | |
[Hotkeys] | |
startKey={PGDN} | |
stopKey={PGUP} | |
[Duration] |
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
'use strict'; | |
function mastermind() { | |
// Requires | |
var fs = require('fs'); | |
var readline = require('readline'); | |
/// | |
// Members | |
var prompts = { | |
banner: function() { |
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
// Problem: How to make a "Loading" spinner or animation appear before a component is fully rendered? | |
// Solution: | |
// 1. Allow the component to render once and display a <LoadingSpinner /> component, | |
// and defer the change of `this.state.loading` until after component renders once | |
class SomethingWithLoadSpinner extends Component { | |
constructor(...args) { | |
super(...args); | |
this.state = { | |
loading: true |
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 tiny script to move channels around on the DiscordApp.com chat servers. | |
// | |
// Open up your console and paste in all the functions | |
// Then just call `moveChannelToTopByName` on the channel you want to pin to the top | |
function getIndexOfChannelByName(channel) { | |
var channelTextList = document.querySelectorAll('#guild-channels > ul:nth-child(2) span.channel-name') | |
return [].slice.call(channelTextList) | |
.map(elem => elem.innerHTML) |
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 handleKeydown() { | |
var unreadSelector = '.channel.channel-text.unread > a'; | |
var unreadIndex = 0; | |
var getUnread = () => document.querySelectorAll(unreadSelector); | |
var numUnread = getUnread().length; | |
return function (e) { | |
// Hotkey is CTRL + B (case insensitive) | |
if (e && e.ctrlKey && e.keyCode == 'B'.charCodeAt(0)) { | |
var newLength = getUnread().length; | |
var unreadDelta = numUnread - newLength; |
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
#!/bin/bash | |
function mkcomponent { | |
if [ ! -z "${1}" ] | |
then | |
if [[ $PWD == *"src" ]] | |
then | |
if [ ! -d "./components/${1}" ] | |
then | |
echo 'Making Component' ${1} | |
mkdir ./components/${1} |
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
/* If you have a React event handler and you want to pass it more than just the `event` argument, you can | |
* do so in the following ways. | |
*/ | |
// using an inline Wrapper | |
handleEvent (someData, event) { | |
// ... | |
} | |
<MyComponent onEvent={(event) => this.handleEvent('someData', event)} /> |
OlderNewer