Skip to content

Instantly share code, notes, and snippets.

View JBreit's full-sized avatar

Jason Breitigan JBreit

  • Inner Mind Co.
  • Lancaster, PA
View GitHub Profile
@JBreit
JBreit / observable.js
Created June 4, 2017 20:15
Observable
const node = document.querySelector('input[name="test"]');
const p = document.querySelector('p');
function Observable(subscribe) {
this.subscribe = subscribe;
}
Observable.fromEvent = (element, name) => {
return new Observable((observer) => {
const callback = (event) => observer.next(event);
@JBreit
JBreit / daemon.js
Created May 31, 2017 01:27
Linux Node JS HTTP Daemon
#!/usr/bin/env node
/**
* bin/daemon
* A simple Linux HTTP Daemon
*/
require('daemon')();
const cluster = require('cluster');
const strategies = {
cacheFirst(request) {
return caches.open(APPLICATION_CACHE).then((cache) => {
return cache.match(request).then((matching) => {
return matching || Promise.reject('no-match');
});
});
},
networkFirst(request, delay) {
return new Promise((resolve, reject) => {
#!/usr/bin/env node
const { log } = require('./logger');
switch (process.argv[2]) {
case 'start':
log('start command detected');
break;
case 'stop':
log('stop command detected');
const { Console } = require('console');
const { createWriteStream } = require('fs');
const output = createWriteStream('./stdout.log');
const errorOutput = createWriteStream('./stderr.log');
const logger = new Console(output, errorOutput);
module.exports = logger;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
namespace TestTrapCtrlC {
public class Program {
static bool exitSystem = false;
const { spawn } = require('child_process')
const { existsSync, readdirSync, lstatSync, unlinkSync, rmdirSync } = require('fs')
const utils = {
/**
* Convert an options object into a valid arguments array for the child_process.spawn method
* from:
* var options = {
* foo: 'hello',
* baz: 'world'

TypeScript Node Starter

Dependency Status Build Status

Live Demo: TODO

Pre-reqs

module.exports = {
entry: "./src/main.js",
output: {
filename: "./dist/bundle.js"
},
module: {
loaders: [{
test: [/\.js$/, /\.es6$/],
exclude: /node_modules/,
@JBreit
JBreit / Gruntfile.js
Created May 10, 2017 03:07 — forked from eliotfowler/Gruntfile.js
Sample Gruntfile
module.exports = function (grunt) {
// Load grunt tasks automatically
require('load-grunt-tasks')(grunt);
// Time how long tasks take. Can help when optimizing build times
require('time-grunt')(grunt);
// Define the configuration for all the tasks
grunt.initConfig({