Skip to content

Instantly share code, notes, and snippets.

View Ryanb58's full-sized avatar

Taylor Brazelton Ryanb58

View GitHub Profile
@Ryanb58
Ryanb58 / main.md
Created November 17, 2020 14:31
Who Is Using Your Webcam?

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 July 1, 2020 20:30
Cool sites that allow you to send some neat gifts to friends/family.

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 January 25, 2024 14:23
How to profile a Node.JS application and Visualize/debug the results.

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 September 28, 2018 15:45
Python monkey patch example.

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 September 25, 2018 19:41
Django Model Change Tracker
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
@Ryanb58
Ryanb58 / mac-apps.md
Last active September 19, 2018 15:13
@Ryanb58
Ryanb58 / diff.md
Created August 15, 2018 13:08
Custom SysCTL Changes on DrPepper

--- /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 March 22, 2024 12:19
How to install telnet into a alpine docker container. This is useful when using the celery remote debugger in a dev environment.
>>> 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 15:51
Profile a section of code in python.
import time
import cProfile, pstats, StringIO
import os
import shutil
import tempfile
start_time = time.time()
pr = cProfile.Profile()
pr.enable()