Skip to content

Instantly share code, notes, and snippets.

# 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))
@ashlynnpai
ashlynnpai / config.json
Created December 15, 2017 04:09 — forked from anonymous/config.json
Bootstrap Customizer Config
{
"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",
@ashlynnpai
ashlynnpai / timer.js
Created December 11, 2017 18:56
Timer countdown using React
class Timer extends React.Component {
constructor(props) {
super(props);
this.state = {count: 10};
}
componentDidMount() {
this.timerID = setInterval(
() => this.tick(),
1000
@ashlynnpai
ashlynnpai / game.js
Created December 9, 2017 05:19
first draft of game of life with react
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 = {
@ashlynnpai
ashlynnpai / counter.js
Last active December 8, 2017 16:32
counter in React
//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(),
#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"
@ashlynnpai
ashlynnpai / index.html
Created November 3, 2017 23:39
Leaderboard
<div id="app"></app>
@ashlynnpai
ashlynnpai / index.html
Last active October 11, 2017 14:30
Pomodoro Timer
<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'>
@ashlynnpai
ashlynnpai / index.html
Created October 9, 2017 20:47
Calculator
<div id='main'>
<br/>
<h1 id='display'>
</h1>
<br>
<div id='buttons'>
<button class='num'>
1
</button>
<button class='num'>
//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) {