Skip to content

Instantly share code, notes, and snippets.

View vector623's full-sized avatar

David Gallmeier vector623

View GitHub Profile
@vector623
vector623 / consul_debug_output
Created March 25, 2020 18:59
pulled from journalctl
-- Logs begin at Thu 2020-02-20 21:03:22 UTC. --
Mar 25 18:54:47 srv-pro-schd-05 consul[30217]: 2020-03-25T18:54:47.382Z [DEBUG] agent.server.autopilot: Failed to remove dead servers: error="denied, because removing the majority of servers 1/1 is not safe"
Mar 25 18:54:57 srv-pro-schd-05 consul[30217]: 2020-03-25T18:54:57.382Z [DEBUG] agent.server.autopilot: Failed to remove dead servers: error="denied, because removing the majority of servers 1/1 is not safe"
Mar 25 18:55:06 srv-pro-schd-05 consul[30217]: 2020-03-25T18:55:06.607Z [DEBUG] agent: Skipping remote check since it is managed automatically: check=serfHealth
Mar 25 18:55:06 srv-pro-schd-05 consul[30217]: 2020-03-25T18:55:06.608Z [DEBUG] agent: Node info in sync
Mar 25 18:55:07 srv-pro-schd-05 consul[30217]: 2020-03-25T18:55:07.361Z [DEBUG] agent.server: Skipping self join check for node since the cluster is too small: node=srv-pro-svrg-01
Mar 25 18:55:07 srv-pro-schd-05 consul[30217]: 2020-03-25T18:55:07.382Z [DEBUG] agent.se
@vector623
vector623 / balance_sheet_parameters_tofetch.sql
Created January 18, 2020 16:31
generates list of parameters to sync balance sheets, to be called against this endpoint: https://iexcloud.io/docs/api/#balance-sheet
WITH dates AS (
SELECT
date_trunc('day', dd):: date AS date
FROM generate_series
('2017-01-01'::timestamp
, @currentDate::timestamp
, '1 day'::interval) dd
),
quarters AS (
@vector623
vector623 / FormsAuthenticationTicketHelper.cs
Last active September 5, 2019 23:01 — forked from dazinator/FormsAuthenticationTicketHelper.cs
Decrypt a Legacy ASP.NET Forms Authentication Cookie (that uses SHA1 validation, and AES encryption) - without horrendous dependencies on system.web.. This allows you to decrypt a forms authentication cookie that was created in ASP.NET 3.5, from an ASP.NET 5 application.
internal static class FormsAuthenticationTicketHelper
{
private const byte CURRENT_TICKET_SERIALIZED_VERSION = 0x01;
private const int MAX_TICKET_LENGTH = 4096;
// Resurrects a FormsAuthenticationTicket from its serialized blob representation.
// The input blob must be unsigned and unencrypted. This function returns null if
// the serialized ticket format is invalid. The caller must also verify that the
// ticket is still valid, as this method doesn't check expiration.
@vector623
vector623 / c#-to-rust.md
Last active May 5, 2019 23:28 — forked from carols10cents/c#-to-rust.md
C# to Rust Cheat Sheet

C# to Rust Cheat Sheet

The goal of this is to have an easily-scannable reference for the most common syntax idioms in C# and Rust so that programmers most comfortable with C# can quickly get through the syntax differences and feel like they could read and write basic Rust programs.

What do you think? Does this meet its goal? If not, why not?

Table of Contents

@vector623
vector623 / SerilogConfig.cs
Last active July 12, 2018 14:36
format dynamic expando objects with Serilog
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.Destructure.ByTransforming<ExpandoObject>(JsonConvert.SerializeObject)
.WriteTo.AzureAnalytics(
workspaceId: Configuration["AZUREANALYTICS_WORKSPACEID"],
authenticationId: Configuration["AZUREANALYTICS_AUTHENTICATIONID"],
logName: "logTableName",
restrictedToMinimumLevel: LogEventLevel.Debug,
batchSize: 10)
.CreateLogger();
@vector623
vector623 / WarehouseTransactions.cs
Created July 12, 2018 13:13
example Serilog usage in a typical ETL
public IActionResult WarehouseTransactions()
{
dynamic logs = new ExpandoObject();
try
{
using (var athenaDb = LocalDB.GetConnection())
using (var remoteDb = RemoteDB.GetConnection())
{
//download ids+lastmodified timestamp for source and destination
var sourceTransationState = athenaDb
@vector623
vector623 / redshift-cheatsheet.sql
Last active September 13, 2018 12:15 — forked from rudylee/redshift-cheatsheet.sql
Redshift Cheatsheet
## General Stuff
### List of all tables
SELECT * FROM pg_catalog.pg_tables
### Create new user and give it superuser access
create user adminuser createuser password '1234Admin';
alter user adminuser createuser;
### Create user without superuser privilege
@vector623
vector623 / GithubPullerDemo.cs
Created May 17, 2018 14:01
a quick C# demo, reading data from Github's REST API and parsing the JSON
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using Microsoft.AspNetCore.Routing;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace GithubPullerDemo
{
public class GitHubRepo
static class Program
{
public static IConfigurationRoot Configuration { get; }
public static ILoggerFactory LoggerFactory { get; }
public static DbConnectionStringBuilder DbConnectionStringBuilder { get; }
static Program()
{
Configuration = new ConfigurationBuilder()
.AddEnvironmentVariables("TROICENETDEV_")
.Build();