Skip to content

Instantly share code, notes, and snippets.

Taylor Brazelton Ryanb58

Block or report user

Report or block Ryanb58

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
View full-width.md

How do you make a DIV or other HTML item full width of the screen? This overrides parent margins + paddings.

.full-width {
  width: 100vw;
  position: relative;
  left: 50%;
  right: 50%;
  margin-left: -50vw;
@Ryanb58
Ryanb58 / profile.md
Last active Oct 22, 2018
How to profile a Node.JS application and Visualize/debug the results.
View profile.md

Profile your node app:

node --prof-process app.js

Visualize the data by opening chrome and going too:

chrome://tracing

@Ryanb58
Ryanb58 / monkey_patch.md
Created Sep 28, 2018
Python monkey patch example.
View monkey_patch.md

Having an issue deep within django and realize we wanted a debugger. So we monkey patched the methods.


def fake_prep_for_like_query(self, x):
    """Prepares a value for use in a LIKE query."""
    from django.utils.encoding import force_text
    return force_text(x).replace("\\", "\\\\").replace("%", "\%").replace("_", "\_")

def fake_get_db_prep_lookup(self, lookup_type, value, connection,
@Ryanb58
Ryanb58 / change-tracker.py
Created Sep 25, 2018
Django Model Change Tracker
View change-tracker.py
from django.forms.models import model_to_dict
class ModelChangesMixin(object):
"""
Mixin to tracks changes to your models.
"""
def __init__(self, *args, **kwargs):
super(ModelChangesMixin, self).__init__(*args, **kwargs)
self.__original = self._data
View mac-apps.md
@Ryanb58
Ryanb58 / diff.md
Created Aug 15, 2018
Custom SysCTL Changes on DrPepper
View diff.md

--- /etc/sysctl.conf 2018-03-18 19:29:11.085404567 -0400 +++ /etc/sysctl.conf.dpkg-new 2018-01-17 17:35:48.000000000 -0500 @@ -58,5 +58,20 @@

Log Martian Packets

#net.ipv4.conf.all.log_martians = 1

-fs.inotify.max_user_watches=524288

+################################################################### +# Magic system request Key

@Ryanb58
Ryanb58 / install.md
Last active Jun 26, 2019
How to install telnet into a alpine docker container. This is useful when using the celery remote debugger in a dev environment.
View install.md
>>> docker exec -it CONTAINERID /bin/sh
/app # telnet
/bin/sh: telnet: not found

/app # apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz
v3.7.0-243-gf26e75a186 [http://dl-cdn.alpinelinux.org/alpine/v3.7/main]
v3.7.0-229-g087f28e29d [http://dl-cdn.alpinelinux.org/alpine/v3.7/community]
@Ryanb58
Ryanb58 / profile.py
Created May 22, 2018
Profile a section of code in python.
View profile.py
import time
import cProfile, pstats, StringIO
import os
import shutil
import tempfile
start_time = time.time()
pr = cProfile.Profile()
pr.enable()
View python-remote-debugger.md

PROGRAM WITH REMOTE DEBUGGER:

import time
from celery.contrib import rdb

while(True):
    time.sleep(1)
    rbd.set_trace()
    a = 1 + 3
View get_active_admins.py
import csv
from ftphosting.ftp.models import *
active_sites = [2,18,45,55,67,98,125,130,133,134,136,137,139,154,240,257,314,334,361,452,626,639,644,660,674,680,729,761,826,895,911,922,938,976,1039,1051,1054,1059,1074,1158,1181,1185,1194,1223,1241,1332,1361,1379,1396,1452,1455,1461,1493,1526,1556,1567,1608,1646,1647,1691,1744,1761,1795,1796,1820,1825,1851,1855,1856,1858,1874,1885,1911,1920,1928,1934,1956,1978,1993,2000,2011,2012,2097,2098,2129,2131,2147,2200,2238,2241,2245,2247,2257,2309,2349,2357,2366,2429,2449,2456,2485,2500,2512,2593,2609,2653,2654,2684,2698,2710,2716,2735,2807,2841,2857,2889,2897,2914,2935,2956,2959,2967,3052,3061,3065,3066,3081,3086,3102,3190,3230,3264,3270,3280,3290,3312,3351,3387,3395,3407,3427,3453,3454,3481,3524,3550,3606,3723,3730,3733,3748,3759,3821,3844,3906,3918,3920,3943,3946,3981,3984,4015,4026,4123,4128,4134,4147,4173,4179,4247,4272,4273,4308,4342,4356,4370,4381,4409,4434,4441,4466,4486,4558,4610,4672,4678,4689,4691,4718,4745,4746,4747,4754,4777,4793,4812,4845,4864,4876,4877,4
You can’t perform that action at this time.