Skip to content

Instantly share code, notes, and snippets.

@zachlysobey
zachlysobey / partition.ts
Last active April 6, 2023 16:33
TypeScript array `partition` utility
/**
* Takes a predicate and a list of values and returns a a tuple (2-item array),
* with each item containing the subset of the list that matches the predicate
* and the complement of the predicate respectively
*
* @sig (T -> Boolean, T[]) -> [T[], T[]]
*
* @param {Function} predicate A predicate to determine which side the element belongs to.
* @param {Array} arr The list to partition
*
@robhrt7
robhrt7 / MySQL_5-7_macOS.md
Last active November 4, 2024 19:55 — forked from nrollr/MySQL_macOS_Sierra.md
Install MySQL 5.7 on macOS using Homebrew

This is a fork of original gist https://gist.github.com/nrollr/3f57fc15ded7dddddcc4e82fe137b58e, with slight changes on pointing to 5.7 version branch, instead of 8 (latest default of MySQL in Hombrew).

Install MySQL 5.7 on macOS

This procedure explains how to install MySQL using Homebrew on macOS (Sierra 10.12 and up)

Install Homebrew

  • Installing Homebrew is effortless, open Terminal and enter :
    $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • Note: Homebrew will download and install Command Line Tools for Xcode 8.0 as part of the installation process.
@mariocj89
mariocj89 / python-logging.md
Last active November 6, 2024 20:13
Understanding logging in Python

Logging trees

Introduction

When applications are running in production, they become black boxes that need to be traced and monitored. One of the simplest, yet main, ways to do so is logging. Logging allows us - at the time we develop our software - to instruct the program to emit information while the system is running that will be useful for us and our sysadmins.

@amir-arad
amir-arad / lodash.d.ts
Last active January 11, 2022 17:24 — forked from albohlabs/lodash.d.ts
fixed to pass strict mode validation, plus some generic types here and there
// https://raw.githubusercontent.com/donnut/typescript-ramda/master/ramda.d.ts
// https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/lodash/lodash.d.ts
declare namespace fp {
interface Dictionary<T> {
[index: string]: T;
}
interface CurriedFunction1<T1, R> {
@julienbourdeau
julienbourdeau / wilson.php
Last active August 13, 2024 12:55
[PHP] 5 Star Rating - Lower bound of Wilson score confidence interval for a Bernoulli parameter
<?php
/*
|--------------------------------------------------------------------------
| 5 Star Rating
|--------------------------------------------------------------------------
|
| Lower bound of Wilson score confidence interval for a Bernoulli parameter (0.9604)
|
| See:
@Humberd
Humberd / async-validator-wrapper.ts
Last active October 26, 2024 08:18
Async Validator Wrapper for Angular 2 Reactive Forms.This wrapper lets you debounce your asyncValidator instead of on every keystroke
import { AbstractControl } from "@angular/forms";
import { Observable } from "rxjs/Observable";
import { Subject } from "rxjs/Subject";
export class QstAsyncValidatorWrapper {
/*
* Angular async validators are triggered on every key stroke.
* This function debounces triggering an async validator.
*
// https://raw.githubusercontent.com/donnut/typescript-ramda/master/ramda.d.ts
// https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/lodash/lodash.d.ts
declare namespace fp {
interface Dictionary<T> {
[index: string]: T;
}
interface CurriedFunction1<T1, R> {
@Deathnerd
Deathnerd / jinja.xml
Created April 8, 2015 00:37
Jinja Pycharm Live Templates
<templateSet group="jinja">
<template name="jinelse" value="{% else %}&#10; $END$" description="A simple else line" toReformat="true" toShortenFQNames="true">
<context>
<option name="HTML_TEXT" value="true" />
<option name="HTML" value="true" />
<option name="Django" value="true" />
</context>
</template>
<template name="jinblock" value="{% block $BLOCKNAME$ %}&#10;$END$&#10;{% endblock %}&#10;" description="A generic jinja block" toReformat="true" toShortenFQNames="true">
<variable name="BLOCKNAME" expression="" defaultValue="" alwaysStopAt="true" />
@xmlking
xmlking / Enum.es6.js
Last active June 25, 2019 18:09
JavaScript Enums with ES6, Type Checking and Immutability
export class EnumSymbol {
sym = Symbol.for(name);
value: number;
description: string;
constructor(name: string, {value, description}) {
if(!Object.is(value, undefined)) this.value = value;
if(description) this.description = description;
@staltz
staltz / introrx.md
Last active November 17, 2024 01:08
The introduction to Reactive Programming you've been missing