Skip to content

Instantly share code, notes, and snippets.

@dragermrb
dragermrb / Description-and-Usage.md
Created May 17, 2020 12:43
HTML5 Resize image before upload without ajax

HTML5 Resize image before upload without ajax

Allows to resize a file input image before upload to the server. The resized image will be attached to original file input. Then you can submit your form without ajax or handle it as you need.

Usage as jQuery Plugin

<form>
    <label>Select image</label>
@davidfowl
davidfowl / Program.cs
Last active June 29, 2024 18:09
A minimal fully asynchronous C# ASP.NET Core 3.0 application with routing (learn more about ASP.NET Core here https://docs.microsoft.com/en-us/aspnet/core/?view=aspnetcore-3.0)
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Hosting;
public class Program
{
public static void Main(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
@swlaschin
swlaschin / effective-fsharp.md
Last active June 16, 2024 18:41
Effective F#, tips and tricks

Architecture

  • Use Onion architecture

    • Dependencies go inwards. That is, the Core domain doesn't know about outside layers
  • Use pipeline model to implement workflows/use-cases/stories

    • Business logic makes decisions
    • IO does storage with minimal logic
    • Keep Business logic and IO separate
  • Keep IO at edges

@peaeater
peaeater / optimize-pdf.ps1
Created May 25, 2018 17:47
Downsamples PDFs with ghostscript.
<#
Downsample PDF and convert to gray if necessary.
Requires Ghostscript (gswin64c).
#>
param (
[string]$indir,
[string]$outdir = $indir,
[string]$gs = "gswin64c",
[string]$dpi = "150"
@pimbrouwers
pimbrouwers / reset.css
Created March 27, 2018 13:45
Minimal CSS Reset
html, body, div, span,
h1,h2,h3,h4,h5,h6,hgroup,
ul,ol,dd,
p,figure,
pre,table,fieldset,hr,
article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
@pimbrouwers
pimbrouwers / ajax.js
Last active January 26, 2018 14:44
AJAX helpers with jQuery
module.exports = new Ajax();
function Ajax() { };
Ajax.prototype.get = function (url, callback, error) {
var req = this.makeRequest('GET', url, callback, error);
req.send();
};
Ajax.prototype.post = function (url, data, callback, error) {
@pimbrouwers
pimbrouwers / c-sharp-parse-linkheader.cs
Last active April 5, 2024 20:53
C# Parse Link Header
public class LinkHeader
{
public string FirstLink { get; set; }
public string PrevLink { get; set; }
public string NextLink { get; set; }
public string LastLink { get; set; }
public static LinkHeader LinksFromHeader(string linkHeaderStr)
{
LinkHeader linkHeader = null;
@pimbrouwers
pimbrouwers / mssql-calendar-table.sql
Last active October 12, 2023 13:20
SQL Server Calendar Table
USE master
GO
IF OBJECT_ID('dbo.calendar') IS NOT NULL
DROP TABLE dbo.calendar;
IF OBJECT_ID('dbo.fn_generate_calendar') IS NOT NULL
DROP FUNCTION dbo.fn_generate_calendar;
GO
@pimbrouwers
pimbrouwers / mssql-continent-country.sql
Created May 9, 2017 13:53
MSSQL Continents / Countries (Name, ISO2, ISO3, ISO Num)
CREATE SCHEMA [Geo]
GO
CREATE TABLE [Geo].[Continent](
[Code] [char](2) NOT NULL PRIMARY KEY,
[Name] [nvarchar](25) NULL
)
GO
------------------------------
@peaeater
peaeater / self-signed-cert.ps1
Created April 11, 2017 23:40
Creates new wildcard self-signed SSL certificate for development purposes. Needs PowerShell admin.
# Creates new self-signed certificate for testing purposes
new-selfsignedcertificate -dnsname "*.domain.local" -friendlyname "*.domain.local Development Certificate" -certstorelocation "cert:\LocalMachine\My" -notafter (get-date).AddYears(100)