Skip to content

Instantly share code, notes, and snippets.

View glowinthedark's full-sized avatar

glowinthedark glowinthedark

  • URLError: <urlopen error [Errno 8] nodename nor servname provided, or not known>
  • HTTPError: HTTP Error 403: Forbidden
View GitHub Profile
@glowinthedark
glowinthedark / 0dedict.py
Last active April 15, 2022 04:37 — forked from josephg/0dedict.py
Apple dictionaries
#!/usr/bin/env python3
# -*- coding: ascii -*-
# Thanks to commenters for providing the base of this much nicer implementation!
# Save and run with $ python 0dedict.py
# You may need to hunt down the dictionary files yourself and change the awful path string below.
# This works for me on MacOS 10.14 Mohave
# /System/Library/AssetsV2/com_apple_MobileAsset_DictionaryServices_dictionaryOSX/0cab8989af7642f18332cfdc038d97017d28586a.asset/AssetData/Spanish - English.dictionary/Contents/Resources/Body.data
import sys
@glowinthedark
glowinthedark / README.md
Last active September 23, 2022 14:04 — forked from cuth/README.md
Font Size Bookmarklet

Font Size Bookmarklet

Code

javascript:(function(){'use strict';var getFontSize=function(el){return parseFloat(getComputedStyle(el,null)['font-size']);};document.addEventListener('wheel',function(e){if(!e.altKey)return;e.preventDefault();var el=e.target;var parent=el.parentElement;var size=getFontSize(el);while(parent&&size===getFontSize(parent)){el.style.fontSize='inherit';el=parent;parent=parent.parentElement;}
if(e.wheelDelta>0){size+=1;}else{size-=1;}
console.log(size);el.style.fontSize=size+'px';el.style.lineHeight='1.2em';});}());
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import os
# function to take care of downloading file
def enable_download_headless(browser,download_dir):
browser.command_executor._commands["send_command"] = ("POST", '/session/$sessionId/chromium/send_command')
params = {'cmd':'Page.setDownloadBehavior', 'params': {'behavior': 'allow', 'downloadPath': download_dir}}
browser.execute("send_command", params)
@glowinthedark
glowinthedark / selenium_basics.py
Created March 15, 2020 11:20 — forked from nrrb/selenium_basics.py
Selenium stuffs
from selenium import webdriver
profile = webdriver.FirefoxProfile()
# Set proxy settings to manual
profile.set_preference('network.proxy.type', 1)
# Set proxy to Tor client on localhost
profile.set_preference('network.proxy.socks', '127.0.0.1')
profile.set_preference('network.proxy.socks_port', 9050)
# Disable all images from loading, speeds page loading
# http://kb.mozillazine.org/Permissions.default.image
@glowinthedark
glowinthedark / lxml_examples.py
Created October 27, 2022 14:51 — forked from IanHopkinson/lxml_examples.py
Examples of xpath queries using lxml in python
#!/usr/bin/env python
# encoding: utf-8
import lxml.etree
import lxml.html
import requests
xml_sample = """<?xml version="1.0" encoding="UTF-8"?>
<foo:Results xmlns:foo="http://www.foo.com" xmlns="http://www.bah.com">
<foo:Recordset setCount="2">
@glowinthedark
glowinthedark / python_request_create_gist.py
Created November 11, 2022 22:57 — forked from joshisumit/python_request_create_gist.py
Create GIST from your python code with python requests module and OAuth token.
'''
HTTP Reuests has following parameters:
1)Request URL
2)Header Fields
3)Parameter
4)Request body
'''
#!/usr/bin/env python
import requests
@glowinthedark
glowinthedark / whisper-transcribe.bash
Created November 14, 2022 13:10 — forked from DaniruKun/whisper-transcribe.bash
Transcribe (and translate) any VOD (e.g. from Youtube) using Whisper from OpenAI and embed subtitles!
#!/usr/bin/env bash
# Small shell script to more easily automatically download and transcribe live stream VODs.
# This uses YT-DLP, ffmpeg and the CPP version of Whisper: https://github.com/ggerganov/whisper.cpp
# Use `./transcribe-vod help` to print help info.
# MIT License
# Copyright (c) 2022 Daniils Petrovs
@glowinthedark
glowinthedark / how-to-find-forks-of-deleted-repo.md
Created November 14, 2022 21:51 — forked from rjeczalik/how-to-find-forks-of-deleted-repo.md
How to find forks of a deleted repository?
@glowinthedark
glowinthedark / whisper-mock-en.ipynb
Created November 23, 2022 15:55 — forked from Kazuki-tam/whisper-mock-en.ipynb
whisper-mock-en.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from fairseq.models.transformer import TransformerModel
zh2en = TransformerModel.from_pretrained(
'/path/to/checkpoints',
checkpoint_file='checkpoint_best.pt',
data_name_or_path='data-bin/wmt17_zh_en_full',
bpe='subword_nmt',
bpe_codes='data-bin/wmt17_zh_en_full/zh.code'
)
zh2en.translate('你好 世界')