Skip to content

Instantly share code, notes, and snippets.

View GopherJ's full-sized avatar
🎯
Focusing on applied ZKP

Cheng JIANG GopherJ

🎯
Focusing on applied ZKP
View GitHub Profile
@GopherJ
GopherJ / query.json
Created July 25, 2018 14:26 — forked from cb372/query.json
Using the Elasticsearch scroll API
{
"sort": ["_doc"],
"size": 100,
"query": {
"bool": {
"must": {
"match_all": {}
},
"filter": {
...
@GopherJ
GopherJ / systemd-example.md
Created August 2, 2018 13:28 — forked from zsiegel/systemd-example.md
systemd example - works on Ubuntu 16.04

Ubuntu 16.04 systemd service setup

Enable persistent user systemd services

loginctl enable-linger $user

Create a user systemd directory

mkdir ~/.config/systemd/user
@GopherJ
GopherJ / model.rs
Created August 7, 2018 20:35 — forked from JIghtuse/model.rs
Rust' Path usage example
use std::path::{Path, PathBuf};
struct Model {
u: f32,
}
fn texture_fname(path: &Path) -> PathBuf {
let fullname = format!("{}{}", path.file_stem().unwrap().to_str().unwrap(), "_diffuse");
let mut buf = PathBuf::from(path);
@GopherJ
GopherJ / README.md
Created August 18, 2018 09:48 — forked from guilhermesimoes/README.md
YouTube's new morphing play/pause SVG icon

As soon as I saw the new YouTube Player and its new morphing play/pause button, I wanted to understand how it was made and replicate it myself.

From my analysis it looks like YouTube is using [SMIL animations][1]. I could not get those animations to work on browsers other than Chrome and it appears [that they are deprecated and will be removed][2]. I settled for the following technique:

  1. Define the icon path elements inside a defs element. These paths are not drawn.

  2. Draw one icon by definining a use element whose xlink:href attribute points to one of the icons. Simply [changing this attribute to point to the other icon is enough to swap them out][3], but this switch is not animated. To do that,

  3. Substitute the use for the actual path when the page is loaded.

@GopherJ
GopherJ / tcp_client.rs
Created August 21, 2018 20:44 — forked from postmodern/tcp_client.rs
TCP Client in Rust
#![allow(unused_variables)]
#![allow(unused_imports)]
use std::env;
use std::process;
use std::thread;
use std::io::{self, Read, Write, Error};
use std::net::TcpStream;
use std::net::TcpListener;
@GopherJ
GopherJ / servers.md
Created September 28, 2018 06:52 — forked from skseth/servers.md
Setup Docker, Postgres, Redis and NSQ on Mac

#Postgres

##Create Postgres Dockerfile

#create fresh postgres image  
docker build -t postgres .
@GopherJ
GopherJ / gist:ab372c59808687f780244199aee8e747
Created October 4, 2018 21:46 — forked from meule/gist:777d9a8a42e2c99a3386
Smooth animation of changing Leaflet marker's position on setLatLng
// just include d3js and add animaDur in ms to marker's option
L.SVG.prototype._setPath = function(layer,path){
if(layer.options.animaDur)
d3.select(layer._path).transition().duration(layer.options.animaDur).ease('linear').attr('d',path)
else
layer._path.setAttribute('d', path);
}
@GopherJ
GopherJ / select.rs
Created October 11, 2018 07:56 — forked from AGWA/select.rs
Very simple Rust wrapper around pselect
/* Copyright (C) 2017 Andrew Ayer
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
@GopherJ
GopherJ / cook_rsa_key.go
Created October 11, 2018 07:57 — forked from AGWA/cook_rsa_key.go
Demonstrates that an RSA signature does not uniquely identify a public key.
/*
* Demonstrates that an RSA signature does not uniquely identify a public key.
* Given a signature, s, and a message m, it's possible to construct a new RSA key
* pair such that s is a valid signature for m under the new key pair.
*
* Requires Go version >= 1.5. Go <= 1.4 doesn't work due to a bug in the bignum
* package: https://github.com/golang/go/issues/9826
*
* Written in 2015 by Andrew Ayer <agwa@andrewayer.name>
*
@GopherJ
GopherJ / fork_rand.c
Created October 11, 2018 08:00 — forked from AGWA/fork_rand.c
Demonstrates that LibreSSL's PRNG is not fork-safe on Linux. See https://www.agwa.name/blog/post/libressls_prng_is_unsafe_on_linux
/*
* Demonstrates that LibreSSL's PRNG is not fork-safe on Linux.
* See https://www.agwa.name/blog/post/libressls_prng_is_unsafe_on_linux
* This code is in the public domain.
*/
#include <openssl/rand.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>