Skip to content

Instantly share code, notes, and snippets.

/**
* @param {number[][]} board
* @return {void} Do not return anything, modify board in-place instead.
*/
var gameOfLife = function(board) {
let neighbors = [0, 1, -1];
let rows = board.length;
let cols = board[0].length;
let copyBoard = [];
copyBoard.length = rows;
@akrawchyk
akrawchyk / webpack.config.js
Last active June 27, 2017 20:28
Webpack vendor and modules example
var webpack = require('webpack');
var path = require('path');
module.exports = function(env) {
return {
entry: {
// main pages JS
page1: './page1/index.js',
page2: './page2/index.js',
@akrawchyk
akrawchyk / writing-css.md
Created February 20, 2017 19:35 — forked from jednano/writing-css.md
Writing CSS

Writing CSS

This project uses cssnext, which allows us to use emerging CSS features at design time and transpile into currently-supported, browser-compatible CSS at runtime.

Styles can be found in app/styles. Inside this folder, you should familiarize yourself with the following structure:

styles
├── config
│ ├── fonts.json
@akrawchyk
akrawchyk / crawler.js
Last active June 20, 2016 18:40
Streams HTML from phantomjs after document load as ndjson
/**
* Crawler
* PhantomJS writes to stream with content of crawled pages
* Streams HTML from phantomjs after document load as ndjson
*/
'use strict'
const ndjson = require('ndjson')
const phantom = require('phantom')
@akrawchyk
akrawchyk / gist:16ffe8c128e03e58b546
Created March 5, 2015 03:20
ternary operator js
var jobsCountRemaining = 2;
// ternary
var completed = jobsCountRemaining === 0 ? true : false;
return completed;
// if-else
if (jobsCountRemaining === 0) {
completed = true;
} else {
@akrawchyk
akrawchyk / inputToJSON
Last active August 29, 2015 14:00
Serialize input to JSON
/**
* Creates JSON for a single input field
*
* e.g. article[id] = 1 => { article: {id: 1}}
*
* @param {Node} inputElem - :input element to serialize
* @returns {object}
*/
var serializeInputToJSON = function(inputElem) {
var name = inputElem.name;
@akrawchyk
akrawchyk / entypo sass map
Created April 7, 2014 18:23
Using SASS maps to generate entypo icon font classes
$entypo-icons: (
search : \1f50d,
flag : \2691
// ...
);
@each $icon, $code in $entypo-icons {
.entypo-#{$icon}:before {
content: '#{$code}';
}
@akrawchyk
akrawchyk / random bootstrap popover content
Last active January 4, 2016 04:09
Replacing bootstrap popover content on each click
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>demo</title>
<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.3/css/bootstrap.min.css">
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.3/js/bootstrap.min.js"></script>
</head>
@akrawchyk
akrawchyk / SASS opposite direction function
Created September 27, 2013 19:45
Reverses a CSS direction, accepting a single direction or a list.
@function get-opposite-direction($direction) {
$opposite-direction: center;
@if $direction == top {
$opposite-direction: bottom;
}
@if $direction == bottom {
$opposite-direction: top;
}
@if $direction == left {
@akrawchyk
akrawchyk / SASS Bootstrap 3 grid
Last active December 23, 2015 11:39
Bootstrap 3 basic grid system in SCSS. Omits offsetting, nesting, and ordering for simplicity.
// variables
$bp-small: em(768) !default;
$bp-medium: em(992) !default;
$bp-large: em(1200) !default;
$grid-columns: 12 !default;
$grid-gutter-width: em(30) !default;
$grid-wrapper-small: em(750) !default;
$grid-wrapper-medium: em(970) !default;
$grid-wrapper-large: em(1170) !default;