Skip to content

Instantly share code, notes, and snippets.

func main() {
addr := flag.String("addr", ":4000", "HTTPS network address")
certFile := flag.String("certfile", "cert.pem", "certificate PEM file")
keyFile := flag.String("keyfile", "key.pem", "key PEM file")
flag.Parse()
mux := http.NewServeMux()
mux.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
if req.URL.Path != "/" {
http.NotFound(w, req)
@richzw
richzw / Dockerfile
Created March 9, 2022 04:48
DockerTest
FROM alpine:latest
RUN apk add -U libcap netcat-openbsd
RUN apk add --no-cache iptables ip6tables
RUN apk --no-cache add tcpdump
ENTRYPOINT ["sleep", "1h"]
@richzw
richzw / Dockerfile
Created March 9, 2022 04:06
Docker_test
FROM alpine:latest
RUN apk add -U libcap netcat-openbsd
RUN apk add --no-cache iptables ip6tables
RUN apk --no-cache add tcpdump
ENTRYPOINT ["sleep", "1h"]
public static void main(String[] args) throws IOException {
//create scope list with DataFlow's scopes
Set<String> scopeList = new HashSet<>();
scopeList.addAll(DataflowScopes.all());
GoogleCredentials credential = null;
try {
String curDir = Paths.get(".").toAbsolutePath().normalize().toString();
FileInputStream credFile = new FileInputStream(curDir + "/secrete.json");
PCollection<String> lines = pipeline.apply("readDataFromGCS",
TextIO.read().from("gcs path")
.watchForNewFiles(Duration.standardMinutes(2), Watch.Growth.never()));
PCollection<KV<String, Map<String, String>>> filter_event = lines.apply("ParseAndFilterFn", ParDo.of(new ParseAndFilterFn()));
PCollection<KV<String, Map<String, String>>> minute_window_events = filter_event.apply("MinuteFixwindow",
Window.<KV<String, Map<String, String>>>into(FixedWindows.of(Duration.standardMinutes(3)))
.triggering(AfterProcessingTime
.pastFirstElementInPane()
.plusDelayOf(Duration.standardMinutes(2)))
class RedisSink(object):
def __init__(self, host='localhost', port=6379, password=None, field=None):
self._host = host
self._port = port
self._field = field
self._password = password
self._client = None
self._pool = None
def _connect(self):
@richzw
richzw / mongoose group operation
Created July 19, 2012 07:13
The way of mongoose group operation
command = {
'group' : { //mongodb group command
'ns' : 'pings', //the collection to query
'cond' : {'active.end' : { $gt: new Date() }}, //active.end must be in the future
'initial': {'count': 0}, //initialize any count object properties
'$reduce' : 'function(doc, out){ out.count++ }',
'key' : {'url': 1} //fields to group by
}
}
@richzw
richzw / Mongoose GridFS
Created July 31, 2012 10:10
API for mongoose GridFS
mongoose = require('mongoose');
var GridStore = mongoose.mongo.GridStore,
Grid = mongoose.mongo.Grid,
ObjectID = mongoose.mongo.BSONPure.ObjectID;
exports.getGridFile = function(id, fn) {
var db = mongoose.connection.db,
id = new ObjectID(id),

//file.js

C = require('./C.js')

console.log(typeof C);

module.exports = function() {
    //var c = new C();
	return {c: new C()};
var peopleSchema = new mongoose.Schema({
name: {
type: String,
required: true,
minlength: 3,
maxlength: 25
},
age: Number
});