Skip to content

Instantly share code, notes, and snippets.

@fushnisoft
fushnisoft / clariondate.sql
Last active January 5, 2024 14:33
Convert a Clarion Date (INT) to SQL DateTime
DECLARE @ClarionDate INT = 47563
DECLARE @SqlDateTime DATETIME
-- Convert the clarion DATE into and SQL DateTime
SET @SqlDateTime = DateAdd(day, @ClarionDate - 4, '1801-01-01')
SELECT @SqlDateTime AS 'SQL Date Time'
-- Now convert it back from and SQL DateTime to a Clarion Date
SET @ClarionDate = DateDiff(day, DateAdd(day, -4, '1801-01-01'), @SqlDateTime)
@litera
litera / NPoco strong typed Stored Procedures calls T4.md
Last active June 27, 2023 11:37
NPoco/PetaPoco strong typed and named stored procedures T4 generator

NPoco/PetaPoco stored procedures with named strong type parameters

StoredProcedures.tt file automatically generates a C# code file with calsses and methods corresponding to your database stored procedure definitions. This is then used to simply call stored procedures within NPoco/PetaPoco and avoid magic strings and parameter type guessing. It also supports output parameters.

Stored procedures naming conventions

In order to have your stored procedure calls well structured there are particular yet simple naming conventions you should follow when creating your stored procedures:

  1. Name your stored procedures as ClassName_Method
  2. If a particular stored procedure shouldn't be parsed you should omit underscore character in its name; this will make it private from the perspective of your C# as it will only be accessible to other stored procedures but won't be parsed.
@joshdover
joshdover / README.md
Last active September 28, 2023 21:38
Idiomatic React Testing Patterns

Idiomatic React Testing Patterns

Testing React components seems simple at first. Then you need to test something that isn't a pure interaction and things seem to break down. These 4 patterns should help you write readable, flexible tests for the type of component you are testing.

Setup

I recommend doing all setup in the most functional way possible. If you can avoid it, don't set variables in a beforeEach. This will help ensure tests are isolated and make things a bit easier to reason about. I use a pattern that gives great defaults for each test example but allows every example to override props when needed:

@tiernan
tiernan / service-worker.d.ts
Last active February 20, 2022 11:04
Typings for using the Service Worker API with TypeScript
/**
*
* DEPRECIATED: Please use the updated type definitions:
* Service Worker Typings to Supplement lib.webworker.d.ts
* https://gist.github.com/tiernan/c18a380935e45a6d942ac1e88c5bbaf3
*
*
* Copyright (c) 2016, Tiernan Cridland
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby
@ithinkihaveacat
ithinkihaveacat / service-worker.d.ts
Last active April 18, 2024 16:49 — forked from tiernan/service-worker.d.ts
Typings for using the Service Worker API with TypeScript
/**
* Copyright (c) 2016, Tiernan Cridland
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby
* granted, provided that the above copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
@epatr
epatr / _reboot-variables.scss
Created June 14, 2017 22:51
A Sass file to @import before importing Bootstrap 4's Reboot file. Uses Bootstrap defaults.
// Required mixin
$enable-hover-media-query: false;
@mixin hover-focus {
@if $enable-hover-media-query {
&:focus { @content }
@include hover { @content }
}
@else {
&:focus,
&:hover {
@FQ400
FQ400 / braching.js
Last active September 15, 2017 07:42
Branching in functional javascript using Ramda
import R from 'ramda';
const payloadSizeWithinLimit = (payload, limit) => limit > payload.size;
const errorState = { name: 'can not be empty' };
const sizeInBytes = 50000;
let errorObj;
errorObj = R.cond([
[R.equals(true), R.always({})],
@getify
getify / 1.js
Last active June 2, 2021 15:41
Proposal: curried function declarations in javascript -- aka, making FP development in JS much much nicer
// Standard:
function fn(x) {
return function(y){
return function(z){
return x * y / z;
};
};
}
@asciidisco
asciidisco / drm_idk.md
Last active October 20, 2021 07:32
EME? CDM? DRM? CENC? IDK!

Title

EME? CDM? DRM? CENC? IDK!

Abstract

Once there was the <video/> tag, but content distributors decided it wasn't enough. They wanted more - more power, more protection, more control, more features. So, Encrypted Media Extensions were born & Digital Rights Management appeared in our browsers.

@claudiopro
claudiopro / .gitignore
Last active November 10, 2017 20:24 — forked from rauchg/README.md
require-from-dat
/node_modules/
module.js