Skip to content

Instantly share code, notes, and snippets.

View teyfix's full-sized avatar

Halil Teyfik teyfix

  • Istanbul, Turkey
View GitHub Profile
@teyfix
teyfix / unsubscribingSubject.js
Created June 20, 2021 12:38
rxjs - unsubscribing subject
const subject = new Subject();
const subscription = subject.subscribe(value => console.log(value));
subject.next('foo');
subject.next('bar');
subscription.unsubscribe();
@teyfix
teyfix / simpleSocketIO.js
Created June 20, 2021 12:37
rxjs - simple socket.io
import { fromEvent } from 'rxjs';
import io from 'socket.io-client';
const client = io().connect();
const listen = (event: string) => fromEvent(client, event);
listen('message').subscribe((message) => console.log(message));
@teyfix
teyfix / mappingSource.js
Created June 20, 2021 12:37
rxjs - mapping source
subject.pipe(
map(x => x * x),
);
@teyfix
teyfix / detailedSocketIO.js
Last active June 20, 2021 12:39
rxjs - detailed socket.io
import { fromEvent, Subject } from 'rxjs';
import { map, shareReplay, switchMap } from 'rxjs/operators';
import io from 'socket.io-client';
const $token = new Subject();
const $client = $token.pipe(
map((token) => {
if (null == token || '' === token) {
return {};
}
@teyfix
teyfix / creatingSubject.js
Last active June 20, 2021 12:39
rxjs - creating subject
const subject = new Subject();
subject.next(1);
subject.next(2);
subject.next(3);
@teyfix
teyfix / subject.js
Last active June 20, 2021 12:39
rxjs - subscribing subject
const subject = new Subject();
subject.subscribe(value => console.log(value));
subject.next('lorem');
subject.next('ipsum');
subject.next('dolor');
@teyfix
teyfix / subject.js
Last active June 20, 2021 12:39
rxjs - closing subject
const subject = new Subject();
subject.subscribe(
(value) => console.log(value),
(error) => console.error(error),
() => console.log('özne sonlandı'),
);
subject.complete();
@teyfix
teyfix / combinations.ts
Created June 17, 2021 16:40
calculating every possible combinations of a given array
// credit: https://codesandbox.io/s/all-combinations-of-words-v14d9
function combinations(words: string[]): string[][] {
const combs: string[][] = [[]];
for (const word of words) {
combs.push(
...combs.map((comb) => {
return [...comb, word];
})
);
@teyfix
teyfix / regex
Last active June 14, 2021 18:05
seperating turkish words into syllables
/^[aeıioöuüAEIİOÖUÜ]$|^[bcçdfgğhjklmnprsştvyzBCÇDFGĞHJKLMNPRSŞTVYZ]$|[aeıioöuüAEIİOÖUÜ](?=[bcçdfgğhjklmnprsştvyzBCÇDFGĞHJKLMNPRSŞTVYZ][aeıioöuüAEIİOÖUÜ][bcçdfgğhjklmnprsştvyzBCÇDFGĞHJKLMNPRSŞTVYZ]?)|[bcçdfgğhjklmnprsştvyzBCÇDFGĞHJKLMNPRSŞTVYZ][aeıioöuüAEIİOÖUÜ](?=$|[^aeıioöuüAEIİOÖUÜbcçdfgğhjklmnprsştvyzBCÇDFGĞHJKLMNPRSŞTVYZ]|[bcçdfgğhjklmnprsştvyzBCÇDFGĞHJKLMNPRSŞTVYZ][aeıioöuüAEIİOÖUÜ])|[aeıioöuüAEIİOÖUÜ][bcçdfgğhjklmnprsştvyzBCÇDFGĞHJKLMNPRSŞTVYZ]|(?<=^|[^aeıioöuüAEIİOÖUÜbcçdfgğhjklmnprsştvyzBCÇDFGĞHJKLMNPRSŞTVYZ])[bcçdfgğhjklmnprsştvyzBCÇDFGĞHJKLMNPRSŞTVYZ][aeıioöuüAEIİOÖUÜ][bcçdfgğhjklmnprsştvyzBCÇDFGĞHJKLMNPRSŞTVYZ][bcçdfgğhjklmnprsştvyzBCÇDFGĞHJKLMNPRSŞTVYZ](?=[bcçdfgğhjklmnprsştvyzBCÇDFGĞHJKLMNPRSŞTVYZ][aeıioöuüAEIİOÖUÜ][bcçdfgğhjklmnprsştvyzBCÇDFGĞHJKLMNPRSŞTVYZ])|[bcçdfgğhjklmnprsştvyzBCÇDFGĞHJKLMNPRSŞTVYZ][bcçdfgğhjklmnprsştvyzBCÇDFGĞHJKLMNPRSŞTVYZ][aeıioöuüAEIİOÖUÜ]([bcçdfgğhjklmnprsştvyzBCÇDFGĞHJKLMNPRSŞTVYZ](?=[^aeıioöuüAEIİOÖUÜbcçdfgğhjklmnprsştvyzBCÇDFGĞHJKLMNPRSŞTVYZ]|$|[bcçdfgğhjklmnprsştvyz
@teyfix
teyfix / .dockerignore
Last active May 25, 2021 01:36
Docker setup for NestJS applications
# just adding the .env.local file for
# my local development purposes and
# I do not really need to specify
# every single file to be ignored
# because I am not copying everything
# with "COPY . ." command
# you can see what I mean below
# in "Dockerfile"
.env.local*