This file contains 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 | |
# This is used to process multiple svg files | |
cp -r svg-original svg-compressed | |
cd svg-compressed | |
files=$(ls *.svg) | |
for file in $files | |
do |
This file contains 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 filterParams(source, keys) { | |
let result = {}; | |
keys.forEach(item => { | |
result[item] = source[item]; | |
}); | |
return result; | |
} | |
const source = { |
This file contains 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
const SESSION_STATUS = { | |
NOT_LOGIN: 1, | |
LOGIN: 2, | |
ACCESS_TOKEN_EXPIRED: 3, | |
REFRESH_TOKEN_EXPIRED: 4 | |
}; | |
let refresh_timer = null; | |
function checkAuth(callback) { |
This file contains 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
/** | |
* 强制输入框只能输入正整数 | |
* @param {string} id 输入框的id | |
*/ | |
function intInput(id) { | |
var item = document.querySelector(id); | |
item.onkeyup = forceInt; | |
item.onafterpaste = forceInt; | |
function forceInt() { |
This file contains 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 os, shutil | |
src = "img" | |
dest = "newimg" | |
if os.path.isdir(dest) == False: | |
os.mkdir(dest) | |
imgs = os.listdir(src) |
This file contains 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
package { | |
import flash.display.Sprite; | |
public class Ball extends Sprite { | |
public var vx:Number; | |
public var vy:Number; | |
public function Ball() { | |
init(); | |
} | |
This file contains 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 trim(str:String):String { | |
return str.replace(/^\s+/, "").replace(/\s+$/, ""); | |
} | |
var demo:String = " foo bar "; | |
trace("["+demo+"]"); // [ foo bar ] | |
trace("["+trim(demo)+"]"); // [foo bar] |
This file contains 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
# version 3.X | |
# print out all the files' name, and stores | |
# them in a text file, in list format | |
import os | |
cwd = os.getcwd() | |
lst = os.listdir(cwd) | |
str = repr(lst) | |
output = open("output.txt", "w", encoding="utf-8") | |
output.write(str) |
This file contains 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:utf-8 -*- | |
import io | |
lines = io.open("data.txt", "r", encoding="utf-8-sig").readlines() # windows | |
lines = io.open("data.txt", "r", encoding="utf-8").readlines() # linux |
This file contains 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 can = document.getElementById("can"); | |
var ctx = can.getContext("2d"); | |
var touching = 0; | |
can.addEventListener("touchstart", touchDown, false); | |
can.addEventListener("touchmove", touchXY, true); // why is true | |
can.addEventListener("touchend", touchUp, false); | |
function touchUp() { | |
touching = 0; |
NewerOlder