Skip to content

Instantly share code, notes, and snippets.

View mchambaud's full-sized avatar
🚲
Meet, commit, ride.

Michael Chambaud mchambaud

🚲
Meet, commit, ride.
  • Montreal, Canada
View GitHub Profile
@mchambaud
mchambaud / SearchingChallenge.ts
Last active March 11, 2022 02:23
BitmapHoles / 2D Matrix
function searchChallenge(strArr: string[]): number {
let contiguousRegions = 0;
const matrix: number[][] = strArr.map((x: string): number[] => x.split('')
.map((y: string): number => +y));
const search = (row: number, col: number) => {
if (row >= 0 && row < matrix.length && col >= 0 && col < matrix[row].length && matrix[row][col] === 0) {
matrix[row][col] = 2;
// up
@mchambaud
mchambaud / arithGeo.ts
Created March 5, 2022 15:21
Array Challenge Arithmetic / Geometric
function isArithmetic(arr: number[]): boolean {
return arr.every((x: number, i: number) => {
if (i < 2) {
return true;
}
return arr[i] - arr[i-1] === arr[i-1] - arr[i-2];
});
}
@mchambaud
mchambaud / .editorconfig
Created January 24, 2017 19:29
.editorconfig
root = true
[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
if (!String.prototype.padRight) {
String.prototype.padRight = function (length, str) {
str = str || ' ';
return this.length >= length
? this
: this + (new Array(Math.ceil((length - this.length) / str.length) + 1).join(str)).substr(0, (length - this.length));
};
}
if (!String.prototype.padLeft) {
String.prototype.padLeft = function (length, str) {
str = str || ' ';
return this.length >= length
? this
: (new Array(Math.ceil((length - this.length) / str.length) + 1).join(str)).substr(0, (length - this.length)) + this;
};
}
@mchambaud
mchambaud / gist:8553543
Created January 22, 2014 04:34
Mou Markdown Help

Mou

Mou icon

Overview

Mou, the missing Markdown editor for web developers.

Syntax

if (!String.prototype.format) {
String.prototype.format = function() {
var args = arguments;
return this.replace(/{(\d+)}/g, function(match, number) {
return typeof args[number] != 'undefined'
? args[number]
: match
;
});
};
@mchambaud
mchambaud / $translateMissingTranslationHandlerLogRaygun
Created December 5, 2014 04:24
Angular-translate-handler-log using raygun
angular.module('pascalprecht.translate')
.factory('$translateMissingTranslationHandlerLogRaygun', function ($window) {
return function (translationId) {
$window.Raygun.send('Missing Translation', {translationKey: translationId});
};
});
@mchambaud
mchambaud / gist:35bd7c6fe83bf5de207e
Created December 5, 2014 04:23
Log all $rootScope.$emit
app.config(function ($provide) {
$provide.decorator('$rootScope', function ($delegate) {
var originalEmitFn = $delegate.$emit;
$delegate.$emit = function () {
console.log.apply(console, arguments);
originalEmitFn.apply(this, arguments)
}
return $delegate;
@mchambaud
mchambaud / Player-POC.markdown
Created August 4, 2014 21:30
A Pen by Michael Chambaud.