Andy Thomason is a Senior Programmer at Genomics PLC. He has been witing graphics systems, games and compilers since the '70s and specialises in code performance.
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
function urlBase64ToUint8Array(base64String) { | |
const padding = '='.repeat((4 - base64String.length % 4) % 4); | |
const base64 = (base64String + padding) | |
.replace(/\-/g, '+') | |
.replace(/_/g, '/') | |
; | |
const rawData = window.atob(base64); | |
return Uint8Array.from([...rawData].map((char) => char.charCodeAt(0))); | |
} |
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
require 'openssl' | |
require 'base64' | |
# ===== \/ sign ===== | |
# generate keys | |
key = OpenSSL::PKey::EC.new("secp256k1") | |
key.generate_key | |
public_key = key.public_key | |
public_key_hex = public_key.to_bn.to_s(16).downcase # public key in hex format |
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
// XPath CheatSheet | |
// To test XPath in your Chrome Debugger: $x('/html/body') | |
// http://www.jittuu.com/2012/2/14/Testing-XPath-In-Chrome/ | |
// 0. XPath Examples. | |
// More: http://xpath.alephzarro.com/content/cheatsheet.html | |
'//hr[@class="edge" and position()=1]' // every first hr of 'edge' class |
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
class GooglePlayVerification | |
require 'google/api_client' | |
# Refer: | |
# https://code.google.com/p/google-api-ruby-client/issues/detail?id=72 | |
# and | |
# http://jonathanotto.com/blog/google_oauth2_api_quick_tutorial.html | |
# and | |
# http://milancermak.wordpress.com/2012/08/24/server-side-verification-of-google-play-subsc/ | |
GOOGLE_KEY = 'xxx-xxx.apps.googleusercontent.com' |
Eric Bidelman has documented some of the common workflows possible with headless Chrome over in https://developers.google.com/web/updates/2017/04/headless-chrome.
If you're looking at this in 2016 and beyond, I strongly recommend investigating real headless Chrome: https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md
Windows and Mac users might find using Justin Ribeiro's Docker setup useful here while full support for these platforms is being worked out.
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
-module(rest). | |
-include("/opt/local/lib/erlang/lib/stdlib-1.18.2/include/qlc.hrl"). | |
-include("/opt/local/lib/yaws/include/yaws_api.hrl"). | |
-export([out/1, addAirport/4, handle/2 ]). | |
-define(RECORD_TYPE, airport). | |
-define(RECORD_KEY_FIELD, code). |
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
<head> | |
<title>meteor_servercall</title> | |
</head> | |
<body> | |
{{> simple}} | |
{{> passData}} | |
</body> | |
<template name="simple"> |
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 SimpleHTTPServer | |
class CORSHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): | |
def send_head(self): | |
"""Common code for GET and HEAD commands. | |
This sends the response code and MIME headers. | |
Return value is either a file object (which has to be copied | |
to the outputfile by the caller unless the command was HEAD, | |
and must be closed by the caller under all circumstances), or |
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
module BinaryTree | |
class Node | |
attr_reader :word, :count, :left, :right | |
include Enumerable | |
def initialize(word) | |
@word, @count = word, 1 | |
end |
NewerOlder