Skip to content

Instantly share code, notes, and snippets.

View eralpkor's full-sized avatar
๐ŸŽฏ
Focusing

Eralp Kor eralpkor

๐ŸŽฏ
Focusing
View GitHub Profile
@eralpkor
eralpkor / assign_ip_all.sh
Created January 15, 2025 12:05
Assign ip address to all interfaces
#!/bin/bash
# Ensure the script is run with sudo or as root
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
# Define interfaces to exclude
EXCLUDE_INTERFACES=("lo" "ens11f0np0" "enx8e3b4a37aed1") # Add interfaces to exclude here
@eralpkor
eralpkor / RemoveLinkedListKth.js
Created August 24, 2020 21:54
remove kth node from the end of the linked list
function removeNthNodeFromBack(head, k) {
// Handles edge cases. If index (k) is less than 0 index
if (k <= 0) return head;
// Moves frontPointer forward by k-1 nodes.
let frontPointer = head;
for (let i = 1; i <= k - 1; i++) {
frontPointer = frontPointer.next;
// If frontPointer lands on null,
// *Write a function called commonElements that has parameters for two arrays.
// Return an array of all items that are present in both arrays. Do not modify the arrays that are passed in.*
// Input Example:
// [1, 2, 3, 4] [3, 4, 5, 6]
// ['a', 'b', 'c'] ['x', 'y', 'z', 'a']
// [1, 2, 3] [4, 5, 6]
// Output Example:
// [3, 4]
// *Write a function that takes in a string, reverses the 'casing'
// of that string, and returns the "reversed-casing" string.*
function reverseCase(str) {
return str.split('').map(val => {
return val === val.toUpperCase() ? val.toLowerCase() : val.toUpperCase();
}).join('');
}
var string = 'HELLO world!';
@eralpkor
eralpkor / lambdaDaily.js
Last active September 18, 2019 18:51
Lambda Days
// Day 1.
// Good morning! Write a function that takes an array of strings and return the longest string in the array.
// For example:
// const strings1 = ['short', 'really, really long!', 'medium'];
// console.log(longestString(strings1)); // <--- 'really, really long!'
// Edge case: If you had an array which had two "longest" strings of equal length, your function should just return the first one.
// For example:
// const strings2 = ['short', 'first long string!!', 'medium', 'abcdefghijklmnopqr'];
@eralpkor
eralpkor / README.md
Created July 7, 2019 16:02 — forked from roachhd/README.md
EMOJI cheatsheet ๐Ÿ˜›๐Ÿ˜ณ๐Ÿ˜—๐Ÿ˜“๐Ÿ™‰๐Ÿ˜ธ๐Ÿ™ˆ๐Ÿ™Š๐Ÿ˜ฝ๐Ÿ’€๐Ÿ’ข๐Ÿ’ฅโœจ๐Ÿ’๐Ÿ‘ซ๐Ÿ‘„๐Ÿ‘ƒ๐Ÿ‘€๐Ÿ‘›๐Ÿ‘›๐Ÿ—ผ๐Ÿ”ฎ๐Ÿ”ฎ๐ŸŽ„๐ŸŽ…๐Ÿ‘ป

EMOJI CHEAT SHEET

Emoji emoticons listed on this page are supported on Campfire, GitHub, Basecamp, Redbooth, Trac, Flowdock, Sprint.ly, Kandan, Textbox.io, Kippt, Redmine, JabbR, Trello, Hall, plug.dj, Qiita, Zendesk, Ruby China, Grove, Idobata, NodeBB Forums, Slack, Streamup, OrganisedMinds, Hackpad, Cryptbin, Kato, Reportedly, Cheerful Ghost, IRCCloud, Dashcube, MyVideoGameList, Subrosa, Sococo, Quip, And Bang, Bonusly, Discourse, Ello, and Twemoji Awesome. However some of the emoji codes are not super easy to remember, so here is a little cheat sheet. โœˆ Got flash enabled? Click the emoji code and it will be copied to your clipboard.

People

:bowtie: ๐Ÿ˜„

@eralpkor
eralpkor / passwordHashes.js
Created May 16, 2019 00:38
Create the function that converts a given string into an md5 hash. The return value should be encoded in hexadecimal.
// Create the function that converts a given string into an md5 hash. The return value should be encoded in hexadecimal.
var crypto = require('crypto');
function passHash(str) {
return crypto.createHash('md5').update(str).digest("hex");
}
passHash('abc123') //--> 'e99a18c428cb38d5f260853678922e03'
passHash('password') //--> '5f4dcc3b5aa765d61d8327deb882cf99'
#!/usr/bin/env node
// **********************
// Simple Node.js Backup script
// @Author: Eralp Kor
// *********************
// Usage: --src or -s [string] --dest or -d [string]
// node backup.js --help
// If files set read only attribute they will not be copied
// If destination file same as source it will be overwritten
@eralpkor
eralpkor / Beast-3.js
Created January 1, 2019 23:20
Improved Library Storage
(function() {
const libraryStorage = {};
function librarySystem(name, deps, callback) {
if (arguments.length > 1) {
libraryStorage[name] = callback.apply(this, deps.map(function(deps) {
return libraryStorage[deps];
}));
} else {
return libraryStorage[name];
function runWithDebugger(ourFunction, arg) {
debugger;
ourFunction.apply(null, arg);
}