Skip to content

Instantly share code, notes, and snippets.

@hongru
hongru / IPSecDemo.m
Created November 10, 2015 15:33 — forked from zqqf16/IPSecDemo.m
Start IPSec programmatically in iOS 8
- (void)viewDidLoad
{
[super viewDidLoad];
// init VPN manager
self.vpnManager = [NEVPNManager sharedManager];
// load config from perference
[_vpnManager loadFromPreferencesWithCompletionHandler:^(NSError *error) {
@hongru
hongru / fsutil.js
Created November 18, 2014 09:59
node file system util apis :)
var fs = require('fs');
var path = require('path');
var http = require('http');
var mkdirSync = function (url,mode,cb){
var arr = url.split("/");
mode = mode || 0755;
cb = cb || function(){};
if(arr[0]==="."){//处理 ./aaa
arr.shift();
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta content="yes" name="apple-mobile-web-app-capable">
<title>iOS Web App</title>
<!-- iPhone -->
@hongru
hongru / ejs2jst.js
Last active December 18, 2015 06:59
ejs2jst
// tasks
// ejs: {
// 'script/view.jst.js': 'view/**/*.ejs'
// },
grunt.registerMultiTask('ejs', 'Compile EJS templates into JST.', function() {
var options = {
client: true,
open: "<%",
function connect(scope, fnFrom, fnTo) {
"use strict"
var objFn = fnFrom.split('.');//处理传入的函数名
var deepth = objFn.length;
var scope = scope || window;
var j = deepth,i=j;
var _obj = scope,__obj=_obj ;
while (i > 0) {//以window.console.log为例,这里利用迭代最终拿到log
_obj = _obj[objFn[deepth - i]];
i -= 1;
@hongru
hongru / About Python&Django.md
Last active December 11, 2015 21:28
About Python&Django

Python27 install info for Windows

  • http://www.python.org/getit/releases/2.7.3/ 找到MSI installer 下载,建议用2.7的版本
  • 安装python后添加环境变量 PATH: ;C:\Python27
  • 安装python package包管理工具和常用package
  • 用pip安装各种需要的package,比如 pip install distribute ...
  • 安装 Django, pip install django
  • 安装 pil, pip install pil ,pil好像下载极其艰难 -_-#
@hongru
hongru / spmbatch.js
Last active December 10, 2015 22:18
batch spm build|upload
#!/usr/bin/env node
// -*- js -*-
/**
* @example
* spmbat ./
*/
var fs = require('fs'),
util = require('util'),
path = require('path'),
@hongru
hongru / Json Format
Created December 19, 2012 08:52
Json Format in document
//background js
console.log('JSON Page Format started!')
;(function () {
var txt = document.body.innerText.trim(),
easyReg = /^{.+}$|^(\w+)\(({.+})\)$/;
var gIndentStyle='&nbsp;&nbsp;&nbsp;&nbsp;';
var arr = txt.match(easyReg), jsonTxt;
if (!arr) return;
@hongru
hongru / jstemplate.js
Created August 31, 2012 09:22
a light js template engine
/*!
* jstemplate: a light & fast js tamplate engine
* License MIT (c) 岑安
*/
;(function (name, definition) {
if (typeof define == 'function') define(definition);
else if (typeof module != 'undefined') module.exports = definition();
else this[name] = definition();
})('jstemplate', function () {
@hongru
hongru / imgRotate
Created August 12, 2012 08:38
imgRotate - canvas & DXTransform Matrix filter
var canvas = false;
var context = false;
var isCanvas = (document.createElement("canvas").getContext) ? true : false;
createCanvas = function(o) {
if (isCanvas) {
canvas = document.createElement("canvas");
canvas.style.position = "absolute";
canvas.style.width = nw + "px";
canvas.style.height = nh + "px";