Skip to content

Instantly share code, notes, and snippets.

@stucka
stucka / BackupPANDA.py
Created June 6, 2019 20:17
Download data from PANDA install -- something something news data appliance
import requests # External dependency
from tqdm import tqdm # External dependency
import json
username = "someguy@something.com"
apikey = "abcdefghijklmnopqrstuvwxyz01234567890123"
baseurl = "http://something.compute-1.amazonaws.com"
urlsuffix = f"?format=json&email={username}&api_key={apikey}"
@stucka
stucka / fixedwidthconversion.py
Last active November 14, 2019 19:58
Python -- better parsing of fixed-width data
# Preview your column widths easier with regex101.com -- makes it so much easier
from collections import OrderedDict
headers = OrderedDict([
("id", 5),
("name", 25),
("attribute", 8)
])
myregex = ""
@stucka
stucka / index.html
Created May 18, 2019 02:01
XO's wedding
<!DOCTYPE html>
<html>
<body onload="dosomething()">
<center>
<font size="30">On Feb. 6, XOofXOs wrote:</font><br clear>
<blockquote class="twitter-tweet" data-conversation="none" data-lang="en"><p lang="en" dir="ltr">THIS YEAR</p>&mdash; I&#39;m YOUR XO (@XOofXOs) <a href="https://twitter.com/XOofXOs/status/1093260909219381248?ref_src=twsrc%5Etfw">February 6, 2019</a></blockquote>
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
@stucka
stucka / index.html
Last active April 4, 2019 02:13
tomheartstanks dip calculator
<!DOCTYPE html>
<html>
<body onload="dosomething()">
<p id="demo"></p>
<script>
function dosomething() {
var newdate = new Date();
var now = newdate.getTime();
@stucka
stucka / ntsbcsv.py
Last active March 24, 2019 12:14
Turn NTSB airplane crash database "CSV" into usable airplane accident / crash data with actual working CSV
import requests
import csv
import re
hosturl = "http://app.ntsb.gov/aviationquery/Download.ashx?type=csv"
targetraw = "ntsbdb.raw"
targetcsv = "ntsbdb.csv"
r = requests.get(hosturl)
@stucka
stucka / gist:2973d0702f05003c5061e57b3df29f70
Created December 10, 2018 22:26
Burn git to the ground, keep only latest commit, shrink size
Burn git to the ground, keep only latest commit, shrink size:
# Adapted from https://stackoverflow.com/questions/9683279/make-the-current-commit-the-only-initial-commit-in-a-git-repository
git checkout --orphan newBranch
git add -A # Add all files and commit them
git commit
git branch -D master # Deletes the master branch
git branch -m master # Rename the current branch to master
git gc --aggressive --prune=all # remove the old files
git push -u -f origin master # Force push master branch to github
git gc --aggressive --prune=all # remove the old files
@stucka
stucka / atgms.txt
Last active December 7, 2018 01:24
Light vehicle-mounted ATGMs against heavy armor
Reading list from Sasha Maggio
?? author, possibly TASS? 2016-12-10, ArmyRecognition.com
Analysis Russian Afganit active protection system is able to intercept uranium tank ammunition TASS 11012163
https://www.armyrecognition.com/weapons_defence_industry_military_technology_uk/analysis_russian_afganit_active_protection_system_is_able_to_intercept_uranium_tank_ammunition_tass_11012163.html
Kyle Mizokami, 2017-11-01, The National Interest
Here Is How Russia Is Making Old Tanks Deadly Tools of War
https://nationalinterest.org/blog/the-buzz/here-how-russia-making-old-tanks-deadly-tools-war-22995
@stucka
stucka / gist:3f7e69b8bec748e95590f5c4a04a8e67
Last active December 6, 2018 14:46
Get story ID from a NewsCycle Content file / NCC bookmark
Highlight the long ugly bit of code that starts with "javascript" and ends with an ungodly mess of punctuation marks.
Hit Control-C to copy.
javascript:(function(){var thingyfeedurl = new URLSearchParams(__gh__coreData.pageData.buckets[0].feedURL).get('lopenr');var thingyimgurl = document.querySelectorAll('meta[property="og:image"]')[0].content.split('/AR-')[1].split(".jpg")[0];var thingymessage = "Story ID may be: " + thingyfeedurl;if(thingyimgurl != thingyfeedurl){thingymessage += "\r\nBut could be: " + thingyimgurl};if(window.location.href.split("/")[3].toLowerCase()=="zz"){thingymessage+="\r\nMake sure you look under site code ZZ with that ID"};alert(thingymessage);})();
Now you need to make a new bookmark.
In Chrome: Control-Shift-O (like Oscar). Three dots in top-left corner; New bookmark. For name of bookmark, try, whatever, "Find NCC story ID" or something. For URL, click in the box and hit Control-V to paste. Once you have the bookmark you can drag it to your bookmark bar, if you use one.
@stucka
stucka / python startup.txt
Last active May 4, 2024 23:40
Set up a new Python
My Python initial setup:
python -m pip install --upgrade pip
Is it sqwaking about managed configuration? If you're on Unix and feeling dumb:
cd /.config
mkdir pip
cd pip
nano pip.conf
...
Add this:
@stucka
stucka / timestamp.py
Created November 28, 2018 20:12
Easy timestamp in Python
def timestamp():
import datetime
return(datetime.datetime.strftime(datetime.datetime.now(), "%Y-%m-%dT%H:%M:%S"))