Skip to content

Instantly share code, notes, and snippets.

View cartermp's full-sized avatar
🦫
reject modernity, become a beaver

Phillip Carter cartermp

🦫
reject modernity, become a beaver
View GitHub Profile
@cartermp
cartermp / babbies.kt
Last active August 29, 2015 14:07
BabbiesFirstKotlin - JVM just got more fun
fun innerExpr(item: Int, mean: Int): Int {
return (item - mean) * (item - mean)
}
fun stdDev(items: List<Int>): Double {
val mean = items.sum() / items.size
val variance = items.map { innerExpr(it, mean) }.sum() / items.size
return Math.sqrt(variance.toDouble())
}
@cartermp
cartermp / piglatin.clj
Last active August 29, 2015 14:07
Beginning to learn Clojure
; Aliasing the string class to be more terse
(require '[clojure.string :as str])
; As a 'def', this is evaluated once
(def vowel? (set "AaEeOoIiUu"))
; Given a word, converts it into a pig latin equivalent
(defn convert-word [word]
(let [first-letter (first word)]
(if (vowel? first-letter)
@cartermp
cartermp / LocationAwareBasic.java
Last active August 29, 2015 14:07
Contains basic functionality for retrieving a location in latitude and longitude.
/*
* This class explicitly implements the ConnectionCallbacks and
* OnCorrectionFailedListener interfaces. What this means is that
* this class will implement what happens when a connection to
* Google Play Services fails, and what happens when a connection
* succeeds.
*/
public class MainActivity extends FragmentActivity implements
GooglePlayServicesClient.ConnectionCallbacks,
GooglePlayServicesClient.OnConnectionFailedListener {
@cartermp
cartermp / XmlToMarkdown.cs
Created December 8, 2014 19:29
Converts a Visual Studio XML Documentation File into Equivalent Markdown. Modified from here: https://gist.github.com/lontivero/593fc51f1208555112e0
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;
@cartermp
cartermp / MrMittensTheKitten.md
Last active August 29, 2015 14:11
More in-depth sample

WuTang4Eva

StringExtensions

Provides extension methods for semantic string support.


IsNullOrWhiteSpace(System.String)
@cartermp
cartermp / pipe-forward.scm
Created December 25, 2014 00:13
F# pipe-forward operator implemented in Scheme with a quick test
(define (|> f g)
(g f))
(define (square x)
(* x x))
(|> '(1 2 3 4 5) (lambda (x) (map square x)))
@cartermp
cartermp / core.clj
Created April 12, 2015 00:26
Google Translate changes to core
(ns app.core
(:require
[app.cache :refer :all]
[clojure.string :as str]
[clojure.xml :as xml]
[clj-xpath.core :as xpath]
[ring.util.codec :as codec])
(:import (org.apache.tika.language.translate GoogleTranslator)))
(def langs {:en "english"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace YES
{
public abstract class ErrorReportingBase
{
@cartermp
cartermp / test.md
Last active November 6, 2015 22:11
XML To Markdown testing

WuTang4Eva

Extensions

Provides extension methods for semantic string support.


IsNullOrWhiteSpace(System.String)
@cartermp
cartermp / stupid.cs
Last active November 18, 2015 16:31
public static string HeyThere(this IEnumerable<Point> pts) =>
$"{pts.Skip(1).Aggregate($"[{pts.First().X},{pts.First().Y},", (curr, p) => $"{curr},{p.X},{p.Y}")}]";