Skip to content

Instantly share code, notes, and snippets.

View Ketcap's full-sized avatar
🏠
Working from home

Uğur Oruç Ketcap

🏠
Working from home
View GitHub Profile
@Ketcap
Ketcap / CustomFib.js
Created December 13, 2020 13:06
Custom Fib
let fibo = parseInt(process.env.FIBO);
console.time(`Fib-${fibo}`);
let counter = 1;
var l = 0;
var r = 1;
const fib = () => {
const left = l;
@Ketcap
Ketcap / sf.css
Created January 13, 2019 10:33
San Francisco Font
/**
* http://applemusic.tumblr.com/
*/
/** Ultra Light */
@font-face {
font-family: "San Francisco";
font-weight: 100;
src: url("https://applesocial.s3.amazonaws.com/assets/styles/fonts/sanfrancisco/sanfranciscodisplay-ultralight-webfont.woff");
}
@Ketcap
Ketcap / async-foreach.js
Created December 22, 2018 11:27 — forked from Atinux/async-foreach.js
JavaScript: async/await with forEach()
const waitFor = (ms) => new Promise(r => setTimeout(r, ms))
const asyncForEach = (array, callback) => {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array)
}
}
const start = async () => {
await asyncForEach([1, 2, 3], async (num) => {
await waitFor(50)
@Ketcap
Ketcap / anagram.js
Last active August 20, 2018 12:27
Anagram
const anagram = (word1, word2) => {
const w1 = word1.toLowerCase().replace(/\s+|!/g, '').split('');
const w2 = word2.toLowerCase().replace(/\s+|!/g, '').split('')
const letters1 = w1.reduce((prev, current, val) => {
if (typeof prev[current] !== 'undefined') {
return { ...prev, [current]: prev[current] + 1 }
}
return { ...prev, [current]: 1 }
}, {})
export const CreateUserSearchQuery = (query) => {
let search1 = { $or: [] };
let search2 = { $or: [] };
let searchQuery = [];
if (!!query.text) {
search1['$or'].push({ 'profile.name': { $regex: query.text, $options: 'i' } });
search1['$or'].push({ 'profile.surname': { $regex: query.text, $options: 'i' } })
search1['$or'].push({ 'username': { $regex: query.text, $options: 'i' } })
searchQuery.push(search1);
}
@Ketcap
Ketcap / check_is_array.js
Last active May 2, 2018 07:58
Checking given name of array if it exists inside object or not
const obj = {
a: [],
b: {
c: [1],
q: 'asd',
d: {
h: 'asd',
g: 'sd',
e: {
f: []
### Keybase proof
I hereby claim:
* I am Ketcap on github.
* I am ketcap (https://keybase.io/ketcap) on keybase.
* I have a public key whose fingerprint is 321D 048A 0EE7 2D23 C88F 05B3 4773 9670 2817 91EE
To claim this, I am signing this object: