This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# just show the IP address | |
% dig <DNS_NAME> +short |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// types and literals | |
// defines a new type (note - this is not a type alias, type aliases are a different thing) | |
type Thing int32 | |
// this function only accepts arguments of type Thing, int32 arguments are not allowed by the compiler | |
func justThings(t Thing) { | |
// do stuff | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# filter tests by name (works for standalone test functions or method names on a test class) | |
# | |
# pytest <test_file.py> -k test_foo | |
# pytest <test_file.py> -k 'test_foo or test_bar' | |
# run the same test multiple times with different parameters | |
@pytest.mark.parametrize("p1, p2", [(1, 2), (3, 4), (5,6)]) | |
def test_foo(p1, p2): | |
assert bar(p1) == p2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# debugging | |
import pdb | |
pdb.set_trace() | |
# override a class method in a subclass (Python 2.x) | |
class Foo(object): | |
@classmethod | |
def baz(cls, x): | |
return x + 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Creating an Animated Gif Screen Recording | |
1. CMD+SHIFT+5 -> choose "Record Selected Portion" | |
2. Position box of region of screen being recorded | |
3. Hit Record | |
4. CMD+SHIFT+5 -> hit "Stop" button | |
4. Use Gifski application to convert movie file into animated gif | |
Find out which process is listening on <PORT> | |
sudo lsof -nP -i4TCP:<PORT> | grep LISTEN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Excon exposes defaults for injecting configuration parameters | |
Excon.defaults[:mock] = true | |
Excon.defaults.delete(:mock) | |
# Excon stubbing | |
# first parameter - Hash of expected request attributes (all are optional) | |
# second parameter - Hash of response attributes | |
# if second parameter is omitted, a block can be provided a Proc object | |
Excon.stub({ method: :post, path: exp_path, headers: exp_headers, query: exp_query, body: exp_body }, { status: 200 }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
To _not_ transitively update the dependencies of a gem when doing a bundle update, use --conservative | |
% bundle update --conservative <gem> | |
Install gems to a different path | |
bundle install --path . | |
Override a deployment packaged bundle (i.e. add new gems to a bundle already packaged for deployment) | |
bundle install --no-deployment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Install | |
% npm install -g typescript | |
Start a new node.js project | |
% npm init | |
% npm install typescript -s | |
Add "tsc" script to package.json | |
"scripts": { | |
"tsc": "tsc" |
NewerOlder