Skip to content

Instantly share code, notes, and snippets.

View compute_error.py
opencl_context = cl.create_some_context()
opencl_queue = cl.CommandQueue(opencl_context)
opencl_kernel = open('./opencl/calculate_error_double.cl', 'r').read()
opencl_program = cl.Program(self.opencl_context, opencl_kernel).build()
View multiply.cl
inline double sigmoid(double z){return 1.0/(1.0+exp(-1.0 * z));} //http://simple-ml-in-action.blogspot.com/2012/05/logistic-regression-with-opencl-and-net.html
__kernel
void multiply(__global const long *params, __global const double *as, __global const double *b, __global double *cs){
int gid = get_global_id(0);
//https://cnugteren.github.io/tutorial/pages/page2.html
//row major
int M = params[2];
View engine.js
this.tryHash = function(midstate, half, data, hash1, target, nonce){
data[3] = nonce;
this.sha.reset();
var h0 = this.sha.update(midstate, data).state; // compute first hash
for (var i = 0; i < 8; i++) hash1[i] = h0[i]; // place it in the h1 holder
this.sha.reset(); // reset to initial state
var h = this.sha.update(hash1).state; // compute final hash
if (h[7] == 0) {
var ret = [];
View engine.js
this.handleGetWorkResponse = function(response){
var work = eval("(" + response + ")");
var midstate = jsMiner.Util.fromPoolString(work.midstate);
var half = work.data.substring(0, 128);
var data = work.data.substring(128, 256);
data = jsMiner.Util.fromPoolString(data);
half = jsMiner.Util.fromPoolString(half);
var hash1 = jsMiner.Util.fromPoolString(work.hash1);
var target = jsMiner.Util.fromPoolString(work.target);
View nginx.conf
proxy_set_header X-SSL-Client-Cert $ssl_client_raw_cert;
View jason_whitehorn_us.conf
location = /wp-login.php {
if ($ssl_client_verify != SUCCESS) {
return 403;
}
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
View server.conf
server {
server_name jason.whitehorn.us;
listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate /etc/nginx/jason.whitehorn.us.crt;
ssl_certificate_key /etc/nginx/jason.whitehorn.us.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:AES128-SHA:RC4-SHA;
View jason_whitehorn_us.conf
limit_req_zone $binary_remote_addr zone=jason_whitehorn_us:5m rate=5r/m;
server {
server_name jason.whitehorn.us;
listen 443 ssl;
listen [::]:443 ssl;
ssl_client_certificate /etc/nginx/whitehorn-ca.crt;
ssl_certificate /etc/nginx/jason.whitehorn.us.crt;
ssl_certificate_key /etc/nginx/jason.whitehorn.us.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
View contents.json
{
"url": "https://www.datasyncbook.com/login/?redirect_to=https%3A%2F%2Fwww.datasyncbook.com%2Fcontent%2Fdelta-based-synchronization%2F",
"file": "html/chapter2.xhtml",
"login": {
"username": "user",
"password": "secret!",
"action": "/login/"
}
}
View contents.json
[
{
"url": "https://www.datasyncbook.com/content/introduction/",
"file": "html/intro.xhtml",
"login": null
},
{
"url": "https://www.datasyncbook.com/content/server-to-client-updates/",
"file": "html/part1.xhtml",
"login": null