Skip to content

Instantly share code, notes, and snippets.

View NeuTrix's full-sized avatar

michael j. Walker NeuTrix

  • BrandGeneering.com
  • San Franciscos, LA, Las Vegas
View GitHub Profile
@NeuTrix
NeuTrix / gist:915736e6c3a3752c6906f41bbd127d57
Created January 16, 2019 17:02
package.json for React Redux CRUD toy app
{
"name": "date_trader",
"version": "0.0.1",
"description": "Basic CRUD template in React and Redux",
"main": "index.js",
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
@NeuTrix
NeuTrix / eslintrc.json: airbnb styleguide
Last active February 4, 2019 18:34
eslintrc.json for airbnb styleguide. Place in the root folder of js application
{
"env": {
"browser": true,
"es6": true,
"node": true,
"jest": true
},
"extends": [
"airbnb",
"plugin:jsx-a11y/recommended",
@NeuTrix
NeuTrix / Codility: FrogJmp JavaScript solution
Last active July 13, 2018 04:15
Solution in JavaScript warning: parseInt() is nutty!
function solution(X, Y, D) {
let range = (Y - X); // max distance to go
// special cases
let hops = D === Y ? 0 : parseInt(range / D); // whole jumps [1]
let extra = range % D; // any left over hops required
console.log(`===>| X:${X} | Y:${Y} | D:${D} | range:${range} | hops:${hops} | extra:${extra} |`)
return extra ? hops + 1 : hops
}
// [1] parseInt() [at least in Chrome] exhibits wonky behavior when working with small fractions. For example:
@NeuTrix
NeuTrix / Codility: PermCheck. JavaScript solution
Created July 12, 2018 02:46
A simple javascript solve to the Codility PermCheck challenge
// ===== ANSWER:
function solution(A) {
let set = new Set(); // holds a unique set of values
let max = 1; // largest number in set
let min = 1; // smallest number in set
let n = A.length
for (let i = 0; i < n; i += 1) {
let num = A[i];
@NeuTrix
NeuTrix / Codility Stonewall Solution Using JavaScript Stack
Last active July 12, 2018 02:48
Cover "Manhattan skyline" using the minimum number of rectangles in JavaScript
// ===== ANSWER
function solution(H) {
// write your code in JavaScript (Node.js 8.9.4)
let stack = [];
let count = 0;
let height = 0;
// adds a block to the stack when value exceeds current height
const addBlock = (value) => {
@NeuTrix
NeuTrix / gist:b3b0a570efbb4793ca489482a2bf2965
Created October 10, 2017 20:54
sublime User preferences
{
"color_scheme": "Packages/Color Scheme - Default/iPlastic.tmTheme",
"font_size": 16,
"ignored_packages":
[
"Vintage"
],
"rulers":
[
70
@NeuTrix
NeuTrix / How to start a new GitHub repo
Last active September 14, 2016 06:25
Start a New Git Repo
http://kbroman.org/github_tutorial/pages/init.html
git/github guide
**Start a new git repository**
Your first instinct, when you start to do something new, should be git init. You’re starting to write a new paper, you’re writing a bit of code to do a computer simulation, you’re mucking around with some new data … anything: think git init.
A new repo from scratch
Say you’ve just got some data from a collaborator and are about to start exploring it.
Create a directory to contain the project.
Go into the new directory.
`rails new (Application Name) -d postgresql -T
@lalkmim
lalkmim / codility_solutions.txt
Last active April 25, 2024 21:47
Codility Solutions in JavaScript
Lesson 1 - Iterations
- BinaryGap - https://codility.com/demo/results/trainingU2FQPQ-7Y4/
Lesson 2 - Arrays
- OddOccurrencesInArray - https://codility.com/demo/results/trainingFN5RVT-XQ4/
- CyclicRotation - https://codility.com/demo/results/trainingSH2W5R-RP5/
Lesson 3 - Time Complexity
- FrogJmp - https://codility.com/demo/results/training6KKWUD-BXJ/
- PermMissingElem - https://codility.com/demo/results/training58W4YJ-VHA/
@danielstocks
danielstocks / gist:5da83982d3b4c7b503a0
Created October 17, 2014 11:38
Pretty print a JavaScript Tree Data Structure
// Example implementation: http://jsfiddle.net/2f7w2fpn/
var indent = 1;
function walk(tree) {
tree.forEach(function(node) {
console.log('--' + Array(indent).join('--'), node.key);
if(node.children) {
indent ++;
walk(node.children);
}