Skip to content

Instantly share code, notes, and snippets.

View alexvictoor's full-sized avatar

Alexandre Victoor alexvictoor

View GitHub Profile
@zaetrik
zaetrik / monoid-example-use-case.ts
Created May 4, 2020 13:41
Monoid Type Class Example Use Case
// The use cases for Monoids & Semigroups are pretty similar
// Not every Semigroup can be a Monoid, e.g. when there is no neutral value for empty
// An example use case for both Semigroups & Monoids
// We merge two objects together we merge them by always using the right-most non-None value
// We do this by using the getLastMonoid function from fp-ts
// Mostly taken from https://dev.to/gcanti/getting-started-with-fp-ts-monoid-ja0
import { getStructMonoid } from "fp-ts/lib/Monoid";
import { Option } from "fp-ts/lib/Option";
@SpenceDiNicolantonio
SpenceDiNicolantonio / TestUtil.cls
Last active December 20, 2023 19:29
[Salesforce ID generator] Generates 15-character Salesforce IDs for testing #salesforce #apex
/**
* A collection of static utility methods for unit testing.
*/
@IsTest
public class TestUtil {
// ID generator configuration
private static final Integer ID_RESERVED_CHARACTERS = 7;
private static final Integer ID_INCREMENTER_PREFIX_LENGTH = 1;
private static final String BASE62_ALPHABET = '0123456789abcdefghijklmnopqrstuvwqyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
@gdekefir
gdekefir / arbitrary.ts
Last active February 18, 2018 22:20
Custom jsverify property for generating an alpha-numeric string
import * as jsc from 'jsverify';
const getRandomString = (length: number, chars: string) => {
let result = '';
for (let i = length; i > 0; --i) {
result += chars[Math.floor(Math.random() * chars.length)];
}
return result;
};
@tduarte
tduarte / publish-ghpages.md
Last active May 18, 2024 13:52
If you need to force push an subtree
git checkout master # you can avoid this line if you are in master...
git subtree split --prefix dist -b gh-pages # create a local gh-pages branch containing the splitted output folder
git push -f origin gh-pages:gh-pages # force the push of the gh-pages branch to the remote gh-pages branch at origin
git branch -D gh-pages # delete the local gh-pages because you will need it: ref
@domenic
domenic / 0-github-actions.md
Last active May 26, 2024 07:43
Auto-deploying built products to gh-pages with Travis

Auto-deploying built products to gh-pages with GitHub Actions

This is a set up for projects which want to check in only their source files, but have their gh-pages branch automatically updated with some compiled output every time they push.

A file below this one contains the steps for doing this with Travis CI. However, these days I recommend GitHub Actions, for the following reasons:

  • It is much easier and requires less steps, because you are already authenticated with GitHub, so you don't need to share secret keys across services like you do when coordinate Travis CI and GitHub.
  • It is free, with no quotas.
  • Anecdotally, builds are much faster with GitHub Actions than with Travis CI, especially in terms of time spent waiting for a builder.
@wadewegner
wadewegner / addselftosqlsysadmin.cmd
Created January 25, 2012 18:35
Script to add the current user to the sysadmin role in SQL Server
@echo off
rem
rem ****************************************************************************
rem
rem Copyright (c) Microsoft Corporation. All rights reserved.
rem This code is licensed under the Microsoft Public License.
rem THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
rem ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
rem IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
rem PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.