Skip to content

Instantly share code, notes, and snippets.

View philcleveland's full-sized avatar

Phil Cleveland philcleveland

View GitHub Profile
@philcleveland
philcleveland / README-Template.md
Created April 30, 2018 19:50 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@philcleveland
philcleveland / react-up.sh
Created January 11, 2017 16:24
WIP: Create a dev env for react using gulp and babel
# npm install -g create-react-app
create-react-app hello-world
cd hello-world
# set up Babel so we can use ES6
npm install --save-dev gulp-babel
npm install babel-preset-env --save-dev
touch .babelrc
echo "{
echo ------------------------------------------------------------
echo --- Updating Packages
echo ------------------------------------------------------------
sudo apt-get update
echo ------------------------------------------------------------
echo --- Upgrading Packages
echo ------------------------------------------------------------
sudo apt-get upgrade
echo ------------------------------------------------------------
echo --- Updating Packages
@philcleveland
philcleveland / Dapper_dynamic_query.cs
Created May 26, 2016 19:19
Trying to figure out how to build dapper dynamic query.
public Task<List<Tag>> SearchTags(params string[] searchTerms)
{
var sql = @"SELECT * FROM Tags WHERE ";
var term = "value LIKE %@t{0}%";
var sb = new StringBuilder(sql);
for (int i = 0; i < searchTerms.Length; i++)
{
sb.Append(string.Format(term, i + 1));
if(i != searchTerms.Length - 1)//islastterm
@philcleveland
philcleveland / Quaternion.fs
Last active February 4, 2016 00:15
Quaternion implementation
type Quaternion =
{
w:float
x:float
y:float
z:float
} with
static member (+) (r: Quaternion, q: Quaternion) =
{w=r.w+q.w;x=r.x+q.x;y=r.y+q.y;z=r.z+q.z}
static member (-) (r: Quaternion, q: Quaternion) =
@philcleveland
philcleveland / bitwiseMatch.fs
Last active January 14, 2016 06:49
F# bitwise pattern match
let parseState value =
match value with
| 0us ->
printfn "state 0"
| value when value &&& 16us <> 16us ->
printfn "state 1"
| value when value &&& 32us <> 32us ->
printfn "state 2"
| value when value &&& 64us <> 64us ->
printfn "state 3"
@philcleveland
philcleveland / Program.fs
Last active January 7, 2016 22:48
Akka Producer/Consumer with infinite polling loop
// Learn more about F# at http://fsharp.org
// See the 'F# Tutorial' project for more help.
open System
open System.IO
open Akka.FSharp
type ProducerCommand =
| Start
| Stop
@philcleveland
philcleveland / angular2bootstrap.sh
Last active November 16, 2015 16:36
Create a directory for your angular2 project and then run this shell in that directory
echo Go check out angular.io for a really good tutorial!
mkdir src
cd src
#create base the index.html
awk 'BEGIN { print "<html>"
print "<head>"
print " <title>TitleHere</title>"
print " <script src=\"../node_modules/systemjs/dist/system.src.js\"></script>"
print " <script src=\"../node_modules/angular2/bundles/angular2.dev.js\"></script>"
print " <script>"
@philcleveland
philcleveland / routes.go
Last active November 2, 2015 17:35
Currently how I define my routes for api's in Go. Up for discussion
r := mux.NewRouter()
r.StrictSlash(true)
apiV1 := r.PathPrefix("/api/v1").Subrouter()
//recipes
apiV1.HandleFunc("/{userID}/recipes/", ws.GetAllRecipes).Methods("GET")
apiV1.HandleFunc("/{userID}/recipes/{recipeID}", ws.GetRecipeByID).Methods("GET")
apiV1.HandleFunc("/{userID}/recipes/", ws.CreateRecipe).Methods("POST")
apiV1.HandleFunc("/{userID}/recipes/{recipeID}", ws.EditRecipe).Methods("PUT")
apiV1.HandleFunc("/{userID}/recipes/{recipeID}", ws.DeleteRecipe).Methods("DELETE")
@philcleveland
philcleveland / index.html
Last active November 26, 2022 20:26
GoLang template with image
<!DOCTYPE html>
<html>
<head>
<title>Index</title>
</head>
<body>
Index page.
<!-- This image always fails to load when served from go, but is fine if I just double click the html file -->