Skip to content

Instantly share code, notes, and snippets.

var cluster=require('cluster');
if(cluster.isMaster){
console.log('is master');
var worker=cluster.fork();
worker.on('message',function(message){
console.log('master recieve message: '+message);
});
process.on('exit',function(){
console.log('process exit');
#!/bin/bash
safeRunCommand() {
typeset cmnd="$*"
typeset ret_code
echo cmnd=$cmnd
eval $cmnd
ret_code=$?
if [ $ret_code != 0 ]; then
package com.example.touch;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.webkit.ConsoleMessage;
import android.webkit.WebChromeClient;
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<style>
body {
background-color: darkkhaki;
width: 360px;
height: 600px;
}
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import cv2
im = cv2.imread('h.png')
cv2.imshow('你好', im)
cv2.waitKey()
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import cv2
cap = cv2.VideoCapture(0)
while True:
ret,im = cap.read()
cv2.imshow('video test',im)
#!/usr/bin/python
# -*- coding: UTF-8 -*-
packageCounts='600,500,300,100'.split(',')
packageSum=0
temp=[]
subPackageCounts=[]
for i in range(len(packageCounts)):
currentCount=int(packageCounts[i])
@MarshalW
MarshalW / rendersphere.py
Created August 14, 2013 08:55
PyOpenGL简单示例
#!/usr/bin/env python
#
#
# 3.1.3 added toggle on for shader by pressing "g" (for glsl). Doesn't seem to
# want to toggle back off. plVShader looks identical to phong. To see toon
# shader change lines 163 and 164 to vShader = toonVShader
# and fShader = toonFShader
#
# 3.1.4 Attempting to add a more complex shader! I may add some more lights
# too
@MarshalW
MarshalW / io.js
Created January 11, 2017 11:31
dd命令在nodejs中的调用
// from http://stackoverflow.com/questions/36934749/how-to-get-the-output-of-a-spawned-child-process-in-node-js
var spawn = require('child_process').spawn;
// Create a child process
var child = spawn('dd', ['if=/dev/zero','of=/tmp/test1.img','bs=100m','count=1','conv=noerror,sync']);
child.stdout.on('data',
function(data) {
console.log('ls command output: ' + data);
});
package marshal.opencvproto;
import org.opencv.core.Mat;
import android.util.Log;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;