Skip to content

Instantly share code, notes, and snippets.

View unionx's full-sized avatar
🦄
biu~biu~biu~

帝归 unionx

🦄
biu~biu~biu~
View GitHub Profile
@unionx
unionx / foobar.js
Last active March 26, 2020 15:09
JS promise
function foo() {
let p = new Promise(function(resolve, reject) {
setTimeout(function() {
console.log('foo');
resolve('foo111');
}, 1000);
});
return p;
}
@unionx
unionx / run.py
Created February 21, 2015 01:59
Try numba
#!/usr/bin/env python3
from numba import jit
from numpy import arange
import cProfile
##@jit
def sum2d(arr):
M, N = arr.shape
result = 0.0
@unionx
unionx / makeup
Created January 19, 2015 19:20
化妆品整理
#!/usr/bin/env python
makeupItem = {
'name': '香奈儿8号',
'category': '香水',
'price': 780,
'description': '一些评价blablabla'
}
@unionx
unionx / leancloud
Created January 16, 2015 13:43
Leancloud Python REST script
#!/usr/bin/env python3
import time
import json
import hashlib
import requests
appId = 'xxx'
appKey = 'xxx'
masterKey = 'xxx'
@unionx
unionx / RecursionMax.java
Created December 15, 2014 11:44
Use recursion in Java is not right
import java.util.*;
public class RecursionMax {
public static Integer max(LinkedList<Integer> numberList, Integer maxNumber) {
if (numberList.size() == 0) {
return maxNumber;
} else {
Integer firstNumber = numberList.get(0);
if (maxNumber < firstNumber) {
@unionx
unionx / cron.py
Last active August 29, 2015 14:08
Sample script for using plan to write cron files
#!/usr/bin/env python3
from plan import Plan
import argparse
cron = Plan()
# write the cron jobs here:
cron.command("/usr/bin/pganalyze-collector --cron", every="5.minute")
<!-- 随机名人名言代码开始 -->
<h3 style="margin-top:10px;">
<button id="click-me">Click Me!</button>
<left id="people-quote">
<!-- 可以把这里的 jquery 依赖放在本地 -->
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script type="text/javascript">
var butong_net = new Array(
'物理教授走过校园,遇到数学教授。物理教授在进行一项实验,他总结出一个经验方程,似乎与实验数据吻合,他请数学教授看一看这个方程。<br>一周后他们碰头,数学教授说这个方程不成立。可那时物理教授已经用他的方程预言出进一步的实验结果,而且效果颇佳,所以他请数学教授再审查一下这个方程。 <br> 又是一周过去,他们再次碰头。数学教授告诉物理教授说这个方程的确成立,但仅仅对于正实数的简单情形成立。',
@unionx
unionx / ask.py
Created April 28, 2014 19:52
对比一下CPython和PyPy的速度
#!/usr/bin/env python
import cProfile
def main():
for i in range(100000000):
i / 5.53892138021312312 * 23.23123121321321312
print(i)
cProfile.run("main()")
@unionx
unionx / reverse-it.clj
Last active December 19, 2015 05:19
丧心病狂的使用宏的方法
(require '(clojure [string :as string]
[walk :as walk]))
;; page 236 on <Clojure Programming>
(defmacro reverse-it [form]
(walk/postwalk #(if (symbol? %)
(symbol (string/reverse (name %)))
%)
form))
@unionx
unionx / reduction1.clj
Created December 3, 2012 22:19
4clojure #60
(fn reduction1
([f col]
(reduction1 f (f (first col)) (rest col)))
([f val col]
(if (empty? col)
(list val)
(cons val (lazy-seq (reduction1 f (f val (first col)) (rest col)))))))