- install percol
- .bashrc:
bind -x '"\C-R": READLINE_LINE=$(history | tac | cut -c 8- | percol --query "${READLINE_LINE}") READLINE_POINT='
- .bashrc:
export HISTCONTROL=ignoreboth:erasedups
This file contains 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
// Reverse a string, e.g., '321' -> '123' | |
s.split('').reverse().join('') | |
// Give a random number within a range [a,b) | |
Math.random() * (b - a) + a; | |
// XOR swap | |
x = x^y; | |
y = x^y; | |
x = x^y; |
This file contains 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
class Clock extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = {date: new Date()}; | |
} | |
componentDidMount() { | |
this.timerID = setInterval( | |
() => this.tick(), | |
1000 |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
%% KFY shuffle | |
n = 3; | |
max_iter = 1e5; | |
count = zeros(17,1); | |
for iter = 1:max_iter | |
a = 1:n; | |
for i = n:-1:2 | |
j = randi(i,1,1); | |
t = a(i); | |
a(i) = a(j); |