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
@copyninja
copyninja / daemon.c
Created June 19, 2011 07:24
A sample Daemon program in C
#include <stdio.h>
#include <fcntl.h>
#include <signal.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#define RUNNING_DIR "/tmp"
#define LOCK_FILE "daemond.lock"
#define LOG_FILE "daemond.log"
@jtriley
jtriley / terminalsize.py
Created July 26, 2011 21:58
Get current terminal size on Linux, Mac, and Windows
#!/usr/bin/env python
import os
import shlex
import struct
import platform
import subprocess
def get_terminal_size():
""" getTerminalSize()
@badsyntax
badsyntax / gist:5317545
Created April 5, 2013 08:24
Using Javascript labels to break out of a nested loop
// Break out of a nested loop when both indexes are equal to 1
// It's a stupid example, but demonstrates how to use labels
// Traditional (alternatively we could adjust the value of 'i' to break the outer loop)
var iteration1 = 0;
var found = false;
for (var i = 0; i < 3; i++) {
for (var j = 0; j < 3; j++) {
iteration1++;
if (i === 1 && j === 1) {
@Matthew-Weber
Matthew-Weber / data.csv
Last active May 7, 2022 20:36
D3 multi-series line chart with tooltips and legend
type date Line 1 Line 2 Line 3 Line 4
val1 1/1/00 11.361 40.863 106.118 33.896
val1 1/1/01 9.552 39.713 123.521 32.408
val1 1/1/02 8.576 38.091 137.61 33.204
val1 1/1/03 7.549 35.853 140.896 34.865
val1 1/1/04 6.716 32.109 156.805 36.044
val1 1/1/05 6.312 30.235 164.498 36.149
val1 1/1/06 5.76 27.934 161.806 36.039
val1 1/1/07 5.181 25.183 164.546 35.703
val1 1/1/08 4.922 28.642 180.783 40.183
@glenrobertson
glenrobertson / TileLayer.GeoJSON.js
Last active August 2, 2021 07:11
Leaflet GeoJSON Tile Layer Example
// Load data tiles from an AJAX data source
L.TileLayer.Ajax = L.TileLayer.extend({
_requests: [],
_addTile: function (tilePoint) {
var tile = { datum: null, processed: false };
this._tiles[tilePoint.x + ':' + tilePoint.y] = tile;
this._loadTile(tile, tilePoint);
},
// XMLHttpRequest handler; closure over the XHR object, the layer, and the tile
_xhrHandler: function (req, layer, tile, tilePoint) {
@erasin
erasin / webtest.go
Created August 26, 2013 09:36
golang 构建简单的服务器,和静态文件
package main
import (
"io"
"log"
"net/http"
"os"
)
func Hello(w http.ResponseWriter, r *http.Request) {
@rsolomo
rsolomo / udp_listener.rs
Last active July 15, 2022 14:19
trying out creating a udp listener in Rust
use std::io::net::ip;
use std::io::net::udp;
use std::str;
fn main() {
let addr = ip::SocketAddr {
ip: ip::Ipv4Addr(127, 0, 0, 1),
port: 5514
};
@thomasfr
thomasfr / Git push deployment in 7 easy steps.md
Last active May 1, 2024 23:17
7 easy steps to automated git push deployments. With small and configurable bash only post-receive hook
@staltz
staltz / introrx.md
Last active June 26, 2024 10:24
The introduction to Reactive Programming you've been missing
@jpillora
jpillora / sshd.go
Last active December 17, 2023 16:27
Go SSH server complete example - Read more here https://blog.gopheracademy.com/go-and-ssh/
// A small SSH daemon providing bash sessions
//
// Server:
// cd my/new/dir/
// #generate server keypair
// ssh-keygen -t rsa
// go get -v .
// go run sshd.go
//
// Client: