Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View unrelentingfox's full-sized avatar
🤓
Learning

Dustin unrelentingfox

🤓
Learning
  • Clearwater Analytics
  • USA
View GitHub Profile
@unrelentingfox
unrelentingfox / facebook-ad-insights.gs
Created June 23, 2021 06:37
An example of how you can use the facebook api to populate a google sheet.
// https://www.benlcollins.com/apps-script/api-tutorial-for-beginners/
function main() {
let accessToken = "YOUR_ACCESS_TOKEN"
let fields = "account_id,account_name,date_start,date_stop,impressions,spend"
let accountIds = getAccountIds(accessToken)
let jsonData = getAdInsights(accountIds, fields, accessToken)
let sheet = SpreadsheetApp.getActiveSheet()
let dataKeys = Object.keys(jsonData[0])
let dataArray = convertToArray(dataKeys, jsonData)
dataArray.unshift(dataKeys)
@unrelentingfox
unrelentingfox / kraken-avg-cost.py
Last active June 18, 2022 19:25
A python script that queries all of your historic trades and calculates the average price you purchased coins at. This was a quick script based on the examples found here: https://docs.kraken.com/rest/. I am open to feedback!!
#!/usr/local/bin/python3
import base64
import hashlib
import hmac
import json
import os
import requests
import time
import urllib.parse
@unrelentingfox
unrelentingfox / locker.sh
Last active April 22, 2021 01:05
Quick 7z based directory locking script. I created this because I want an easy way to quickly encrypt and decrypt a directory.
#!/bin/bash
USAGE_TEXT="Usage: locker.sh <command> target
Commands:
lock Expects target to be a directory. This directory will be compressed
with a password using 7z removing the original directory afterwards.
unlock Expects target to be a 7z compressed file. Unlocks the given
@unrelentingfox
unrelentingfox / nvim-update-to-tag.sh
Last active April 19, 2021 20:57
A script to use for dynamically installing a tag version of Neovim.
#!/bin/bash
if [ -z "$1" ]
then
TAG="stable"
else
TAG=$1
fi
TMP_FILE=nvim-macos.tar.gz
# For use when you need trace level logs
status = error
name = PropertiesConfig
filters = threshold
filter.threshold.type = ThresholdFilter
filter.threshold.level = trace
appenders = console
# delete till end of line
dt$
find main | grep -P 'Rule.java$' > testfile
sed 's/main/test/g' testfile | sed 's/Rule\.java/RuleTest\.java/g' > final
cat final | xargs -L 1 mkdir -p
alias pcat='pygmentize -g'
alias chrome='google-chrome-stable'
alias gfr='git svn fetch; git svn rebase'
alias work='cd ~/workspace/'
alias home='cd ~'
alias bprops='vim /etc/cwan/titan/basic.properties'
alias bpropsd2='vim /etc/cwan/titan/d2/basic.properties'
alias rm='rm -v'
alias mv='mv -v'
alias cp='cp -v'
<code_scheme name="Titan (hand entered)" version="173">
<option name="SOFT_MARGINS" value="120" />
<JavaCodeStyleSettings>
<option name="SPACE_AROUND_TYPE_BOUNDS_IN_TYPE_PARAMETERS" value="false" />
<option name="BLANK_LINES_AROUND_INITIALIZER" value="0" />
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
</JavaCodeStyleSettings>
<SqlCodeStyleSettings version="2">
<option name="ALIAS_CASE" value="1" />
@unrelentingfox
unrelentingfox / NullSafe.java
Created July 27, 2018 20:22
Useful java safe comparison helper functions
private static boolean safeEquals(Integer first, Integer second) {
return (first == null && second == null) || (first != null && first.equals(second));
}
private static boolean safeContains(String str, String substr) {
return str != null && str.contains(substr);
}
private static <K> List<K> safe(List<K> list) {
return list != null ? list : Collections.EMPTY_LIST;