Skip to content

Instantly share code, notes, and snippets.

Ryan Wilson-Perkin ryanwilsonperkin

Block or report user

Report or block ryanwilsonperkin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ryanwilsonperkin
ryanwilsonperkin / fast_vagrant_ssh.md
Created May 3, 2017
Faster SSHing into vagrant
View fast_vagrant_ssh.md

Running vagrant ssh can be slow because it boots up a ruby process, does a bunch of analysis to determine your ssh parameters, and then actually invokes the command. If you want a faster login, try the following:

# Compute the ssh parameters, append them to your global ssh config file
# The --host parameter specifies what you want the vagrant machine to be called
vagrant ssh-config --host vagrant >> ~/.ssh/config

# Now just ssh into that machine directly
ssh vagrant
@ryanwilsonperkin
ryanwilsonperkin / decorators.py
Last active Nov 23, 2017
Different types of decorators
View decorators.py
# Regular decorator
def decorator(f):
def wrapped(*args, **kwargs):
print('Before')
result = f(*args, **kwargs)
print('After')
return result
return wrapped
# Regular decorator usage
@ryanwilsonperkin
ryanwilsonperkin / convox_env_check.sh
Created Dec 20, 2017
Check all applications in a convox rack for environment variables (name or value) containing a search_query
View convox_env_check.sh
rack=$1
search_query=$2
if [ -z "$rack" ] || [ -z "$search_query" ]; then
echo "usage: $0 rack search_query"
exit 1
fi
apps=$(convox apps --rack $rack | grep -v STATUS | cut -f1 -d' ')
@ryanwilsonperkin
ryanwilsonperkin / github_repos.py
Last active Jan 9, 2018
Use the GitHub API to generate a CSV or your organization's repositories.
View github_repos.py
#!/usr/local/bin/python
"""
Generate a CSV file of your organization's GitHub repositories.
Results in a CSV file with the following columns:
- name: The name of the repository
- private: True if this is a private repository, else False
- fork: True if this repository is the result of a fork, else False
- created_at: The datetime this repository was created
- updated_at: The datetime this repository was last updated
@ryanwilsonperkin
ryanwilsonperkin / create_test_list.py
Created Mar 5, 2018
Reads Xunit XML files and prints the (sorted) test names to stdout.
View create_test_list.py
#!/usr/local/bin/python
"""
Reads Xunit XML files and prints the (sorted) test names to stdout.
usage: python create_test_list.py file [file...]
"""
import sys
import xml.etree.ElementTree as ET
def xmlToList(filename):
@ryanwilsonperkin
ryanwilsonperkin / example_private.py
Last active Mar 11, 2018
pipenv-test-private-package
View example_private.py
import sys
sys.stdout.write('This is a private package\n')
@ryanwilsonperkin
ryanwilsonperkin / example_public.py
Last active Mar 11, 2018
pipenv-test-public-package
View example_public.py
import sys
sys.stdout.write('This is a public package\n')
@ryanwilsonperkin
ryanwilsonperkin / coredump
Created Mar 14, 2018
Debugging npm failure on Alpine Linux on EC2 C5 instance
View coredump
Program terminated with signal SIGSEGV, Segmentation fault.
warning: Unexpected size of section `.reg-xstate/26' in core file.
#0 __cp_end () at src/thread/x86_64/syscall_cp.s:29
29 src/thread/x86_64/syscall_cp.s: No such file or directory.
[Current thread is 1 (LWP 26)]
(gdb) bt
#0 __cp_end () at src/thread/x86_64/syscall_cp.s:29
#1 0x00007fd6161eecd8 in __syscall_cp_c (nr=202, u=<optimized out>, v=<optimized out>, w=<optimized out>, x=<optimized out>, y=<optimized out>,
z=0) at src/thread/pthread_cancel.c:35
@ryanwilsonperkin
ryanwilsonperkin / update.py
Created Apr 6, 2018
Update relative imports in JS files to be absolute based on current path
View update.py
import os
import re
import sys
ROOT_DIR = 'project-name'
PATTERN = re.compile(
"""(?P<prefix>.*from *['"])"""
"""(?P<path>\..*)"""
"""(?P<suffix>['"].*)"""
)
@ryanwilsonperkin
ryanwilsonperkin / component.js
Last active Aug 14, 2018
A HOC proposal for injecting tracking of events.
View component.js
import React from 'react';
import withTracking from 'withTracking';
export class MyLink extends React.Component {
static propTypes = {
text: PropTypes.string,
href: PropTypes.string,
track: PropTypes.func,
};
You can’t perform that action at this time.