Skip to content

Instantly share code, notes, and snippets.

View mahizsas's full-sized avatar

MAHIZ mahizsas

View GitHub Profile
$/
  docs/
  src/
  tests/
  samples/
  artifacts/
  packages/
  build/
 lib/
/**
* Perform a deeply recursive reduce on a set of JSON, or a JSON-encodable Object hierarchy.
*
* @param {Array|Object} collection
* @param {Function} fn
* @param {*} memo
* @return {*}
*/
function deepReduce(collection, fn, memo) {
@mahizsas
mahizsas / ConsoleRequestLogger.cs
Last active August 29, 2015 14:08 — forked from darrelmiller/gist:28221417620db2973a25
Colored Console MesageHanlder
public class ConsoleRequestLogger : DelegatingHandler
{
protected async override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine("> {0} {1}",request.Method,request.RequestUri.GetComponents(UriComponents.PathAndQuery, UriFormat.SafeUnescaped));
ProcessHeader(request.Headers, (name, value) => Console.WriteLine("> {0}: {1}", name, value));
if (request.Content != null)
{
@mahizsas
mahizsas / DatabaseServerStatusController.cs
Last active August 29, 2015 14:08 — forked from darrelmiller/gist:972f01aa64c6e5df37df
DatabaseServerStatusController
using System;
using System.Data;
using System.Data.SqlClient;
using System.Net;
using System.Net.Http;
using System.Net.Http.Formatting;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Http;
using Newtonsoft.Json.Linq;
@mahizsas
mahizsas / web.config
Last active August 29, 2015 14:08 — forked from wullemsb/web.config
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="X-UA-Compatible" value="IE=Edge" />
</customHeaders>
</httpProtocol>
<system.webServer>
@mahizsas
mahizsas / routes.js
Last active August 29, 2015 14:08 — forked from charandas/routes.js
app.config(function($stateProvider, BaseSettingsService, PrintSettingsService) {
$stateProvider
// All app states loaded in index.html
.state('app', {
abstract: true,
templateUrl: 'views/app.html',
controller: 'AppCtrl',
resolve: {
baseSettings: settings: function(BaseSettingsService) {
@mahizsas
mahizsas / PdfFilter.cs
Last active August 29, 2015 14:07 — forked from jbogard/PdfFilter.cs
public class PdfFilter : Stream
{
private readonly Stream _oldFilter;
private readonly string _baseUrl;
private readonly MemoryStream _memStream;
public override bool CanSeek
{
get { return false; }
}
@if (Model == null) {
<text>@ViewData.ModelMetadata.NullDisplayText</text>
} else if (ViewData.TemplateInfo.TemplateDepth > 1) {
<text>@ViewData.ModelMetadata.SimpleDisplayText</text>
} else {
foreach (var prop in ViewData.ModelMetadata.Properties.Where(pm => pm.ShowForDisplay && !ViewData.TemplateInfo.Visited(pm))) {
if (prop.HideSurroundingHtml) {
<text>@Html.Editor(prop.PropertyName)</text>
} else {
<p>
angular.module('app.core')
.factory('templateModifierInterceptor', [
'$q',
'$templateCache',
function($q) {
var modifiedTemplates = {};
var HAS_FLAGS_REGEX = /data-dom-(remove|keep)/;
var HTML_PAGE_REGEX = /\.html$|\.html\?/i;
return {
angular.module('myMdl', []).config(['$httpProvider', function($httpProvider) {
$httpProvider.responseInterceptors.push([
'$q', '$templateCache', 'activeProfile',
function($q, $templateCache, activeProfile) {
// Keep track which HTML templates have already been modified.
var modifiedTemplates = {};
// Tests if there are any keep/omit attributes.
var HAS_FLAGS_EXP = /data-(keep|omit)/;