Skip to content

Instantly share code, notes, and snippets.

View DevEarley's full-sized avatar
🎯
Focusing

Alex Earley DevEarley

🎯
Focusing
View GitHub Profile
@DevEarley
DevEarley / some-controller.js
Created June 18, 2017 02:44
Your everyday angular controller.
'use strict';
var myApp = angular.module('myApp');
myApp.controller('SomeController', ['$scope', '$rootScope', '$location',
function ($scope, $rootScope, $location) {
}]);
//OR
@DevEarley
DevEarley / some-app.js
Last active October 3, 2018 17:02
Your everyday app.js - with routing
angular.module('myApp', ['ngRoute']).config(function ($routeProvider, $locationProvider) {
$routeProvider
.when('/', {
templateUrl: 'content/views/login/login.html',
controller: 'loginController',
controllerAs: 'vm'
})
.when('/home', {
templateUrl: 'content/views/landing/landing.html',
controller: 'landingController',
@DevEarley
DevEarley / some-service.js
Created June 18, 2017 02:51
Your Everyday service.
'use strict';
angular.module('myApp').service('UserService', ['$http', '$window', function ($http, $window) {
return {
getUsers: function () {
return $http({
method: 'GET',
url: $http.defaults.apiUrl + '/users',
headers: { 'Authorization': $window.sessionStorage.token }
}).then(function (data) { return data.data; });
@DevEarley
DevEarley / on-enter.js
Created June 21, 2017 19:42
Do some action on enter. Angular directive.
angular
.module("on-enter", [])
.directive("onEnter", function () {
return function (scope, element, attrs) {
element.bind("keydown keypress", function (event) {
if (event.which === 13) {
scope.$apply(function () {
scope.$eval(attrs.onEnter);
});
@DevEarley
DevEarley / work-vs-code-settings.json
Last active March 2, 2018 22:22
My Studio Code settings
{
"window.menuBarVisibility": "toggle",
"workbench.activityBar.visible": false,
"workbench.iconTheme": "material-icon-theme",
"editor.roundedSelection": false,
"editor.minimap.enabled": true,
"editor.minimap.renderCharacters": false,
"editor.quickSuggestions": {
"other": true,
"comments": false,
@DevEarley
DevEarley / SomeNancyModule.cs
Last active August 6, 2017 18:09
nancy binding for some app
public class ItemModule : NancyModule
{
public ItemModule() : base("/items")
{
Get("/", p => GetAllItems(this.Bind<ItemRequestModel>()));
Get("/{ItemID}", p => GetItem(this.Bind<ItemRequestModel>()));
}
public List<ItemResponseModel> GetAllItems(ItemRequestModel _ItemRequestModel)
{
@DevEarley
DevEarley / SomeResponseModel.cs
Last active August 6, 2017 18:14
Some Response Model
public class ItemResponseModel
{
public int ItemID;
public string Name;
public string Message;
public static ItemResponseModel ToResponseModel(Item _Item) {
return new ItemResponseModel {
ItemID = _Item.ItemID,
@DevEarley
DevEarley / some_index.html
Created August 6, 2017 20:14
your typical index.html
<html>
<head>
<link rel="stylesheet" type="text/css" href="some-website.min.css">
</head>
<body ng-app="SomeWebsite">
<ng-view></ng-view>
<script src="some-website.min.js" type="text/javascript" ></script>
</body>
</html>
@DevEarley
DevEarley / SomeNancyBootstrap.cs
Last active April 22, 2018 02:22
Nancy bootstrapper with a default web folder
using Nancy;
using Nancy.Bootstrapper;
using Nancy.TinyIoc;
using Nancy.Conventions;
using Nancy.Session;
namespace SomeApi
{
public class Bootstrapper : DefaultNancyBootstrapper
{
@DevEarley
DevEarley / SomeNancyProgram.cs
Last active March 2, 2022 00:25
Nancy set up with signalr
using Owin;
using Nancy.Owin;
using System;
using Microsoft.Owin;
using Microsoft.AspNet.SignalR;
[assembly: OwinStartup(typeof(SomeAPI.Startup))]
namespace SomeAPI
{
public class Startup