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 / tc.dart
Created June 24, 2020 12:07
tc kimlik numarası doğrulama
// Kimliğin ilk 9 rakamı için d, kontrol basamakları için c kullanırsak :
// Tc No = d1 d2 d3 d4 d5 d6 d7 d8 d9 c1 c2
// c1 = ( (d1 + d3 + d5 + d7 + d9) * 7 - (d2 + d4 + d6 + d8) ) mod10
// c2 = ( d1 + d2 + d3 + d4 + d5 + d6 + d7 + d8 + d9 + c1 ) mod10
class TC {
static final RegExp regExp = RegExp(r"^\d{11}$");
static bool validate(String tc) {
if (regExp.hasMatch(tc)) {
@teyfix
teyfix / node_modules regexp
Last active September 11, 2022 18:50
a regex pattern to be used with everything (find everything program) to match non-recursive node_module directories
/^C:\\((?!node_modules|AppData|\.vscode|Program Files).)*\\node_modules$/gi
@teyfix
teyfix / BaseConvert.js
Last active December 2, 2020 14:25
base converting tool for javascript
class BaseConvert {
static defaultDigits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
static test() {
const expects = [
{
base: 64,
encode: [
{input: 150, output: 'CW'},
{input: 19238, output: 'Esm'},
@teyfix
teyfix / StyleManager.js
Last active December 16, 2020 19:28
a helper class to manage local styles with javascript efficiently
class StyleManager {
/**
* creates a native style element
*/
static createElement() {
const style = document.createElement('style');
style.setAttribute('type', 'text/css');
return style;
@teyfix
teyfix / tierMakerLabels.js
Last active December 16, 2020 20:34
a small script that adds label to tiermaker.com characters
(() => {
const debounce = (fn, ms = 50) => {
let timer;
const tick = () => {
fn();
timer = null;
};
return () => {
if (null != timer) {
@teyfix
teyfix / README.md
Last active April 14, 2021 10:00
Proxy script for CloudFlare workers
@teyfix
teyfix / README.md
Created April 14, 2021 17:08
useful typeorm base entities

Useful base entities for TypeORM

Attribute

Any database entity. Attributes are usually being used as a child for an Existence or a Reflection.

Existence

Entities that can be changed or deleted in time.

Reflection

@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*
@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 / 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];
})
);