Skip to content

Instantly share code, notes, and snippets.

View oHaiyang's full-sized avatar
🦀
Coding Rust

Haiyang Peng oHaiyang

🦀
Coding Rust
View GitHub Profile
0
@oHaiyang
oHaiyang / twoWayBind.html
Last active June 12, 2017 01:28
一个模仿的模仿 Vue 的双向绑定实现
<!-- 参考原链接: http://www.cnblogs.com/kidney/p/6052935.html?utm_source=gold_browser_extension -->
<div id="app">
<input type="text" v-model="text"/>
{{text}}
</div>
<script>
function compile(dom, vm) {
const frag = document.createDocumentFragment();
@oHaiyang
oHaiyang / imageToBase64
Created April 18, 2017 03:01
Convert image to base64 from URL
static getDataUri (url) {
return new Promise((resolve, reject) => {
var image = new window.Image()
image.crossOrigin = 'Anonymous'
image.onload = function () {
var canvas = document.createElement('canvas')
window.alert('创建了 Canvas')
window.alert(canvas)
canvas.width = image.width
@oHaiyang
oHaiyang / build.log
Created September 26, 2016 08:35
cordova-plugin-rongcloud-im build ios failed
❯ cordova build ios
Building project: /Users/penghaiyang/Coding/chaodp_cordova/platforms/ios/Chaodp.xcodeproj
Configuration: Debug
Platform: emulator
Build settings from command line:
CONFIGURATION_BUILD_DIR = /Users/penghaiyang/Coding/chaodp_cordova/platforms/ios/build/emulator
SDKROOT = iphonesimulator10.0
SHARED_PRECOMPS_DIR = /Users/penghaiyang/Coding/chaodp_cordova/platforms/ios/build/sharedpch
Build settings from configuration file '/Users/penghaiyang/Coding/chaodp_cordova/platforms/ios/cordova/build-debug.xcconfig':
function wrapValue(n) {
return function() {
return n += 2;
};
}
var wrap1 = wrapValue(1);
console.log(wrap1()); //-> 1
console.log(wrap1());
@oHaiyang
oHaiyang / ack.c
Created September 21, 2014 12:14
A implement of Ackermann function
#include <stdio.h>
#include <stdlib.h>
#define MAXSIZE 50000
struct stack {
int top;
int m[MAXSIZE];
int n[MAXSIZE];
int s[MAXSIZE];
@oHaiyang
oHaiyang / queens.c
Last active August 29, 2015 14:06
Dumb exploration of the N Queens Puzzle
#include <stdio.h>
#include <stdlib.h>
#define MAXSIZE 1000
static int call_init_canvas = 0;
static int call_save_stack = 0;
static int call_add_ret = 0;
static int call_set_rock = 0;
static int call_kick_rock = 0;