Skip to content

Instantly share code, notes, and snippets.

View elderfo's full-sized avatar

Chris 'Freddy' Getsfred elderfo

View GitHub Profile
@elderfo
elderfo / Controllers\ExampleController.cs
Last active December 2, 2016 05:01
Original standard architecture business logic class
using Project.Logic;
namespace Project.Controllers
{
public class ExampleController : Controller
{
public JsonResult GetUser(Guid userId)
{
UserModel user = Logic.User.Get(userId);
return Json(user, JsonRequestBehavior.AllowGet);
@elderfo
elderfo / ExampleController.cs
Last active December 2, 2016 03:58
Static keyword removed
using Project.Logic;
namespace Project.Controllers
{
public class ExampleController : Controller
{
private readonly User _userLogic = new User();
public JsonResult GetUser(Guid userId)
{
UserModel user = _userLogic.Get(userId);
@elderfo
elderfo / ExampleController.cs
Last active December 2, 2016 03:53
Factory method addition
using Project.Logic;
namespace Project.Controllers
{
public class ExampleController : Controller
{
private readonly User _userLogic = User.New();
// public JsonResult GetUser(Guid userId) ...
}
}
@elderfo
elderfo / Controllers\ExampleController.cs
Last active December 2, 2016 05:20
Modules Implementation
namespace Project.Controllers
{
public class ExampleController : ModuleController
{
public JsonResult GetUser(Guid userId)
{
UserModel user = Modules.UserLogic.Get(userId);
return Json(user, JsonRequestBehavior.AllowGet);
}
}
@elderfo
elderfo / Controller\User.cs
Created December 2, 2016 05:45
Leak stopped
using Project.Data; // enternal dependency
namespace Project.Logic
{
public class User
{
// ..
public List<UserModel> GetAll() {
IEnumerable<User> users = _entities.Users;
@elderfo
elderfo / deconstruct.cs7.cs
Last active December 7, 2016 19:07
Destructuring in JavaScript vs Deconstruction C#7
// Requires references to:
// - System.ValueTuple
// - Microsoft.VisualStudio.QualityTools.UnitTestFramework
public class Person
{
public string Name { get; set; }
public string City { get; set; }
public void Deconstruct(out string name, out string city)
{
@elderfo
elderfo / launch.json
Created March 31, 2017 13:14
VS Code Debug Jest
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Jest",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/node_modules/jest-cli/bin/jest.js",
"stopOnEntry": false,
"args": ["--runInBand"],
@elderfo
elderfo / SampleClass.js
Created March 31, 2017 20:06
Jest - Class Mocking
export default class SampleClass {
getSomething() {
return 'something';
}
}
@elderfo
elderfo / rename_branch.sh
Created May 17, 2017 12:47
Rename git branch
git branch -m old_branch new_branch # perform the rename
git push origin :old_branch # delete remote branch
git push --set-upstream origin new_branch # push to remote, setting the remote branch
@elderfo
elderfo / HMR-notes.md
Created July 27, 2017 17:43
Hot module reload notes for electron

Notes on HMR

  • Build electron using it's own babel config (using env)
{
  "electron-main": {
    "presets": [
      ["es2015"],
      "react"
    ],
 "plugins": [