This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function tree(id, arr){ | |
var node = arr.find(a => a.id == id) || { } | |
node.items = arr.filter(a => a.pid == id).map(a => tree(a.id, arr)) | |
return node | |
} | |
tree(0, [ | |
{id:1, pid:0, name:"SYSTEM"}, | |
{id:2, pid:1, name:"aa"}, | |
{id:3, pid:2, name:"aaa"}, | |
{id:4, pid:2, name:"b"}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var PREFIX = 'c' + Math.floor(Math.random() * 1000) + '-', | |
EXTENSION = 'bmp', | |
ROOT_DIR = '', | |
FFMPEG_PATH = 'ffmpeg-20151116-git-1fe82ab-win64-static\\bin\\ffmpeg.exe', | |
FFMPEG_ARGS = '-framerate 30', | |
FILE_OUTPUT = 'test.avi' | |
var app = WScript.CreateObject('Shell.Application'), | |
shell = WScript.CreateObject('WScript.Shell'), | |
fso = WScript.CreateObject('Scripting.FileSystemObject') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: gbk -*- | |
import os, sys, urllib, urllib2, cookielib, random, re, datetime | |
# uis username, uis password, phone number | |
userinfo = [ \ | |
# [studentID, password, phoneNumber], | |
] | |
# the desired date (year, month, day) | |
reqdate = datetime.date(2015, 5, 6) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//ini_set('display_errors',1); | |
//ini_set('display_startup_errors',1); | |
//error_reporting(-1); | |
// this is naive | |
function isValidUrl($url) { | |
return strpos($url, 'http://') === 0 || strpos($url, 'https://') === 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% image file | |
FILE_NAME = 'p2.png'; | |
% length / pixel | |
LENGTH_SCALE = 500 / 114; | |
% ignore regions if area small than | |
MIN_AREA = 10; | |
% filter to create binary image |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import httplib, urllib, datetime | |
conn = httplib.HTTPConnection('baidu.com') | |
conn.request('GET', '/') | |
response = conn.getresponse() | |
data = response.read() | |
conn.close() | |
if data.find('//10.108.255.12') < 0: | |
exit() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<meta name="viewport" content="width=640,user-scalable=no" /> | |
<meta charset="utf8" /> | |
<style> | |
html, body { | |
background: #aaa; | |
margin: 0; | |
padding: 0; | |
position: relative; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// run `phantomjs index.js [directory] [imagename]` in the shell and file will be out.png | |
var WIDTH = 200, | |
MARGIN = 5, | |
COLS = 3 | |
var fs = require('fs'), | |
sys = require('system'), | |
dir = sys.args[1] || '.' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
# /etc/init.d/autossh | |
TUNNEL_MONITOR=53389 | |
TUNNEL_USER="bae" | |
TUNNEL_HOST="bae.ofr.me" | |
TUNNEL_PORT=30383 | |
TUNNEL_KEY="/home/oxyflour/.ssh/bae.id_rsa" | |
TUNNEL_ARGS="-D 0.0.0.0:3129 -L 0.0.0.0:13128:127.0.0.1:3128 -L 0.0.0.0:10022:vlr.ofr.me:22" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xml.dom.minidom | |
def node_to_obj(node): | |
obj = {} | |
if node.nodeType == 1: | |
if node.attributes.length > 0: | |
obj["#attr"] = {} | |
for i in range(0, node.attributes.length): | |
attr = node.attributes.item(i) | |
obj["#attr"][attr.name] = attr.value |
OlderNewer