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
# Use it with: python3 simple-asyncio.py <timeout> | |
# timeout defaults to 5 seconds which means it'll never timeout | |
# change the string to expect (or the string printed after the sleep) to demonstrate the EOF example (did not timeout but did not match) | |
import sys | |
import asyncio | |
import pexpect | |
async def work(timeout): |
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
package main | |
import ( | |
"fmt" | |
"time" | |
"github.com/bytecodealliance/wasmtime-go" | |
) | |
func prepare(wasmfile string) (*wasmtime.Store, *wasmtime.WasiInstance, *wasmtime.Module) { |
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
#![deny(warnings)] | |
use hyper::service::{make_service_fn, service_fn}; | |
use hyper::{Client, Server, Body, Request, Result, Response, StatusCode}; | |
async fn handle(req: Request<Body>) -> Result<Response<Body>> { | |
match req.uri().path() { | |
"/ping" => { | |
Ok(handle_ping()) |
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
/* Remove facebook photos | |
Just run the below snippet on the console after browsing to Your Photos (click Photos, then Your Photos) | |
It kind of works on videos with a couple of caveats: need to change data-action-type to delete_video, | |
and change contains('button') to select 'Confirm' instead of 'Delete' | |
However, FB reloads the page after removing each video so it can't be run in a loop | |
*/ | |
function contains(selector, text) { |
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
(?:https?://)?(?:[a-zA-Z0-9\-]+\.)?(?:amazon|amzn){1}\.(?P<tld>[a-zA-Z\.]{2,})\/(gp/(?:product|offer-listing|customer-media/product-gallery)/|exec/obidos/tg/detail/-/|o/ASIN/|dp/|(?:[A-Za-z0-9\-]+)/dp/)?(?P<ASIN>[0-9A-Za-z]{10}) | |
I created this a number of years ago for an irc bot (https://github.com/rmmh/skybot) to recognize amazon urls. Keep forgetting to hang onto it. |
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
### Keybase proof | |
I hereby claim: | |
* I am avidal on github. | |
* I am avidal (https://keybase.io/avidal) on keybase. | |
* I have a public key whose fingerprint is 33DC 0060 F0E3 A0AE FD9F 6DB8 4980 1044 EFC3 E5F6 | |
To claim this, I am signing this object: |
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
var msgs = cb().messages; | |
var lim = 200 /* max of 200 entries in the backlog */; | |
var arr = msgs.toArray().slice(0, msgs.size() - lim); | |
_.each(arr, function(m) { | |
$('div[data-eid='+m.get('eid')+']').remove(); | |
msgs.remove(m); | |
}) |
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 python | |
import os | |
j = lambda *p: os.path.join(*p) | |
# Permanent directory paths are $goodroot/$album | |
GOOD_ROOT = u"/media/raid/music" |
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 subprocess | |
from StringIO import StringIO | |
class XmpFile(object): | |
def __init__(self, path, flags, *mode): | |
# Store the path as an instance property for later | |
self.path = "." + path | |
self.file = os.fdopen(open(self.path, flags, *mode), | |
flag2mode(flags)) |
NewerOlder