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
# create a vector with multiple repeated elements | |
# v is "a" "a" "a" "a" "a" "b" "b" "b" | |
v<-c(rep('a', each=10), rep('b', each=3)) |
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
{ | |
"vars": { | |
"@gray-base": "#000", | |
"@gray-darker": "lighten(@gray-base, 13.5%)", | |
"@gray-dark": "lighten(@gray-base, 20%)", | |
"@gray": "lighten(@gray-base, 33.5%)", | |
"@gray-light": "lighten(@gray-base, 46.7%)", | |
"@gray-lighter": "lighten(@gray-base, 93.5%)", | |
"@brand-primary": "darken(#428bca, 6.5%)", | |
"@brand-success": "#5cb85c", |
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 Timer extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = {count: 10}; | |
} | |
componentDidMount() { | |
this.timerID = setInterval( | |
() => this.tick(), | |
1000 |
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 Game extends React.Component { | |
constructor(props) { | |
super(props); | |
let initialSquares = Array(4900).fill(null); | |
//set initial seed | |
let seed = [730, 800, 870]; | |
for (let i=0; i<seed.length; i++) { | |
initialSquares[seed[i]]="X"; | |
} | |
this.state = { |
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
//reference: https://reactjs.org/docs/state-and-lifecycle.html | |
class Counter extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = {count: 0}; | |
} | |
componentDidMount() { | |
this.timerID = setInterval( | |
() => this.tick(), |
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
#Code Wars kata solution | |
def damaged_or_sunk (board, attacks): | |
hits = [] | |
results = { 'sunk': 0, 'damaged': 0 , 'not_touched': 0, 'points': 0} | |
for attack in attacks: | |
x = attack[0]-1 | |
y = len(board)-attack[1] | |
if board[y][x] != 0: | |
hits.append(board[y][x]) | |
board[y][x] = "X" |
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
<div id="app"></app> |
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
<h1>Change Time</h1> | |
<input type='text' id='inputTime' name='time' /> | |
<div><input type='submit' id='submit-button' value='Start'/> | |
<button id='reset'> | |
Reset | |
</button> | |
<button id='reset'> | |
Stop | |
</button></div> | |
<div id='tomato'> |
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
<div id='main'> | |
<br/> | |
<h1 id='display'> | |
</h1> | |
<br> | |
<div id='buttons'> | |
<button class='num'> | |
1 | |
</button> | |
<button class='num'> |
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
//sum array of two numbers and all numbers in between | |
//positive numbers only | |
function sumAll(arr) { | |
var min = arr.reduce(function(a, b) { | |
return Math.min(a, b); | |
}); | |
var max = arr.reduce(function(a, b) { | |
return Math.max(a, b); | |
}); | |
if (min == max) { |
NewerOlder