Skip to content

Instantly share code, notes, and snippets.

@GuerrillaCoder
GuerrillaCoder / setup.php
Last active August 29, 2015 14:19
Idea for set up structure
<?php
namespace themename\setup;
//todo: abstract actual values to another object and pass it to this contructor
class MainThemeSetupMaster
{
private $cssSetup;
private $jsSetup;
public function __construct()
{
@GuerrillaCoder
GuerrillaCoder / StringInterpol.cs
Last active August 3, 2017 08:29
C# Named Value String Format Replace For Templating
// This is a modification of https://mhusseini.wordpress.com/2014/05/03/fast-named-formats-in-c.
// To make it work as a flexible templating system I modified it so that it can use dynamic objects
// and silently removes unused fields.
// I am not sure how this has effected its performance.
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;

Creating Neat .NET Core Command Line Apps

Every reason to get more HackerPoints™ is a good one, so today we're going to write a neat command line app in .NET Core! The Common library has a really cool package Microsoft.Extensions.CommandlineUtils to help us parse command line arguments and structure our app, but sadly it's undocumented.

No more! In this guide, we'll explore the package and write a really neat console app. We'll get good practices, a help system and argument parsing for free. Oh, it also involves ninjas. Insta-win.

@GuerrillaCoder
GuerrillaCoder / JS-LINQ.js
Created July 13, 2018 00:19 — forked from DanDiplo/JS-LINQ.js
JavaScript equivalents of some common C# LINQ methods. To help me remember!
// JS array equivalents to C# LINQ methods - by Dan B.
// Here's a simple array of "person" objects
var people = [
{ name: "John", age: 20 },
{ name: "Mary", age: 35 },
{ name: "Arthur", age: 78 },
{ name: "Mike", age: 27 },
{ name: "Judy", age: 42 },
{ name: "Tim", age: 8 }
public static string RunPsqlCsvImport(string filePath, string user, string dbname, string tableName, bool hasHeaderRow)
{
var isLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
//WARNING: an entry for below connection must be entered in system pgpass.conf file or import will fail
ProcessStartInfo startInfo = null;
if (isLinux)
{
var args = $"-c \"cat {filePath} | psql -h 127.0.0.1 -U {user} -d {dbname} -w -c 'copy {tableName} from stdin csv header' \" ";
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Funq;
using Hangfire;
using Hangfire.Console;
using Hangfire.Dashboard;
using Hangfire.PostgreSql;
@GuerrillaCoder
GuerrillaCoder / _init
Last active December 30, 2019 16:31
NLog configuration
dotnet add package NLog.Web.AspNetCore
dotnet add package NLog