Skip to content

Instantly share code, notes, and snippets.

Avatar

Taylor Brazelton Ryanb58

View GitHub Profile
@Ryanb58
Ryanb58 / main.md
Created Nov 17, 2020
Who Is Using Your Webcam?
View main.md

Recently I've noticed a green dot next to my webcam staying on beyond my Google Hangout/Zoom meetings. This is obviously a problem so I've set out to find the solution.

Ends up it is pretty simple. All you need is lsof and grep.

To find out if your built-in webcam is being used:

lsof | grep Camera
@Ryanb58
Ryanb58 / gifts.md
Last active Jul 1, 2020
Cool sites that allow you to send some neat gifts to friends/family.
View gifts.md
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 Jan 19, 2022
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()