This file contains hidden or 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
| { | |
| "name": "commonjs-smart-asset", | |
| "version": "1.0.0", | |
| "private": true, | |
| "description": "An example for https://github.com/sormy/rollup-plugin-smart-asset/issues/22 .", | |
| "keywords": [], | |
| "author": "", | |
| "license": "ISC", | |
| "devDependencies": { | |
| "@rollup/plugin-commonjs": "^18.0.0", |
This file contains hidden or 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 random | |
| import genetic.individuals import SingleChromosomeIndividual | |
| import genetic.selection import bimodal | |
| import genetic.populations import PanmicticPopulation | |
| # 需要定义 data 变量 | |
This file contains hidden or 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 numpy as np | |
| class MLP(object): | |
| def __init__(self, init_r1=0.001, init_r2=0.001, init_hidden_nodes=10, init_max_iter=100000): | |
| self._r1 = init_r1 | |
| self._r2 = init_r2 | |
| self._hidden_nodes = init_hidden_nodes | |
| self._max_iter = init_max_iter |
This file contains hidden or 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 numpy as np | |
| class Perceptron(object): | |
| def __init__(self, init_r=0.01, init_max_iter=100000): | |
| # the parameter to optimized. | |
| self._w = None | |
| self._theta = None | |
This file contains hidden or 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
| " tmux will only forward escape sequences to the terminal if surrounded by a DCS sequence | |
| " http://sourceforge.net/mailarchive/forum.php?thread_name=AANLkTinkbdoZ8eNR1X2UobLTeww1jFrvfJxTMfKSq-L%2B%40mail.gmail.com&forum_name=tmux-users | |
| if exists('$TMUX') | |
| let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\" | |
| let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\" | |
| else | |
| let &t_SI = "\<Esc>]50;CursorShape=1\x7" | |
| let &t_EI = "\<Esc>]50;CursorShape=0\x7" | |
| endif |
This file contains hidden or 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/bash | |
| USERNAME= # YOUR USERNAME HERE | |
| PASSWORD= # YOUR PASSWORD HERE | |
| case $1 in | |
| "on") | |
| out=`curl 'https://ipgw.neu.edu.cn/srun_portal_pc.php?ac_id=1&' -H 'Origin: http://ipgw.neu.edu.cn' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: zh-CN,en;q=0.8' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Cache-Control: max-age=0' -H 'Referer: http://ipgw.neu.edu.cn/srun_portal_pc.php?ac_id=1&' -H 'Connection: keep-alive' -H 'DNT: 1' --data "action=login&ac_id=1&user_ip=&nas_ip=&user_mac=&url=&username=$USERNAME&password=$PASSWORD&save_me=0&ajax=1" --compressed --silent` | |
| if [[ $out == login_ok* ]]; then | |
| echo "登录成功" |
This file contains hidden or 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: utf8 | |
| class StateMachine(object): | |
| """ A state machine targeting the singleton update process. | |
| A normal workflow will look like: | |
| >>> sm = StateMachine('init') | |
| >>> @sm.state('init') | |
| >>> def init(): |
This file contains hidden or 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
| # 函数节流方案 | |
| # 延迟函数执行,降低触发频率 | |
| throttle = (fn, intv=500) -> | |
| firstTime = on | |
| timer = null | |
| () -> | |
| args = arguments | |
| if firstTime |
This file contains hidden or 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
| def agent_utility(board, pos, mark, step=1): | |
| if board[pos] == 0: | |
| board = board.copy() | |
| board[pos] = mark | |
| if step == 1: | |
| return ( | |
| -sum(sum(1 if count_nonzero(r==0) + count_nonzero(r==-mark) == 3 else 0 for r in m) for m in [board, board.T, board.flat[[[0, 4, 8], [2, 4, 6]]]]), | |
| sum(sum(1 if count_nonzero(r==0) + count_nonzero(r==mark) == 3 else 0 for r in m) for m in [board, board.T, board.flat[[[0, 4, 8], [2, 4, 6]]]]), | |
| min(min(3-count_nonzero(r==-mark) if count_nonzero(r==0) + count_nonzero(r==-mark) == 3 else 3 for r in m) for m in [board, board.T, board.flat[[[0, 4, 8], [2, 4, 6]]]]) | |
| ) |
This file contains hidden or 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 java.awt.BufferedImage; | |
| import java.awt.Component; | |
| import javax.imageio.ImageIO; | |
| /** | |
| * A piece of code describing how to capture the screen of a component. | |
| * | |
| * @author yfwz100 | |
| */ |
NewerOlder