Skip to content

Instantly share code, notes, and snippets.

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

NothingRealHappen nothingrealhappen

🏠
Working from home
  • Mars
View GitHub Profile
@nothingrealhappen
nothingrealhappen / canvasWaterMark
Last active August 29, 2015 14:18
canvasWaterMark
真的搞不定语法高亮
@nothingrealhappen
nothingrealhappen / 敢来挑战一下你的智商吗?
Last active August 29, 2015 14:18
【每日一题】2015年3月31日
We couldn’t find that file to show.
@nothingrealhappen
nothingrealhappen / 甘大大出的题目
Created March 31, 2015 10:51
20150331「每日一题」怕了么?
We couldn’t find that file to show.
大厅里有100盏灯,每盏灯都编了号码,分别为1-100。每盏灯由一个开关来控制。(开关按一下,灯亮,再按一下灯灭。开关的编号与被控制的灯相同。)开始时,灯是全灭的。现在按照以下规则按动开关。
第一次,将所有的灯点亮。
第二次,将所有2的倍数的开关按一下。
第三次,将所有3的倍数的开关按一下。
以此类推。第N次,将所有N的倍数的开关按一下。
问第N次(N大于等于2,且小于等于100)按完以后,大厅里还有几盏灯是亮的。
请编程实现上面的逻辑,以N为参数
$(function() {
var share = {
title: '放手放脚体验高速急刹车 9位科技大咖亲测沃尔沃自动驾驶',
desc: '全球首个自动驾驶路试项目 Drive Me Truest Me 自动驾到 谁敢来约',
link: 'http://geekpark.net/zhuanti/volvo/mobile.html',
icon: 'http://geekpark-img.qiniudn.com/volvo-guestshare.jpg'
};
(function() {
@nothingrealhappen
nothingrealhappen / gist:b5ee4c52db33310b89e8
Last active August 29, 2015 14:24
Functional Javascript | Recursion
/*
Recursion is a fundamental programming concept which can lead to elegant and efficient solutions to algorithmic problems. In fact, recursion is so powerful, all iterating behaviour can be defined using recursive functions. You will find recursion indispensable when iterating over nested data structures.
A recursive function is a function which calls itself. For example, this recursive function will take an array of words, and return an array of those words, uppercased.
*/
function toUpperArray(items) {
if (!items.length) return [] // end condition
var head = items[0] // item to operate on
head = head.toUpperCase() // perform action
var tail = items.slice(1) // next
```javascript
const cat = (head, ...items) => head.length ? head.concat.apply(head, items) : [];
const flat = arr => Array.isArray(arr) ? cat.apply(cat, arr.map(flat)) : [arr];
```
@nothingrealhappen
nothingrealhappen / surge_main.conf
Created October 30, 2015 07:41 — forked from jason5ng32/surge.conf
Surge Configs ( Both 2 files are needed )
[General]
loglevel = notify
skip-proxy = 192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12,127.0.0.0/24,100.64.0.0/10
bypass-tun = 0.0.0.0/8, 1.0.0.0/9, 1.160.0.0/11, 1.192.0.0/11, 10.0.0.0/8, 14.0.0.0/11, 14.96.0.0/11, 14.128.0.0/11, 14.192.0.0/11, 27.0.0.0/10, 27.96.0.0/11, 27.128.0.0/9, 36.0.0.0/10, 36.96.0.0/11, 36.128.0.0/9, 39.0.0.0/11, 39.64.0.0/10, 39.128.0.0/10, 42.0.0.0/8, 43.224.0.0/11, 45.64.0.0/10, 47.64.0.0/10, 49.0.0.0/9, 49.128.0.0/11, 49.192.0.0/10, 54.192.0.0/11, 58.0.0.0/9, 58.128.0.0/11, 58.192.0.0/10, 59.32.0.0/11, 59.64.0.0/10, 59.128.0.0/9, 60.0.0.0/10, 60.160.0.0/11, 60.192.0.0/10, 61.0.0.0/10, 61.64.0.0/11, 61.128.0.0/10, 61.224.0.0/11, 100.64.0.0/10, 101.0.0.0/9, 101.128.0.0/11, 101.192.0.0/10, 103.0.0.0/10, 103.192.0.0/10, 106.0.0.0/9, 106.224.0.0/11, 110.0.0.0/7, 112.0.0.0/9, 112.128.0.0/11, 112.192.0.0/10, 113.0.0.0/9, 113.128.0.0/11, 113.192.0.0/10, 114.0.0.0/9, 114.128.0.0/11, 114.192.0.0/10, 115.0.0.0/8, 116.0.0.0/8, 117.0.0.0/9, 117.128.0.0/10, 118.0.0.0/11, 118.64.0.0/10, 118.128.0.0
# general
color default 15 235
color cursor 15 241
color title-focus 242 221
color title-blur 242 221
color delimiter 213 default
color author 156 default
color date 33 default
color line-number 221 default
color mode 255 default
@nothingrealhappen
nothingrealhappen / webpack.config.js
Last active December 4, 2015 07:06
webpack config
const path = require('path');
const webpack = require('webpack'); const IS_PRODUCTION = process.env.NODE_ENV === 'production';
const OUT_DIR = path.join(__dirname, './bundle/');
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
var config = {
context: __dirname,
entry: {
home: './src/home.js'
},