Skip to content

Instantly share code, notes, and snippets.

View ksummerlin's full-sized avatar

Kelly Summerlin ksummerlin

View GitHub Profile
@ksummerlin
ksummerlin / LogExtensions.cs
Created September 20, 2017 13:00
Example of using the CompilerServices attributes to automatically add the calling function name to logging information.
public static class LogExtentions
{
/// <summary>
/// Writes an information message to the logger of the form "methodCalled start: msg"
/// </summary>
/// <param name="log">The logger instance</param>
/// <param name="message">The optional message to use</param>
/// <param name="memberName">The member name to use (automatically set by the compiler)</param>
public static void InfoMethodStart(this ILog log, string message = null,
[System.Runtime.CompilerServices.CallerMemberName] string memberName = "")
@ksummerlin
ksummerlin / reducer.tests.js
Created December 21, 2016 17:47
Unit test ImmutableJs collections using newState.equals(expectState) not expect(newState).toEqual(expectState)
import expect from 'expect';
import whynotEqual from 'is-equal/why';
import appLayoutReducer from '../reducer';
import {
hideLeftMenuIcon,
showLeftMenuIcon,
} from '../actions';
import { fromJS } from 'immutable';
@ksummerlin
ksummerlin / gradle-retrolamba-stack-trace.txt
Last active May 23, 2016 17:41
gradle-retrolambda exception stack trace.
* What went wrong:
Execution failed for task ':app:transformClassesWithRetrolambdaForIntgDebug'.
> Process 'command 'C:\Program Files\Java\jdk1.8.0_92\bin\java.exe'' finished with non-zero exit value 1
* Try:
Run with --info or --debug option to get more log output.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformClassesWithRetrolambdaForIntgDebug'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
[AcceptVerbs("PATCH")]
public HttpResponseMessage PatchOrder(int id, Delta<Order> deltaOrder)
{
using (DBOrderEntities objContext = new DBOrderEntities()) {
var order = objContext.Orders.SingleOrDefault(o => o.ID == id);
if (order == null)
{
throw new HttpResponseException(HttpStatusCode.NotFound);
}
deltaOrder.Patch(order);
[AcceptVerbs("PATCH")]
public HttpResponseMessage PatchOrder(int id, Order updatedOrder)
{
using (DBOrderEntities objContext = new DBOrderEntities()) {
var order = objContext.Orders.SingleOrDefault(o => o.ID == id);
if (order == null)
{
throw new HttpResponseException(HttpStatusCode.NotFound);
}
//write code to update the given proerties here.
@ksummerlin
ksummerlin / PATCH-Order
Created July 3, 2014 03:53
A PATCH request for an order.
//PATCH /admin/orders/#{id}.json
{
"order": {
"id": 450789469,
"email": "new_email@example.com"
}
}
@ksummerlin
ksummerlin / PUT-OrderEmail.json
Last active August 29, 2015 14:03
A potential solution to partially update a specific attribute of a resource.
//PUT /admin/orders/#{id}/email
{
"email": "new_email@example.com"
}
@ksummerlin
ksummerlin / PUT-SimpleOrder
Last active August 29, 2015 14:03
A simple PUT request to update the order.
//PUT /admin/orders/#{id}.json
{
"order": {
"id": 450789469,
"email": "new_email@example.com",
"line_items": [
{
"id": 12412415,
"title": "Shiny Black Boots",
"price": 82.99,
@ksummerlin
ksummerlin / POSTSimpleOrder.json
Last active August 29, 2015 14:03
A simple order as a JSON request.
//POST /api/orders.json
{
"order": {
"email": "customer@example.com",
"line_items": [
{
"title": "Shiny Black Boots",
"price": 82.99,
"quantity": 1
}
@ksummerlin
ksummerlin / subgrunt-task
Created November 25, 2013 15:20
Runs all grunt files in sub-folders.
// Run sub-grunt files
grunt.registerMultiTask('subgrunt', 'Run a sub-gruntfile.', function () {
var path = require('path');
grunt.util.async.forEachSeries(this.filesSrc, function (gruntfile, next) {
grunt.util.spawn({
grunt: true,
args: ['--gruntfile', path.resolve(gruntfile)].concat(grunt.option.flags()),
}, function (error, result) {
if (error) {
grunt.log.error(result.stdout).writeln();