Skip to content

Instantly share code, notes, and snippets.

View ssippe's full-sized avatar

Sam Sippe ssippe

  • Gold Coast, Australia
  • 14:19 (UTC +10:00)
View GitHub Profile
@ssippe
ssippe / mysqlColumnLists.sql
Created June 4, 2020 00:40
mysql column lists for inserts updates etc.
set @schema = 'base_sms';
set @table = 'bayprofiles';
-- column name list
select concat('`',COLUMN_NAME,'`,') as columnName from information_schema.COLUMNS where TABLE_SCHEMA=@schema and TABLE_NAME=@table;
/*
`id`,
`profileId`,
`bayWidth`,
`bcolumn`,
@ssippe
ssippe / mysqlForceDeadlock.sql
Created May 15, 2020 05:31
mysql force deadlock
-- replace:
-- `log` with any table
-- `id` with any index column on that table
-- 81272070 with an existing value in the index column
-- in connection #1
START transaction;
select * from log where id = 81272070 FOR UPDATE;
select sleep(40);
COMMIT;
@ssippe
ssippe / SketchSystems.spec
Last active May 7, 2019 09:24
Landing Page
Landing Page
Create Design -> Is Logged In For New Design?
Login -> Login Page
Create Account -> Create Account
Is Logged In For New Design?
yes? -> New Design
no? -> Login Page
Login Page
@ssippe
ssippe / SketchSystems.spec
Last active March 25, 2019 03:21
Quote Listing*
Quote Listing*
New Quote -> New Quote Wizard
Select Quote -> Estimation View Mode?
Search -> Quote Listing
Estimation View Mode?
is accepted? -> Accepted Quote
is created? -> Created Quote
else -> Draft Quote
@ssippe
ssippe / AggregateException.cs
Created October 30, 2018 05:21
AggregateException Pattern
public void ProcessList(List<Input> inputs)
{
var errors = new List<Exception>();
foreach (var input in inputs)
{
try
{
Process(input);
}
catch (Exception ex)
@ssippe
ssippe / FindRelativePathInAncestors.cs
Last active October 8, 2018 06:50
FindRelativePathInAncestors
/// <summary>
/// Search for relativePath with respect to (w.r.t.) the current directory and if it doesn't exist,
/// search w.r.t. the current parent directory, then the grandparent and so on until the path is found
/// or the root it hit. Works for files or directories.
/// </summary>
/// <returns></returns>
public static string FindRelativePathInAncestors(string relativePath, string startDirectory)
{
relativePath = relativePath.TrimStart(Path.DirectorySeparatorChar);
int level = 0;
@ssippe
ssippe / UnitTest1.cs
Created September 28, 2018 05:32
json serialization and immuatability
using System;
using System.Diagnostics;
using Newtonsoft.Json;
using Shouldly;
using Xunit;
namespace json
{
public class UnitTest1
{
@ssippe
ssippe / AwsFirewallHolePunch.cs
Last active December 23, 2022 03:29
awspunch
using System;
using System.CodeDom;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using Amazon;
@ssippe
ssippe / gist:8fc11c4d7e766e66f06db0431dba3f0a
Created December 2, 2017 11:21
jwt+rsa+dotnet with pem
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.OpenSsl;
using Org.BouncyCastle.Security;
@ssippe
ssippe / cartesianProduct.ts
Created April 20, 2017 00:33
Typescript Cartesian Product
const f = (a: any[], b: any[]): any[] =>
[].concat(...a.map(a2 => b.map(b2 => [].concat(a2, b2))));
export const cartesianProduct = (a: any[], b: any[], ...c: any[]) => {
if (!b || b.length === 0) {
return a;
}
const [b2, ...c2] = c;
const fab = f(a, b);
return cartesianProduct(fab, b2, c2);