Skip to content

Instantly share code, notes, and snippets.

View cAstraea's full-sized avatar

cAstraea

View GitHub Profile
@cAstraea
cAstraea / auth.js
Last active August 15, 2017 20:12
for messenger account linking
'use strict';
require('dotenv').config();
const express = require('express');
const router = express.Router();
const bodyParser = require('body-parser');
const LINKED = {};
const question = {};
const http = require('http');
@cAstraea
cAstraea / .eslintrc
Last active February 10, 2017 09:44
my .eslint
{
// babel parser to support ES6/7 features
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 7,
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": true
},
"sourceType": "module"
@cAstraea
cAstraea / breakwords2.js
Last active February 6, 2017 15:20
breakwords dynamic javascript implementation https://www.youtube.com/watch?v=WepWFGxiwRs
function StringBuffer() {
this.__strings__ = [];
}
StringBuffer.prototype.append = function (str) {
this.__strings__.push(str);
};
StringBuffer.prototype.toString = function () {
@cAstraea
cAstraea / breakwords.js
Created February 6, 2017 12:34
break string into substring reccursive solution
function breakWord(stringToBreak, dictionary) {
if(dictionary.has(stringToBreak)) return stringToBreak;
var length = stringToBreak.length;
for (var i=1; i < length; i++) {
var prefix = stringToBreak.substring(0, i);
if(dictionary.has(prefix)) {
var sufix = stringToBreak.substring(i, length);
var segSufix = breakWord(sufix, dictionary);
if(segSufix != null) {
@cAstraea
cAstraea / gist:222af59643b48922dd3865741d9cf25e
Created February 6, 2017 12:20
break string into two segments if found in dictionary
function breakWord(stringToBreak, dictionary) {
for (var i = 1; i <= stringToBreak.length; i++) {
var prefix = stringToBreak.substring(0, i);
if(dictionary.has(prefix)) {
var suffix = stringToBreak.substring(i, stringToBreak.length);
@cAstraea
cAstraea / tanks.js
Created January 31, 2017 10:36
javascript solution, Finds the minimum number of moves required to rearrange the tanks so that each row and each column contains a single tank, and one such shortest sequence of moves
process.stdin.resume();
process.stdin.setEncoding('ascii');
let input_stdin = '';
let input_stdin_array = '';
let input_currentline = 0;
process.stdin.on('data', (data) => {
input_stdin += data;
@cAstraea
cAstraea / testing
Created October 5, 2016 17:28
ES6 class
class Monster {
constructor({name}) {
this.health = 100;
this.name = name;
}
}
class Snake extends Monster {
constructor(options) {
super(options);
var production = process.env.NODE_ENV === 'production';
var path = require('path');
var webpack = require('webpack');
var UnminifiedWebpackPlugin = require('unminified-webpack-plugin');
module.exports = {
entry: {
product: './web/js/productApp.js'
},
output: {