Skip to content

Instantly share code, notes, and snippets.

@psychoss
psychoss / NDK-Tips.md
Last active January 19, 2016 09:23
NDK

sudo adb start-server

@psychoss
psychoss / CVJNI.java
Created January 18, 2016 08:38 — forked from sheimi/CVJNI.java
JNI Demo (invode opencv ...)
import java.io.*;
public class CVJNI {
//Load jni library
static {
try {
System.loadLibrary("cvjni");
} catch (Exception e) {
e.printStackTrace();
}
@psychoss
psychoss / get-time.rs
Last active January 16, 2016 03:03
Rust Foreign Function Interface
use std::ptr;
pub type c_int = i32;
pub type time_t = i64;
pub type c_long = i64;
pub type c_char = i8;
pub type suseconds_t = i64;
#[repr(u8)]
enum c_void {
__variant1,
#include <sys/types.h>
#include <dirent.h>
#include <errno.h>
#include <vector>
#include <string>
#include <iostream>
using namespace std;
/*function... might want it in some class?*/
@psychoss
psychoss / subscriber.js
Created January 15, 2016 13:13
Javascript
var event = {//发布-订阅功能
clientList: [],
listen: function(key, fn){
if(!this.clientList[key]){
this.clientList[key] = [];
}
this.clientList[key].push(fn); //订阅的消息添加进缓存列表
},
trigger: function(){
var key = Array.prototype.shift.call(arguments),
@psychoss
psychoss / sh-7z-compress.sh
Last active January 21, 2016 06:47
Shell Scripts
#!/bin/bash
DATE=`date +%Y-%m-%d`
for file in ./*
do
if [ -d "$file" ]
then
echo $file-$DATE.zip
#7z a -r $file-$DATE.zip $file
@psychoss
psychoss / vscode-fmt.js
Last active January 15, 2016 12:47
Something about Visual Code
// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
var vscode = require('vscode');
var ass = require("node-sass");
var fs = require("fs");
function css_beautify(source_text, options) {
options = options || {};
source_text = source_text || '';
// HACK: newline parsing inconsistent. This brute force normalizes the input.
package main
import (
"fmt"
"hash/crc32"
)
var crcTable = crc32.MakeTable(crc32.Castagnoli)
// crc implements the checksum specified in section 3 of
@psychoss
psychoss / macros-concat_idents.rs
Last active January 15, 2016 12:48
Something about Rust Macros
macro_rules! test(
($x:ident) => ({
let z = concat_idents!(hello_, $x);
z();
})
)
fn hello_world() { ... }
fn main() {
@psychoss
psychoss / c-regex.c
Last active January 19, 2016 09:21
Deal with file system an C language
/* match: search for regexp anywhere in text */
int match(char *regexp, char *text) {
if (regexp[0] == '^')
return matchhere(regexp + 1, text);
do { /* must look even if string is empty */
if (matchhere(regexp, text))
return 1;
} while (*text++ != '\0');
return 0;
}