Skip to content

Instantly share code, notes, and snippets.

View guillaumegarcia13's full-sized avatar
πŸ’­
Building awesome things πŸš€

GARCIA Guillaume guillaumegarcia13

πŸ’­
Building awesome things πŸš€
View GitHub Profile
@guillaumegarcia13
guillaumegarcia13 / fiddler.ts
Last active September 6, 2018 13:46
Debug node.js requests with Fiddler
/* Adapted from: https://weblogs.asp.net/dixin/use-fiddler-with-node-js
/* Usage:
import { Fiddler } from './../src/helpers/fiddler';
...
Fiddler.proxyRequests();
*/
import * as url from 'url';
import * as http from 'http';
<!-- VIEW
Trick to download document silently (without opening a new tab) -->
<iframe *ngIf="hiddenUrl" class="hidden" [src]="hiddenUrl">
</iframe>
<!-- CONTROLLER -->
public hiddenUrl: SafeUrl;
...
@guillaumegarcia13
guillaumegarcia13 / yield.ts
Last active July 31, 2018 10:43
Yield example
// Run it live on: https://goo.gl/dgwE2D
class Example {
public getCountries(fields: string[] = ['name', 'alpha2Code', 'translations', 'flag']): Observable<any[]> {
const sep = (function* () {
let call = 0;
while (true) {
yield (call++ === 0) ? '?' : '&';
}
})();
@guillaumegarcia13
guillaumegarcia13 / regex_split_path.js
Last active July 22, 2018 13:33 — forked from nopjia/splitPath.js
The ultimate split path, with a single regex
/**
* The ultimate split path.
* Extracts dirname, filename, extension, and trailing URL params.
* Correct handles:
* empty dirname,
* empty extension,
* random input (extracts as filename),
* multiple extensions (only extracts the last one),
* dotfiles (however, will extract extension if there is one)
* @param {string} path
@guillaumegarcia13
guillaumegarcia13 / myresponsive.decorator.ts
Last active July 17, 2018 14:38
Angular Responsive Decorator
/* Disclaimer:
* This snippet is provided β€œAS IS” and could contain technical inaccuracies, typographical errors and out-of-date information.
* Use of the information is therefore at your (very) own risk.
*/
/*_____________________________________________________________________________________________________________________
* Aim
* Provide some solution in case of complex constructs to manage layout from an Angular point-of-view (ex: ngx-datatable)
* See: https://github.com/swimlane/ngx-datatable/issues/423
*
@guillaumegarcia13
guillaumegarcia13 / promises.ts
Last active June 25, 2018 08:06
Promises.all
// Play it on Typescript Playground: https://www.typescriptlang.org/play/
class Test {
static process(): Promise<any> {
let promises = [
Promise.resolve(1),
Promise.resolve(2),
Promise.reject(3),
Promise.resolve(4),
new Promise((res, rej) => { throw new Error('Boum'); }),
Promise.resolve(6),
@guillaumegarcia13
guillaumegarcia13 / GitCommitEmoji.md
Created April 3, 2018 13:20 — forked from parmentf/GitCommitEmoji.md
Git Commit message Emoji

Inspired by dannyfritz/commit-message-emoji

See also gitmoji.

Commit type Emoji
Initial commit πŸŽ‰ :tada:
Version tag πŸ”– :bookmark:
New feature ✨ :sparkles:
Bugfix πŸ› :bug:
@guillaumegarcia13
guillaumegarcia13 / hotjar_debug.js
Last active March 19, 2018 09:46
Hojar: advanced recording manipulation in DevTools
angular.reloadWithDebugInfo(); // https://github.com/angular/angular.js/issues/9515
// Check whether the tagged recordings are set to favourite
var dbg_hj = angular.element($(".recordings-table-container table")).scope().pageResponses()
.map(elt => {
return {
"index" : elt.index,
"id" : elt.id,
"duration" : moment.duration(elt.duration).minutes() + ':' + ('0' + moment.duration(elt.duration).seconds()).slice(-2),
"favourite": elt.favourite,
@guillaumegarcia13
guillaumegarcia13 / clone.js
Created February 20, 2018 16:36 — forked from sstur/clone.js
Deep-copy an object, similar to calling JSON.parse(JSON.stringify(obj)) but preserves dates and undefined
function clone(obj) {
if (Object(obj) !== obj) return obj;
if (typeof obj.toJSON == 'function') {
return obj.toJSON();
}
var type = toString.call(obj).slice(8, -1);
if (type in CLONE) {
return CLONE[type].call(obj, clone);
}
var copy = {};
@guillaumegarcia13
guillaumegarcia13 / groupBy.ts
Created January 12, 2018 23:39
groupBy in Typescript (for use in Angular)
declare global {
interface Array<T> {
groupBy(prop: T): Array<T>;
}
}
if (!Array.prototype.groupBy) {
Array.prototype.groupBy = (prop: string) => {
return this.reduce(function(groups, item) {
const val = item[prop];