Skip to content

Instantly share code, notes, and snippets.

View efleming969's full-sized avatar

Erick Fleming efleming969

  • Fleming Services, LLC
  • Frankfort, KY
View GitHub Profile
@efleming969
efleming969 / sample-database.js
Created February 24, 2017 18:50
nodejs-training-database
var Sqlite = require( "sqlite3" ).verbose()
var db = new Sqlite.Database( "members.db" )
db.serialize( function() {
db.run("DROP TABLE IF EXISTS members" )
db.run("CREATE TABLE members(id varchar(255), name varchar(255), default_plan varchar(255))")
db.run("INSERT INTO members(id, name, default_plan) VALUES('1', 'john', '')")
console.log( "databse was setup!" )
@efleming969
efleming969 / notes.md
Created February 17, 2017 15:28
Nodejs Training 1

Exersice 1

Read a CSV file and convert it to a list of JavaScript Objects

  1. Place index.js and plans.csv in a directory
  2. run the application using the following command: node index.js
  3. Complete the application
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
var assert = require("chai").assert
var agent = require("superagent");
describe( "sanity test", function () {
this.timeout(10000);
it( "sanity post", function ( done ) {
agent.post( "http://httpbin.org/post" )
.send( {name:"foo"} )
package example;
import java.util.*;
import java.io.*;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import org.junit.*;
@efleming969
efleming969 / test.js
Created August 7, 2016 15:19
JavaScript stubbing example
it( 'stubbing example', function() {
var b = new main.DataService();
var a = new main.Foo( b );
sinon.stub( b, "lookupMultiplier" ).returns( 2 );
var result = a.calculateValueUsingLookup( 5 );
assert.equal( result, 10 );
@efleming969
efleming969 / score-sheet.html
Created December 10, 2015 17:20
Basic Bowling Scoresheet
<!doctype html>
<head>
<style>
.ScoreSheet {
display: flex;
}
.ScoreSheet-Frame {
display: inline-block;
@efleming969
efleming969 / idb-samples.js
Created November 3, 2015 20:00
snippets for working with indexeddb object stores
exports.getLowerBounds = function()
{
var openReq = indexedDB.open( databaseName )
openReq.onsuccess = function( e )
{
var idb = e.target.result
var transaction = idb.transaction( objectStoreName, "readonly" )
var objectStore = transaction.objectStore( objectStoreName )
var keyRangeValue = IDBKeyRange.lowerBound( 18 )
@efleming969
efleming969 / bowling-rules.md
Created October 5, 2015 17:30
The rules for score a ten-pin game of bowling

Overview

Ten-pin bowling is a sport in which a player, or "bowler" rolls a bowling ball down a wooden lane with the objective of scoring points by knocking down as many pins as possible.

Standard scoring

There are 10 frames in a game and the total score is the sum of all points from each frame plus any bonuses. In general, one point is scored for each pin that is knocked down. So if a player knocks down three pins with the first shot, then six with the second, the player would receive a total of nine points for that frame. If a player knocks down nine pins with the first shot, but misses with the second, the player would also receive nine points for the frame. Scenario:

Frame 1, ball 1: 3 pins

public interface IPay
{
decimal CalculatePay( Employee currentEmployee );
void SendToBigBallerAccount();
}
public class BigBallerPay : IPay
{
public decimal CalculatePay( Employee currentEmployee )
{