Skip to content

Instantly share code, notes, and snippets.

View khannurien's full-sized avatar
🐛
Looking at bugs

Vincent khannurien

🐛
Looking at bugs
View GitHub Profile
@khannurien
khannurien / fflthread.c
Last active May 6, 2019 13:03
Usage: find /path/to/flac/folder -name "*.flac" | xargs -d '\n' /path/to/fflthread
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
/**
* Structure de données partagée pour limiter le nombre de threads.
@khannurien
khannurien / match-parens.ts
Last active July 2, 2021 06:54
Contrived functional solution to a classic coding interview question.
const values = [
null, 'abc', '',
'()', '[]',
'([])', '[()]',
'([]())', '[[]()]',
'([][]())', '[[[()()]()]()]',
'(abc)', '[]def', 'ijk[]()',
'[a(b)c]', 'x[a(b)c]y',
'x[a(b)c]', '[a(b)c]y',
'[([[]])]', '[][(]',
@khannurien
khannurien / merge-no-duplicates.ts
Last active July 2, 2021 07:04
Merge two arrays while ignoring duplicates in the second array based on a predicate.
interface MyObject {
key: number;
value: string;
}
const array1: MyObject[] = [
{
key: 1,
value: 'one'
},
@khannurien
khannurien / conditional-combine.ts
Last active July 2, 2021 07:04
Using rxjs operators, conditionally combine results from two Observables based on a predicate regarding values from the first Observable.
import { iif, of } from "rxjs";
import { map, switchMap, withLatestFrom } from 'rxjs/operators';
const values1 = [1, 2, 3, 4];
const values2 = [5, 6, 7];
const values1$ = of(values1);
const values2$ = of(values2);
values1$.pipe(
@khannurien
khannurien / download-file.helper.ts
Last active July 20, 2021 12:03
Create a pseudo-link to a file in order to trigger browser prompt for file download.
/**
* Download a file from a Blob with explicitly set MIME type.
* @param fileBlob The input Blob.
* @param mimeType A string representing a conform MIME type (see RFC 6838).
* @param outName A string for the downloaded file name.
*/
export const downloadFile = (fileBlob: Blob, mimeType: string, outName: string): void => {
// explicitly set blob mime-type
const blob = new Blob([fileBlob], { type: mimeType });