This file contains hidden or 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 getVideoImage(path, secs, callback) { | |
| var me = this, video = document.createElement('video'); | |
| video.onloadedmetadata = function() { | |
| if ('function' === typeof secs) { | |
| secs = secs(this.duration); | |
| } | |
| this.currentTime = Math.min(Math.max(0, (secs < 0 ? this.duration : 0) + secs), this.duration); | |
| }; | |
| video.onseeked = function(e) { | |
| var canvas = document.createElement('canvas'); |
This file contains hidden or 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 fitInto(desiredWidth, desiredHeight, actualWidth, actualHeight) { | |
| var actualSlope = actualHeight / actualWidth; | |
| if (isFinite(actualSlope || '@')) { | |
| if (desiredHeight / desiredWidth > actualSlope) { | |
| desiredHeight = desiredWidth * actualSlope; | |
| } | |
| else { | |
| desiredWidth = desiredHeight / actualSlope; | |
| } | |
| } |
This file contains hidden or 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 watermarkImage(elemImage, text) { | |
| // Create test image to get proper dimensions of the image. | |
| var testImage = new Image(); | |
| testImage.onload = function() { | |
| var h = testImage.height, w = testImage.width, img = new Image(); | |
| // Once the image with the SVG of the watermark is loaded... | |
| img.onload = function() { | |
| // Make canvas with image and watermark | |
| var canvas = Object.assign(document.createElement('canvas'), {width: w, height: h}); | |
| var ctx = canvas.getContext('2d'); |
This file contains hidden or 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
| # coding=utf-8 | |
| """ | |
| LICENSE http://www.apache.org/licenses/LICENSE-2.0 | |
| """ | |
| import datetime | |
| import sys | |
| import time | |
| import threading | |
| import traceback | |
| import SocketServer |
This file contains hidden or 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
| from datetime import datetime | |
| from time import sleep | |
| from dnslib import DNSLabel, QTYPE, RD, RR | |
| from dnslib import A, AAAA, CNAME, MX, NS, SOA, TXT | |
| from dnslib.server import DNSServer | |
| EPOCH = datetime(1970, 1, 1) | |
| SERIAL = int((datetime.utcnow() - EPOCH).total_seconds()) |
This file contains hidden or 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 cgi | |
| import http | |
| import mimetypes | |
| import os | |
| import shutil | |
| import urllib.parse | |
| STORAGE_PATH = os.environ.get('STORAGE_PATH') or \ | |
| os.path.dirname(__file__) + '/storage' |
This file contains hidden or 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
| from collections import OrderedDict | |
| import json | |
| from urllib.request import urlopen | |
| import xml.etree.ElementTree as ET | |
| xml = urlopen(url=url).read() | |
| items = [] | |
| for item in ET.fromstring(xml).findall('channel')[0].findall('item'): | |
| items.append(OrderedDict((i.tag, i.text) for i in item)) |
This file contains hidden or 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
| from datetime import datetime, timezone, timedelta | |
| def convert_timezone(dtm, z='utc'): | |
| t_utc = (dtm - (dtm.utcoffset() or timedelta())) | |
| t_utc = t_utc.replace(tzinfo=timezone.utc) | |
| z = z.lower().replace('utc', '').replace(' ', '').replace(':', '') | |
| if not z: | |
| return t_utc | |
| if len(z) == 3: |
This file contains hidden or 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
| # coding=utf-8 | |
| import base64 | |
| from urllib2 import urlopen | |
| import tempfile | |
| import os | |
| import tk | |
| import json | |
| class App(tk.Tk): |
This file contains hidden or 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/sh -xe | |
| API_KEY="YOUR_API_KEY_GOES_HERE" | |
| FPS="10" | |
| VLC_PATH="/Applications/VLC.app/Contents/MacOS/VLC" | |
| # I don't know how this'll behave on multimon, so you might want to hard-code. | |
| # INRES='1440x900' | |
| INRES=$(osascript -e 'tell application "Finder" to get bounds of window of desktop'|sed 's/, /x/g'|cut -f3- -dx) | |
| OUTRES='1280x800' | |
| # You can change this to record microphone or something else, from man soxformat (under coreaudio): |
OlderNewer