Skip to content

Instantly share code, notes, and snippets.

View mecampbellsoup's full-sized avatar

Matt Campbell mecampbellsoup

View GitHub Profile
@mecampbellsoup
mecampbellsoup / diff.log
Created June 25, 2024 18:47
Old and new cloud-console repo diff
% diff --brief --recursive cloud-console cloud-console-new 24-06-25 - 14:46:12
Only in cloud-console/.git: COMMIT_EDITMSG
Only in cloud-console/.git: FETCH_HEAD
Only in cloud-console/.git: ORIG_HEAD
Files cloud-console/.git/config and cloud-console-new/.git/config differ
Only in cloud-console/.git/hooks: commit-msg
Only in cloud-console/.git/hooks: pre-commit
Files cloud-console/.git/index and cloud-console-new/.git/index differ
Only in cloud-console/.git/info: refs
Files cloud-console/.git/logs/HEAD and cloud-console-new/.git/logs/HEAD differ
@mecampbellsoup
mecampbellsoup / condense-list-to-querystring-param.md
Last active December 1, 2020 22:32
Efficiently condense an unordered list of integers to an HTTP querystring param

Condense a List

When requesting resources from a JSONAPI-compliant API, you can request a filtered subset of the resource by including a request parameter filter, e.g.:

GET /api/v1/jobs?filter[id]=1,2

In this example you are requesting, in effect, the following SQL query:

class File:
file_count = 0
def __init__(self, name):
self.file_name = name
# self.file_count = 1
self.__class__.file_count += 1
f1 = File(__file__)
f2 = File(__file__)

Keybase proof

I hereby claim:

  • I am mecampbellsoup on github.
  • I am mattysoup (https://keybase.io/mattysoup) on keybase.
  • I have a public key ASA3XmykByIFFns5PQpCZI-4nh_ffWbmqy3jTZjyWmO_mQo

To claim this, I am signing this object:

@mecampbellsoup
mecampbellsoup / transfers_for_wallet.json
Created June 15, 2018 21:25
JSON dump of GET wallet transfers BitGo API endpoint.
(Pdb) print json.dumps(transaction_history_json, indent=4, sort_keys=True)
{
"coin": "bch",
"transfers": [
{
"coin": "bch",
"confirmations": 124,
"confirmedTime": "2018-06-14T22:09:40.073Z",
"createdTime": "2018-06-14T21:57:57.225Z",
"date": "2018-06-14T22:09:40.073Z",
require 'rspec/autorun'
require 'pry'
def two_sum(nums, target)
# for each integer in the input list
# calculate the sum with every other member
nums.each_with_index do |outer_n, outer_index|
nums.detect.with_index do |inner_n, inner_index|
next if inner_index == outer_index
return [outer_index, inner_index] if outer_n + inner_n == target
8:37:06 › python ob-watcher.py
Traceback (most recent call last):
File "/usr/local/Cellar/python@2/2.7.14_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 539, in <module>
main()
File "/usr/local/Cellar/python@2/2.7.14_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 522, in main
known_paths = addsitepackages(known_paths)
File "/usr/local/Cellar/python@2/2.7.14_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 302, in addsitepackages
for sitedir in getsitepackages():
File "/usr/local/Cellar/python@2/2.7.14_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 290, in getsitepackages
elif os.sep == '/':
@mecampbellsoup
mecampbellsoup / keybase.md
Created April 11, 2018 16:53
Keybase proof of ownership of my GitHub account

Keybase proof

I hereby claim:

  • I am mecampbellsoup on github.
  • I am mattysoup (https://keybase.io/mattysoup) on keybase.
  • I have a public key ASDjfAgxxec_cVhxKJuv3AwUVzi59LPpGUTlUpc97gK6pAo

To claim this, I am signing this object:

# Write a Python program that prints the SHA256 hash of "Hello World" in hexadecimal.
import hashlib
import codecs
def sha256(s):
encoded = s.encode()
hash_object = hashlib.sha256(encoded)
print(hash_object.digest())
return(hash_object.digest())
// Deps
var yaml = require('js-yaml');
var fs = require('fs');
var moment = require('moment');
var endDate = moment();
var startDate = moment().subtract(1, 'months');
var startDateUnix = startDate.unix();
var endDateUnix = endDate.unix();