Skip to content

Instantly share code, notes, and snippets.

View alaztetik's full-sized avatar
😁
Happy developer

Alaz Tetik alaztetik

😁
Happy developer
View GitHub Profile
@alaztetik
alaztetik / .gitignore
Created October 24, 2018 07:16 — forked from octocat/.gitignore
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@alaztetik
alaztetik / gist:51046e7d5b65759182703b2c465d4cf2
Created October 31, 2018 23:32 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@alaztetik
alaztetik / leibnizPIformula.js
Last active April 20, 2019 23:43
Leibniz PI Formula
// REV 03-19042101
function pi(n) {
var v = 0;
for (i = 1; i <= n; i += 4) { // increment by 4
v += 1 / i - 1 / (i + 2); // add the value of the series
}
return 4 * v; // apply the factor at last
}
@alaztetik
alaztetik / turkiye_ilce.json
Created February 12, 2020 05:24
Türkiye ilçeleri için liste, Credit: @berkaycatak
[
{
"ilce_key": "1101",
"ilce_title": "ABANA",
"ilce_sehirkey": "37"
},
{
"ilce_key": "1102",
"ilce_title": "ACIPAYAM",
"ilce_sehirkey": "20"
@alaztetik
alaztetik / turkiye_il.json
Created February 12, 2020 05:26
Türkiye il liste, Credit: @berkaycatak
[
{
"sehir_key": "1",
"sehir_title": "ADANA"
},
{
"sehir_key": "2",
"sehir_title": "ADIYAMAN"
},
{
@alaztetik
alaztetik / range.js
Created April 14, 2020 08:32
sum(range(start, end))
function range(num1, num2) {
const array = [];
if (typeof num1 !== 'number' || typeof num2 !== 'number') {
throw new Error('Please provide 2 numbers.');
}
for (let i = num1; i < num2; i++) {
array.push(i);
@alaztetik
alaztetik / exec.js
Created April 14, 2020 08:57
Executing Shell Commands with Node.js
const { exec } = require("child_process");
exec("ls -la", (error, stdout, stderr) => {
if (error) {
console.log(`error: ${error.message}`);
return;
}
if (stderr) {
@alaztetik
alaztetik / getDOMElement.js
Created December 15, 2020 07:22
Get DOM elements quickly
var el = function (element) {
if (element.charAt(0) === "#") {
// If passed an ID...
return document.querySelector(element); // ... returns single element
}
return document.querySelectorAll(element); // Otherwise, returns a nodelist
};
@alaztetik
alaztetik / sortArrayObjects.js
Created January 6, 2021 05:08
A function that will sort an array of objects according to primary and secondary properties in order
const sortArrayObjs = function(arr, prop1, prop2) {
let sort1 = [...arr].sort((a, b) => {
if (a[prop1] == b[prop1]) {
if (a[prop2] === b[prop2]) return 0;
return (a[prop2] < b[prop2]) ? -1 : 1;
} else {
return (a[prop1] < b[prop1]) ? -1 : 1;
}
});
return sort1;
@alaztetik
alaztetik / getMaxSubSumFast.js
Created January 12, 2021 20:18
Finding the contiguous/continuous subarray of an array argument with the maximal sum of items
// Fast:
function getMaxSubSum(arr) {
let maxSum = 0;
let partialSum = 0;
for (let item of arr) { // for each item of arr
partialSum += item; // add it to partialSum
maxSum = Math.max(maxSum, partialSum); // remember the maximum
if (partialSum < 0) partialSum = 0; // zero if negative
}