Skip to content

Instantly share code, notes, and snippets.

View bryder's full-sized avatar

Bill Ryder bryder

View GitHub Profile
#!/usr/bin/env ruby
## disconnect
# ./disconnect.rb -u yourusername
#
# This is a command-line utility for the bulk-downloading of run data from
# the connect.garmin.com web application, which has lackluster export
# capabilities.
#
#!/usr/bin/env python3
import http.client
http.client.HTTPConnection.debuglevel = 0
#import urllib.request
from urllib.request import Request, urlopen, HTTPCookieProcessor
from urllib.parse import urlencode
import argparse
import sys,os
# SSH Agent Functions
# Mark Embling (http://www.markembling.info/)
#
# How to use:
# - Place this file into %USERPROFILE%\Documents\WindowsPowershell (or location of choice)
# - Import into your profile.ps1:
# e.g. ". (Resolve-Path ~/Documents/WindowsPowershell/ssh-agent-utils.ps1)" [without quotes]
# - Enjoy
#
# Note: ensure you have ssh and ssh-agent available on your path, from Git's Unix tools or Cygwin.
@bryder
bryder / gist:d1c981bd60e9657a594c
Last active August 29, 2015 14:10
short ways to do file I/O in python
sys.stderr.write(open("/tmp/filename").read())
cmdline = open("/proc/cmdline").read()
with open("/dev/blah","r") as f:
for l in f: # l in f means read each line
print l
try:
with open(FILENAME, 'w') as f:
@bryder
bryder / gist:13fba18fcaa1d8629cf5
Created December 15, 2014 03:03
swap caps lock and control on windows
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,03,00,00,00,3A,00,1D,00,1D,00,3A,00,00,00,00,00
@bryder
bryder / gist:f4c4372f5bd5f7f691e7
Created December 16, 2014 19:46
Make rdesktop send a control key when caps lock is pressed
this was true for ubuntu 12.04
mkdir -p ~/.rdesktop/keymaps
cd /usr/share/rdesktop/keymaps/
cp en-us common ~/.rdesktop/keymaps/
edit ~/.rdesktop/keymaps/common
change
@bryder
bryder / ps_git_setup
Created January 6, 2015 02:08
Powershell with PSreadline and some ssh-agent stuff - good for git mainly.
$a = (Get-Host).PrivateData
$a.ErrorForegroundColor = "Yellow"
# (new-object Net.WebClient).DownloadString("http://psget.net/GetPsGet.ps1") | iex
import-module PsGet
install-module PsUrl
install-module PsReadLine
Set-PSReadlineOption -EditMode Emacs
@bryder
bryder / curl_get_data-urlencode_sample
Created April 9, 2015 05:29
curl way to use --data-urlencode The -G is crucial. -X GET does not work - the where clause does not get passed
curl -sS -G --data- { "_id": { "$in": [ "55106b4797b4502d68776cb2","55106b4797b4502d68776cc4","55106b4797b4502d68776cc7","55106b4897b4502d68776cca","55106b4797b4502d68776cc1","55106b4897b4502d68776ccd","55106b4797b4502d68776cb5","55106b4797b4502d68776cb8","55106b4797b4502d68776cbb","55106b4797b4502d68776cbe" ]}} , { "name": {"$in": [ ]} }]}' http://localhost:5001/node_hateoas_off | jq '._items[] | .name'
@bryder
bryder / py.test_tmpdir_usage
Last active April 27, 2021 13:23
How to use py.test tmpdir
# https://pytest.org/latest/tmpdir.html
# http://py.readthedocs.org/en/latest/path.html
# Using in conftest.py
@pytest.fixture(autouse=True)
def a_tmp_filename(tmpdir):
p = tmpdir.join("filename")
p.write("some stuff\n")
return str(p) # str(p) returns the full pathname you can use with normal modules
@bryder
bryder / how_to_bulk_post_to_python_eve
Created April 16, 2015 05:37
Posting json from a file to python-eve. Uses jq as well to strip metadata
curl -Ss 'thing:5001/facts?max_results=10000' | tee facts_response.json | jq '[._items[] | del(._created) | del(._links) | del(._updated) | del(._id) | del(._etag) ]' > facts_to_post.json
curl -H 'Content-Type: application/json' -X POST -d@facts_to_post.json http://localhost:5001/facts > post_facts.results