Skip to content

Instantly share code, notes, and snippets.

View fbukevin's full-sized avatar
🏠
Working from home

Veck Hsiao fbukevin

🏠
Working from home
View GitHub Profile
@fbukevin
fbukevin / loadJSON.java
Created December 28, 2016 16:39
Load JSON file in Android
public JSONObject loadJSON(Context cxt, String file) {
JSONObject json = null;
try {
InputStream is = cxt.getAssets().open(file);
int size = is.available();
byte[] buffer = new byte[size];
is.read(buffer);
is.close();
String data = new String(buffer, "UTF-8");
json = new JSONObject(data);
import Foundation
class TimeTool {
func getCurrentTimeString() -> String {
let now = Date()
let df = DateFormatter()
df.dateFormat = "YYYY/MM/dd HH:mm:ss"
return df.string(from: now)
@fbukevin
fbukevin / loadText.swift
Created December 28, 2016 16:35
Load general text file in Swift 3
func loadText(file: String, handler: (String) -> Void){
if let path = Bundle.main.path(forResource: file, ofType: "txt") {
do {
let context = try String(contentsOfFile: path, encoding: .utf8)
handler(context)
} catch {
print(error.localizedDescription)
}
}
}
@fbukevin
fbukevin / loadJSON.swift
Created December 28, 2016 16:34
Load JSON file in Swift 3
func loadJSON(file: String, handler: (NSDictionary) -> Void){
if let path = Bundle.main.path(forResource: file, ofType: "json") {
do {
let jsonData = try NSData(contentsOfFile: path, options: NSData.ReadingOptions.mappedIfSafe)
do {
let json: NSDictionary = try JSONSerialization.jsonObject(with: jsonData as Data
, options: JSONSerialization.ReadingOptions.mutableContainers) as! NSDictionary
handler(json)
} catch {
print("Parse json failed")
@fbukevin
fbukevin / Procfile
Created November 23, 2016 05:30 — forked from mojodna/Procfile
Getting Kue working on Heroku
web: node app.js
worker: node consumer.js
@fbukevin
fbukevin / snap.animAlongPath.html
Last active January 22, 2016 09:02
Snap Plugin - Animate along path
<script src="snap.svg-min.js"></script>
<script src="snap.tool.js"></script>
<svg id="snap_demo" width="640" height="480" xmlns="http://www.w3.org/2000/svg">
<!-- Created with SVG-edit - http://svg-edit.googlecode.com/ -->
<g>
<title>Layer 1</title>
<path id="svg_4" d="m229,96c0,0 -105,104 -105,104c0,0 97,124 97,124c0,0 139,-2 139,-2c0,0 69,-101 69,-101c0,0 -78,-124 -78,-124c0,0 -122,-1 -122,-1z" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="null" stroke-width="5" stroke="#edd7d7" fill="none"/>
<rect fill="none" stroke="#000000" stroke-width="5" stroke-dasharray="null" stroke-linejoin="null" stroke-linecap="null" x="232" y="278" width="1" height="0" id="svg_3"/>
<circle fill="#000000" stroke="#000000" stroke-width="5" stroke-dasharray="null" stroke-linejoin="null" stroke-linecap="null" cx="284" cy="96" r="6.7082" id="svg_9">
@fbukevin
fbukevin / snap.animAlongPath.js
Created January 22, 2016 08:59
Snap.svg plug - Animate along path
Snap.plugin(function (Snap, Element, Paper, glob, Fragment) {
var elproto = Element.prototype;
elproto.animateAlongPath = function (path, el, start, duration, easing) {
var callback = this;
el.transform('t0,0');
var len = Snap.path.getTotalLength(path),
elBB = el.getBBox(),
elCenter = {
x: elBB.x + (elBB.width / 2),
y: elBB.y + (elBB.height / 2),
main:
@ args = 0, pretend = 0, frame = 16
@ frame_needed = 1, uses_anonymous_args = 0
push {r7, lr}
sub sp, sp, #16
add r7, sp, #0
movs r3, #10
str r3, [r7, #4]
movs r3, #12
str r3, [r7, #8]
main:
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, uses_anonymous_args = 0
@ link register save eliminated.
movs r0, #22
bx lr
.size main, .-main
.text
.align 2
.global add