Skip to content

Instantly share code, notes, and snippets.

View KyleJamesWalker's full-sized avatar
💃
Cha Cha Cha!

Kyle James Walker (he/him) KyleJamesWalker

💃
Cha Cha Cha!
View GitHub Profile
@KyleJamesWalker
KyleJamesWalker / Makefile
Created March 16, 2018 21:33
Makefile Prompts
something:
$(call prompt_run,echo "FUN!")
# Prompt the user to continue and exit the script if they choose no
define prompt_continue
@read -p "Contine and $(1)? " -n 1 -r REPLY; echo "\n"; \
if [[ $$REPLY =~ ^[Nn]$$ ]]; then exit 1; fi
endef
# Prompt the user to run a given command, and keep going if they choose no
@KyleJamesWalker
KyleJamesWalker / README.md
Created March 20, 2018 19:57
Protect Master Branch

How to protect master

  • Run:git config --global core.hooksPath ~/githooks
  • Create hooks folder: mkdir ~/githooks
  • Copy pre-push to the ~/githooks folder
  • Set executable: chmod +x ~/githooks/pre-push
# Every 4 Frames via find and a file
echo "Enter Video Name for folder: ";read VSRC; find . -type f -name '*.JPG' | sort | awk 'NR%4 == 1 {print "file \x27"$1"\x27"}' > $VSRC.txt; ffmpeg -f concat -safe 0 -i $VSRC.txt -c:v libx264 -b:v 10M -maxrate 10M -bufsize 4M -vf scale=-1:1080,format=yuv420p -r 30 $VSRC.mp4
@KyleJamesWalker
KyleJamesWalker / example_extract.py
Created August 13, 2018 21:02
Find Swagger/OpenApi Spec Examples
import yaml
def iter_cases(root, obj=None, template=None):
"""Find and yield example responses in the spec
Since examples are free-form as mentioned in the following
https://swagger.io/docs/specification/adding-examples/
This function assumes each example resonse is key by a unique name,
@KyleJamesWalker
KyleJamesWalker / __init__.py
Created September 5, 2018 22:37
tasks - Invoke Fun
"""Example Build File"""
from invoke import task
from tasks.zefr_template import namespace
def build(ctx):
"""Build the image"""
print("Building Overridden!")
@KyleJamesWalker
KyleJamesWalker / README.md
Created October 18, 2018 21:39
Files Changed Since Last PR

Files Changed Since Last PR

The Jenkins changeset function didn't seem to work predicably enough, as described in How to access Changelogs in a Pipeline Job? So instead I wrote this quick invoke script to pull the changes directly from the git logs. This assumes changes are done in PRs, so when on run on master the task will look for all changes 2 PRs back, but when developing off master it will look for the first PR it finds.

This of course will have issues, if you've merged a PR into another branch and then merged the branch, but for my use case this should be fine.

@KyleJamesWalker
KyleJamesWalker / my_prs.py
Last active October 26, 2018 19:25
GitHub PR Review Lookup
#!/usr/bin/env python
# coding: utf-8
"""Find your PRs
Builds a list of PRs you've worked on over the last xxx (year, month, week)
Example Web Search (https://github.com/pulls):
* `is:pr author:a created:>2017-11-01`
* `is:pr mentions:kylejameswalker commenter:kylejameswalker created:>2017-11-01`
@KyleJamesWalker
KyleJamesWalker / README.md
Created January 31, 2019 19:34
Setup.py Install a Fork

Setup.py Hacking

To get this to work without updating your forked version number, you must lie in the dependency_links section, and then unpin the version that you want installed. This makes it think that the branch is version current linux time (int) in the lookup but will acutally install whatever version it finds in the fork.

Note: You also will likely need to clear your pip cache so it won't install the version it finds in pypi, I think doing the current time will keep it from using the pypi version, so just make sure you keep an eye on the logs when you install your library, and that it says "Cloning ..../KyleJamesWalker/example_lib

@KyleJamesWalker
KyleJamesWalker / README.md
Created July 9, 2019 02:50
Huawei Modem DHCP Details
You can get the string manually with the following:
screen /dev/ttyUSB0
ATZ
AT^NDISDUP=1,1,"h2g2"
AT^DHCP?

# This responds with something like:
#  ^DHCP:11111111,22222222,33333333,44444444,55555555,66666666,100000000,50000000
# 
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
.tnr {
font-family: "Times New Roman", Times, serif;
}
.logo {
position: relative;