Skip to content

Instantly share code, notes, and snippets.

@robbiemu
robbiemu / pure functions.js
Last active October 22, 2020 15:31
ES2022 wishes
a = 1
function f(x) {
return x + a
}
@pure function g(x) {
return x + a
}
@robbiemu
robbiemu / patriot.js
Last active August 11, 2017 12:14
results from my initial interview with Patriot consulting, and 1 night's sleep to realize that I could have shown a basic data structure
//2. Remove duplicate characters from a string (ABCdeABCfg -> ABCdefg)
/* build a string by ensuring that it does not already have letters in before adding */
function dedup (dupped) {
deduped = '' // start with an empty string
dupped
.split('') // get an array of letters from the input
.forEach(l => { // for every letter in the array
if(deduped.indexOf(l) === -1) // if the string we are building does not contain it
deduped += l // add it (only once)
/* I was not happy with my original version ... but I couldn't quiet grasp what was meant by combination. I now think of it as an "ordered combination". You must keep an index to get the set prescribed. This took me a while to realize and then more time to code and debug. */
const flatten = list => list.reduce(
(a, b) => a.concat(Array.isArray(b) ? flatten(b) : b), []
)
class IndexedSubstring {
constructor ({string, index}) {
this.string = string
this.index = index
}
function splitAllWays(result, left, right){
result.push(left.concat(right));
if (right.length > 1){
for(var i = 1; i < right.length; i++){
splitAllWays(result, left.concat(right.substring(0, i)), right.substring(i));
}
}
return result;
};
{
"-KbvAXsd8EC4Ig12gsRR": {
"department": "CMST",
"description": "A study of web design, tools, and technology principles. The goal is to plan and produce a professional website. Topics include Internet protocols; usability; accessibility; and social, ethical, and legal issues related to website production. Focus is on Extensible HyperText Markup Language (XHTML) and cascading style sheets (CSS).",
"equivalencies": [
{
"department": "CAPP",
"number": "385"
}
],
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const BUILD_DIR = 'build'
module.exports = {
entry: './scripts/webpack_loader.js',
output: {
path: BUILD_DIR + '/scripts',
filename: "bundle.js"
@robbiemu
robbiemu / gulpfile.js
Created December 24, 2016 17:08
simon gulpfile
const gulp = require('gulp')
const plumber = require('gulp-plumber')
const rename = require('gulp-rename')
const autoprefixer = require('gulp-autoprefixer')
const babel = require('gulp-babel')
const concat = require('gulp-concat')
const sass = require('gulp-sass')
const browserSync = require('browser-sync')
const clean = require('gulp-clean')
const sourcemaps = require('gulp-sourcemaps');
let languages = (navigator.languages === undefined)?
[ (navigator.language || navigator.userLanguage).substr(0, 2) ] :
$.unique(navigator.languages.map(f=> f.substr(0,2)))
@robbiemu
robbiemu / (original problem) gulpfile.babel.js
Last active September 17, 2016 17:25
having trouble with this gulp
var gulp = require('gulp');
var plumber = require('gulp-plumber');
var rename = require('gulp-rename');
var autoPrefixer = require('gulp-autoprefixer');
//if node version is lower than v.0.1.2
//require('es6-promise').polyfill();
var cssComb = require('gulp-csscomb');
var cmq = require('gulp-merge-media-queries');
var cleanCss = require('gulp-clean-css');
var browserify = require('gulp-browserify');
@robbiemu
robbiemu / ViaCEP_service.js
Created August 25, 2016 14:14
angular service for ViaCEP REST form automation (CEPs are brazilian zipcodes)
angular.module('app').service('ViaCEPService', ['$rootScope',
function($rootScope) {
const __validation_CEP = function (bool, form, dados) {
if(bool){
$(form + ' input[name=rua]').val(dados.logradouro)
$(form + ' input[name=bairro]').val(dados.bairro)
$(form + ' input[name=cidade]').val(dados.localidade)
$(form + ' input[name=estado]').val(dados.uf)
$(form + ' input[name=pais]').val('Brasil')