Skip to content

Instantly share code, notes, and snippets.

[3495645.166553] usb 2-4: reset SuperSpeed Gen 1 USB device number 9 using xhci_hcd
[3495645.187123] usb 2-4: LPM exit latency is zeroed, disabling LPM.
[3495645.187250] usb 2-4: device firmware changed
[3495645.242417] usb 2-4: USB disconnect, device number 9
[3495645.514141] usb 2-4: new SuperSpeed Gen 1 USB device number 10 using xhci_hcd
[3495645.534578] usb 2-4: LPM exit latency is zeroed, disabling LPM.
[3495645.535245] usb 2-4: New USB device found, idVendor=0fd9, idProduct=0066, bcdDevice= 0.00
[3495645.535264] usb 2-4: New USB device strings: Mfr=1, Product=2, SerialNumber=4
[3495645.535265] usb 2-4: Product: Cam Link 4K
[3495645.535266] usb 2-4: Manufacturer: Elgato
// mock promises used below
const wait = async (ms) => await new Promise(resolve => setTimeout(resolve, ms));
const send_request1 = () => wait(300), send_request2 = () => wait(200);
async function get_email() {
await wait(Math.random() * 1000);
if (Math.random() > 0.5) throw new Error('failure');
return {subject: 'foobar'};
}
const assert = require('assert');
@phihag
phihag / gist:2227d7a7119f6c2f339e40c0e8472763
Created November 2, 2018 18:45
youtube-dl log for StackOverflow (unedited)
C:\Users\phihag>youtube-dl -o "C:\My\Download\Location\%(series)s\%(title)s.%(ext)s" "https://www.crunchyroll.com/evil-or-live/episode-1-standing-on-the-edge-of-despair-749999" -v
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-o', 'C:\\My\\Download\\Location\\%(series)s\\%(title)s.%(ext)s', 'https://www.crunchyroll.com/evil-or-live/episode-1-standing-on-the-edge-of-despair-749999', '-v']
[debug] Encodings: locale cp1252, fs mbcs, out cp850, pref cp1252
[debug] youtube-dl version 2018.10.29
[debug] Python version 3.4.4 (CPython) - Windows-10-10.0.17134
[debug] exe versions: ffmpeg N-92330-gd6d407d2d7, ffprobe N-92330-gd6d407d2d7
[debug] Proxy map: {}
@phihag
phihag / daterange.py
Last active November 28, 2018 02:30
youtube-dl daterange simplified
from __future__ import unicode_literals
import youtube_dl
from youtube_dl.utils import DateRange
ydl_opts = {
'daterange' : DateRange('20180601'),
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download(['MqpVnYrNnf0'])
@phihag
phihag / Dockerfile
Created February 8, 2018 09:02
Dockerfile to demo youtube-dl thumbnail embedding
FROM python:3
RUN mkdir /code
WORKDIR /code
RUN echo 'deb http://www.deb-multimedia.org jessie main non-free' >> /etc/apt/sources.list
RUN apt-get update
RUN yes | apt-get install deb-multimedia-keyring
RUN apt-get update
RUN apt-get install -y ffmpeg AtomicParsley
@phihag
phihag / rndsampling.js
Created November 10, 2017 16:17
Check for random sampling
const assert = require('assert');
const checks = {
/* original_post: (val, range, maxNum) => {
return val + range - (val % range) < maxNum;
},*/
traditional: (val, range, maxNum) => {
return val < Math.floor(maxNum / range) * range;
},
correct: (val, range, maxNum) => {

Keybase proof

I hereby claim:

  • I am phihag on github.
  • I am phihag (https://keybase.io/phihag) on keybase.
  • I have a public key whose fingerprint is 7D33 D762 FD6C 3513 0481 347F DB4B 54CB A482 6A18

To claim this, I am signing this object:

@phihag
phihag / score.r
Last active July 23, 2016 09:55
Simulate a Badminton game
PROB <- 0.5
RUNS <- 10000
game_is_over <- function(p, q) {
return((
((p == 21) && (q < 20)) ||
((p > 21) && (p <= 30) && (p - 2 == q)) ||
(p == 30) && (q == 29)
) || (
((q == 21) && (p < 20)) ||
@phihag
phihag / mm.log
Last active June 29, 2016 19:57
NetworkManager / ModemManager logs of ME906s
ModemManager[15700]: <info> [1467221984.425814] [main.c:136] main(): ModemManager (version 1.4.14) starting in system bus...
ModemManager[15700]: <debug> [1467221984.427865] [main.c:61] bus_acquired_cb(): Bus acquired, creating manager...
ModemManager[15700]: <debug> [1467221984.429776] [mm-plugin-manager.c:852] load_plugins(): Looking for plugins in '/usr/lib/x86_64-linux-gnu/ModemManager'
ModemManager[15700]: <debug> [1467221984.430104] [mm-plugin-manager.c:877] load_plugins(): Loaded plugin 'Motorola'
ModemManager[15700]: <debug> [1467221984.430255] [mm-plugin-manager.c:877] load_plugins(): Loaded plugin 'Longcheer'
ModemManager[15700]: <debug> [1467221984.430376] [mm-plugin-manager.c:877] load_plugins(): Loaded plugin 'Option High-Speed'
ModemManager[15700]: <debug> [1467221984.430491] [mm-plugin-manager.c:877] load_plugins(): Loaded plugin 'Gobi'
ModemManager[15700]: <debug> [1467221984.430608] [mm-plugin-manager.c:877] load_plugins(): Loaded plugin 'Nokia (Icera)'
ModemManager[15700]: <debug> [14672219
@phihag
phihag / log file
Last active June 29, 2016 12:05
ME906s problems
--> WvDial: Internet dialer version 1.61
--> Initializing modem.
--> Sending: ATZ
ATZ
OK
--> Sending: AT+CFUN=1
AT+CFUN=1
OK
--> Sending: ATQ0 V1 E1 S0=0
ATQ0 V1 E1 S0=0