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 json | |
import socket # Just so we can properly handle hostname exceptions | |
import obspython as obs | |
import paho.mqtt.client as mqtt | |
import ssl | |
import pathlib | |
import time | |
import enum | |
import uuid | |
from multiprocessing import Lock |
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
#!/usr/bin/env node | |
var lgtv = require("lgtv2")({ | |
url: 'ws://livingroomtv:3000' | |
}); | |
lgtv.on('connect', function () { | |
console.log('connected'); | |
lgtv.getSocket('ssap://com.webos.service.networkinput/getPointerInputSocket', | |
function(err, sock) { | |
if (!err) { |
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
# pip3 install tweepy | |
import tweepy | |
import json | |
import time | |
# Follow the instructions to create a new development project and API keys | |
# from https://developer.twitter.com/en/portal/petition/essential/basic-info | |
# and enter the key, secret, and bearer token. | |
apiv2 = tweepy.Client( | |
consumer_key='', |
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
-- Connect to postgresql instance for nextcloud: | |
-- `psql -U nextcloud nextcloud` | |
-- Get tables with largest disk space | |
SELECT | |
table_name, | |
pg_size_pretty(table_size) AS table_size, | |
pg_size_pretty(indexes_size) AS indexes_size, | |
pg_size_pretty(total_size) AS total_size | |
FROM ( |
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 -x | |
# Invoke with: | |
# ./avchd-mts-to-mp4.sh AVCHD/BDMV/STREAM/*.MTS | |
exifdateformat='%Y:%m:%d %T%z' | |
ffmpegdateformat='%FT%T' | |
filenamedateformat='%Y%m%d_%H%M%S' | |
getfileinfodateformat='%m/%d/%Y %T' | |
for srcfile in "$@" | |
do | |
exifcreatetime=$(exiftool -s -s -s -datetimeoriginal $srcfile) |
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 java.util.*; | |
import java.lang.*; | |
/** | |
Output: | |
with 75 random hashcode items, 1 / 1000000 (9.999999999999999E-5%) of sorts triggered an exception | |
java.lang.IllegalArgumentException: Comparison method violates its general contract! | |
with 93 random hashcode items, 1 / 1000000 (9.999999999999999E-5%) of sorts triggered an exception | |
java.lang.IllegalArgumentException: Comparison method violates its general contract! | |
with 193 random hashcode items, 1 / 1000000 (9.999999999999999E-5%) of sorts triggered an exception |
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
#!/usr/bin/env python3 | |
# video-length.py: sums the duration of all video files passed as arguments using ffmpeg | |
import subprocess | |
import sys | |
import datetime | |
files = sys.argv[1:] | |
CMD = "ffmpeg -i file:\"%s\" 2>&1 | grep Duration | cut -d ' ' -f 4 | sed s/,//" |
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
title = "The title of the article" | |
urls=""" | |
<image URLs scraped from the page> | |
""" |
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
def numbers_sum_to_ten(num1, num2): | |
""" | |
Return True if num1 and num2 sum to 10. | |
Ex.: numbers_sum_to_ten(5, 5) => True | |
""" | |
pass | |
def word_count(search_word, sentences): | |
""" | |
Return the number of times a given word occurs in a group of sentences. |
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
function single_replace { | |
python3 -c "import sys, re; print(re.sub(sys.argv[1], sys.argv[2], open(sys.argv[3]).read()))" "$@" | |
} | |
function multi_replace { | |
python3 -c "import sys, re; t=open(sys.argv[1]).read(); | |
for i in range(2, len(sys.argv)-1, 2): | |
t=re.sub(sys.argv[i], sys.argv[i+1], t) | |
print(t, end='')" "$@" | |
} |
NewerOlder