Skip to content

Instantly share code, notes, and snippets.

@rturk
rturk / failover.sh
Last active November 29, 2023 10:48 — forked from Apsu/failover.sh
An example failover script for dual WAN, using a ping healthcheck and managing default routes appropriately
View failover.sh
#!/bin/bash
# Set defaults if not provided by environment
CHECK_DELAY=${CHECK_DELAY:-5}
CHECK_IP=${CHECK_IP:-1.1.1.1}
PRIMARY_IF=${PRIMARY_IF:-eno8303}
PRIMARY_GW=${PRIMARY_GW:-192.168.15.1}
# Cycle healthcheck continuously with specified delay
while sleep "$CHECK_DELAY"
@rturk
rturk / useCrisp.js
Created July 8, 2020 16:38
useCrisp - Load Crisp Chat with React App
View useCrisp.js
import { useEffect, useRef } from 'react';
import { useScript } from './useScript';
//This will generate a new number every hour
//Crisp has a terrible CDN handeling process, this forces to load last version every hour
const getDateSeconds = () => {
const date = new Date();
const time = date.getTime();
return Math.floor(time / 3600000);
@rturk
rturk / GTM_FORCE_reload.js
Last active August 15, 2018 18:49
GTM Force Reload Tag
View GTM_FORCE_reload.js
<script>
/*
This script will force reload of the page based on the harcoded version.
Create as tag and Use GTM to trigger execution.
*/
var GTMRELOADER_CURRENT_VERION = '1';
var GTMRELOADER_KEY_NAME = 'VERSION';
function canIUseLocalStorage(){
var test = 'test_ls_test';
@rturk
rturk / Redis FIFO writer to Postgres
Created April 12, 2017 21:03
Test - Redis FIFO writer to Postgres
View Redis FIFO writer to Postgres
import redis from "redis";
client = redis.createClient();
exitProcessor = false;
queueNext = () => {
process.nextTick(() => {
// Messages are pushed with RPUSH, making this a FIFO queue
client.blpop('queue', 1, queueFn);
@rturk
rturk / react-d3.jsx
Created October 5, 2016 00:20 — forked from gilbarbara/react-d3.jsx
React + D3 example
View react-d3.jsx
import React from 'react';
import { autobind } from 'core-decorators';
import d3 from 'd3';
import moment from 'moment';
import classNames from 'classnames';
import { getFirstDate } from 'utils/Consolidator';
import { shouldComponentUpdate } from 'utils/shouldUpdate';
import { classes, sort } from 'utils/Presentation';
import Money from 'utils/Money';
@rturk
rturk / index.js
Created May 30, 2016 00:38
RNRF custom navbar with pop
View index.js
'use strict';
import React, {Component} from "react";
import {StyleSheet, Text, View} from "react-native";
import Icon from 'react-native-vector-icons/FontAwesome';
import { Actions } from 'react-native-router-flux';
export default class ToolBar extends Component {
static contextTypes = {
drawer: React.PropTypes.object
@rturk
rturk / index.js
Last active March 20, 2020 18:49
RNRF Tabbar Icon Sample
View index.js
import React, {
Component,
PropTypes,
} from 'react';
import {
StatusBar,
Text,
View,
StyleSheet,
PixelRatio,
@rturk
rturk / gist:858c1afaee170a3a141adc7da652883e
Last active December 26, 2020 18:50
React Native Router Flux - Tab Bar with Icon
View gist:858c1afaee170a3a141adc7da652883e
//This is a Redacted version to be used as a benchmark/example for React Native Router Flux
import React, {
Component,
StatusBar,
Text,
View,
StyleSheet,
PixelRatio,
} from 'react-native';
@rturk
rturk / gist:01a2d43da94bb5290d7a8c7b332a2a79
Last active April 3, 2016 02:26
Simple Publish Message to AWS SNS Topic
View gist:01a2d43da94bb5290d7a8c7b332a2a79
/**
* Sends a Message to AWS topic
*/
import AWS from 'aws-sdk';
const message = {
test: "Test Message",
error: "Error test",
};
@rturk
rturk / imageSyncing.js
Created March 1, 2016 19:33 — forked from jice-lavocat/imageSyncing.js
AWS Lambda - S3 : Thumbnail creation
View imageSyncing.js
// dependencies
var async = require('async');
var path = require('path');
var AWS = require('aws-sdk');
var gm = require('gm').subClass({
imageMagick: true
});
var util = require('util');
// get reference to S3 client
var s3 = new AWS.S3();