Skip to content

Instantly share code, notes, and snippets.

View Slurpgoose's full-sized avatar
🦆

Slurpgoose

🦆
  • Bakkt
  • Atlanta, GA
View GitHub Profile
@Slurpgoose
Slurpgoose / memory_allocation.sh
Created March 19, 2021 15:41
check and restart process if server memory utilization is too high. this is designed to be a quick fix until the larger problem is diagnosed
#!/bin/sh
percent_allowed=85
memory_too_high(){
MAXMEM=$(free -m | grep -oP '\d+' | head -n 1) #total available memory
USEDMEM=$(free -m | awk 'NR==2{printf "%s", $3,$2,$3*100/$2 }') # memory used
PERCENTAGE=$(echo "scale=8; ($USEDMEM / $MAXMEM) * 100" | bc) # get percentage
P_INT=${PERCENTAGE%.*} # convert from float to int
@Slurpgoose
Slurpgoose / redisNode.js
Last active September 29, 2020 17:28
Manage node state with redis.
var redis = require('redis');
var client = redis.createClient(); //redis.createClient(port, host, options)
const key = 'test'; //redis key name
//Error handling
client.on("error", (err) => {
console.log(`Error: ${err}`);
});
@Slurpgoose
Slurpgoose / Error1
Last active April 23, 2020 03:56
Plot Candle OHLC Data
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/pandas/core/indexes/base.py", line 3078, in get_loc
return self._engine.get_loc(key)
File "pandas/_libs/index.pyx", line 140, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/index.pyx", line 162, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/hashtable_class_helper.pxi", line 1492, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas/_libs/hashtable_class_helper.pxi", line 1500, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'Open'
During handling of the above exception, another exception occurred:
@Slurpgoose
Slurpgoose / socket.js
Last active March 22, 2020 05:28
Connect to Coinbase WS
const CoinbasePro = require('coinbase-pro');
const subscriptions = ['BTC-USD', 'ETH-EUR'];
let groups = {};
let beat = {};
startCoinbaseSocket = (subscriptions, groupid) => {
let websocket = new CoinbasePro.WebsocketClient(
subscriptions,
'wss://ws-feed.pro.coinbase.com',
{
@Slurpgoose
Slurpgoose / mysqlConnector.js
Last active January 3, 2023 19:25
A method to wrap your node application with a mysql pool.
/*
Created with refrence from
https://gist.github.com/binki/52662f18ae6fc89b18b020b89aa4e1cd
http://www.madhur.co.in/blog/2016/09/05/nodejs-connection-pooling.html
*/
const mysql = require('mysql'); // import
const pool = mysql.createPool({ // create pool instance
host: "*",
user: "*",