Skip to content

Instantly share code, notes, and snippets.

@pl12133
pl12133 / fake_data_scheduler.sh
Created July 1, 2015 00:47
Fake Data Scheduler script, example of POSTing data directly to the InfluxDB HTTP API
#!/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.
# 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
@pl12133
pl12133 / notify_no_data.sh
Created July 24, 2015 02:27
Check the last time a influxDb Series was updated
#!/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
@pl12133
pl12133 / config.ini
Created October 11, 2015 19:34
A simple timer written in AutoIt to make a noise after a countdown.
; Escape Key = {ESC}
; End Key = {END}
; Page Down = {PGDN}
; Page Up = {PGUP}
; For more: Google "Autoit Send"
[Hotkeys]
startKey={PGDN}
stopKey={PGUP}
[Duration]
@pl12133
pl12133 / fallout_hacking_game
Created October 30, 2015 04:45
Daily Programmer challenge 2015-10-28
'use strict';
function mastermind() {
// Requires
var fs = require('fs');
var readline = require('readline');
///
// Members
var prompts = {
banner: function() {
// 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
// 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)
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;
#!/bin/bash
function mkcomponent {
if [ ! -z "${1}" ]
then
if [[ $PWD == *"src" ]]
then
if [ ! -d "./components/${1}" ]
then
echo 'Making Component' ${1}
mkdir ./components/${1}
/* 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)} />