Published May-13-2020
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
#!/bin/bash | |
# Function to display usage information | |
usage() { | |
echo "Usage: $0 /path/to/input.mp4 [ /path/to/output_directory ]" | |
exit 1 | |
} | |
# Check if at least one argument (input file) is provided | |
if [ $# -lt 1 ]; then |
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
import functools | |
from events import Events # Note you must pip install events | |
class set_event: | |
"""Define a class-based setter method decorator.""" | |
def __init__(self, func, event): | |
super().__init__() |
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
Mute these words in your settings here: https://twitter.com/settings/muted_keywords | |
ActivityTweet | |
generic_activity_highlights | |
generic_activity_momentsbreaking | |
RankedOrganicTweet | |
suggest_activity | |
suggest_activity_feed | |
suggest_activity_highlights | |
suggest_activity_tweet |
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
# Here is an example of some syntax I'm proposing: | |
# See the github repo at https://github.com/mikeckennedy/python-switch | |
def test_switch(): | |
num = 7 | |
val = input("Enter a key. a, b, c or any other: ") | |
with Switch(val) as s: | |
s.case('a', process_a) | |
s.case('b', process_b) |
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
#!/bin/bash | |
line=$(tail -1 /var/log/myapp/myapp.uwsgi.log) | |
substr='uWSGI listen queue of socket' | |
if test "${line#*$substr}" != "$line" | |
then | |
#We're using upstart, could be easily adapted to fx systemd | |
# Adding a log statement to keep track of when this happens. Remember to create the monitor dir | |
/sbin/initctl restart myapp > /var/log/myapp/monitor/uwsgi-monitor.log 2>&1 | |
echo "$(date) restarted myapp due to listen queue error" >> /var/log/myapp/monitor/uwsgi-monitor.log |
I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6
apt-get update && apt-get install gdb
- Create a service file like
dash_sniffer.service
- Put it in
/lib/systemd/system/
- Reload
systemd
using command:systemctl daemon-reload
- Enable auto start using command:
systemctl enable dash_sniffer.service
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
import graphlab as gl | |
import pandas | |
import numpy as np | |
import string | |
import re | |
import unicodedata | |
import math | |
# attempt to load text files | |
import os | |
files = os.listdir(os.getcwd()) |
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
index | file2 | similarity | file1 | |
---|---|---|---|---|
0 | 027.txt | 0.870699976021 | 001.txt | |
1 | 038.txt | 0.86203984054 | 001.txt | |
2 | 045.txt | 0.83739929573 | 001.txt | |
3 | 048.txt | 0.871940130115 | 001.txt | |
4 | 007.txt | 0.839339858402 | 001.txt | |
5 | 009.txt | 0.849677851534 | 001.txt | |
6 | 004.txt | 0.830406980293 | 001.txt | |
7 | 006.txt | 0.878178563493 | 001.txt | |
8 | 031.txt | 0.850476330623 | 001.txt |
NewerOlder