Skip to content

Instantly share code, notes, and snippets.

@jxq0
jxq0 / waitForKeyElements.js
Created October 16, 2023 01:02 — forked from BrockA/waitForKeyElements.js
A utility function, for Greasemonkey scripts, that detects and handles AJAXed content.
/*--- waitForKeyElements(): A utility function, for Greasemonkey scripts,
that detects and handles AJAXed content.
Usage example:
waitForKeyElements (
"div.comments"
, commentCallbackFunction
);
class FMLog: NSObject {
let myOsLog = OSLog(subsystem: "com.jiaxq.fotomete", category: "")
func debug(
_ msg: String, _ args: CVarArg..., file: String = #file, line: Int = #line
) {
let logMsg = String(format: msg, arguments: args)
log(logMsg, type: .debug, file: file, line: line)
}
@jxq0
jxq0 / gpg-import-and-export-instructions.md
Created September 19, 2018 00:10 — forked from chrisroos/gpg-import-and-export-instructions.md
Instructions for exporting/importing (backup/restore) GPG keys

Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.

Method 1

Backup the public and secret keyrings and trust database

cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/

or, instead of backing up trustdb...

let getImage = {[unowned self](data: NSData!, response: NSURLResponse!, error: NSError!) -> Void in
let sizeOrder = ["Large", "Medium 800", "Medium 640"]
var largestImgUrl: String?
let json = JSON(data: data)
for (index: String, subJson: JSON) in json["sizes"]["size"] {
for size in sizeOrder {
if (subJson["label"].string == size) {
largestImgUrl = subJson["source"].string
break
@jxq0
jxq0 / tomorrow.xcs
Created June 19, 2014 00:07
Tomorrow Night for xshell
[tomorrow]
text(bold)=c5c8c6
magenta(bold)=b294bb
text=c5c8c6
white(bold)=ffffff
green=99cc99
red(bold)=cc6666
green(bold)=99cc99
black(bold)=373b41
red=cc6666
@jxq0
jxq0 / date.cpp
Last active January 2, 2016 13:49
c++ date trans
time_t StrToStamp(const string &str, const string &fmt)
{
struct tm tmInfo;
strptime(str.c_str(), fmt.c_str(), &tmInfo);
return mktime(&tmInfo);
}
int TransDateStr(const string &src, const string &fmt_src, string &dst, const string &fmt_dst)
{
#!/usr/bin/env bash
dir=$(dirname $0)
gconfdir=/apps/gnome-terminal/profiles
echo # This makes the prompts easier to follow (as do other random echos below)
########################
### Select a profile ###
########################
worker_processes 2;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
use epoll;
}
#!/usr/bin/env python
from gevent import monkey
monkey.patch_all()
import gevent
from gevent.wsgi import WSGIServer
from gevent.pool import Pool
import gevent.socket
from cgi import parse_qs, escape
import json
import redis
#include <stdio.h>
#include <string.h>
#define mix(a,b,c) \
{ \
a -= b; a -= c; a ^= (c >> 13); \
b -= c; b -= a; b ^= (a << 8); \
c -= a; c -= b; c ^= (b >> 13); \
a -= b; a -= c; a ^= (c >> 12); \
b -= c; b -= a; b ^= (a << 16); \
c -= a; c -= b; c ^= (b >> 5); \