Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am cheerazar on github.
  • I am cheerazar (https://keybase.io/cheerazar) on keybase.
  • I have a public key ASADymxiS3SJ2tFWq_qnl7UHrquAuK9J2Ca0rv_d7wM0yAo

To claim this, I am signing this object:

@Cheerazar
Cheerazar / readTabDelimitedFile.js
Created December 13, 2017 22:44
Node script to read tab delimited files and to process
const fs = require('fs');
const path = require('path');
module.exports = filename =>
new Promise((resolve, reject) => {
fs.readFile(path.join(__dirname, 'data', filename), 'utf8', (err, data) => {
if (err) {
return reject(err);
}
@Cheerazar
Cheerazar / index.js
Last active December 13, 2017 22:45
Read tab delimited files and process them
const readTabDelimitedFile = require('./readTabDelimitedFile');
/*
products.tab = A list of product names tab delimited with categories
sales.tab = A list of product names tab delimited with sales amount
From this data we'd like you to answer two questions:
* What category has the highest average sales price? (Please include the average sale price)
* What is the minimum and maximum sale in the category 'Breakfast'
*/
@Cheerazar
Cheerazar / flatten.js
Created December 5, 2017 15:21
Method to flatten nested arrays using reduce and spread syntax
// Must be using node version 5.12 or greater to use the
// spread syntax
// recursively go through the array of inputs and flatten
// them appropriately.
const flatten = inputs =>
inputs.reduce((total, next) => {
if (Array.isArray(next)) {
return [...total, ...flatten(next)];
}
@Cheerazar
Cheerazar / store.js
Created November 24, 2017 17:26
An example redux store that composes the middleware together using the globally available redux devtools compose or the compose method of redux
import { compose, createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import reducers from '../reducers';
const middleware = [thunk];
// eslint-disable-next-line no-underscore-dangle
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
export default createStore(reducers, composeEnhancers(applyMiddleware(...middleware)));
@Cheerazar
Cheerazar / iterm2-solarized.md
Created October 28, 2016 20:48 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font (OS X / macOS)

Solarized

@Cheerazar
Cheerazar / 0.2.1-boggle_class_from_methods.rb
Created January 4, 2014 15:21 — forked from dbc-challenges/0.2.1-boggle_class_from_methods.rb
phase 0 unit 2 week 1 boggle class challenge
class BoggleBoard
#your code here
end
dice_grid = [["b", "r", "a", "e"],
["i", "o", "d", "t"],
["e", "c", "l", "r"],