Skip to content

Instantly share code, notes, and snippets.

View vexdy's full-sized avatar
😶‍🌫️

vexdy

😶‍🌫️
View GitHub Profile
///// it doesnt work sometimes /////
@vexdy
vexdy / upload.js
Created January 2, 2022 12:06
Nodejs Sharex Basic Upload Rest API
const { nanoid } = require('nanoid'),
express = require('express'),
multer = require('multer'),
fs = require('fs'),
app = express()
const uploads = multer({ dest: 'static/' })
app
.use(express.static('static'))
@vexdy
vexdy / matrix.js
Created December 6, 2021 20:37
Matrix Homework
function drawMatrix(size, defaultValue) {
return Array(size).fill(defaultValue).map(()=>Array(size).fill(defaultValue));
};
function fillRectangle(x, y, width, height, matrix) {
for (let i = x; i < x + width; i++) {
for (let j = y; j < y + height; j++) {
matrix[i][j] = 1;
};
};
@vexdy
vexdy / fizzbuzz.js
Created October 12, 2021 16:04
FizzBuzz One Liner
// This is the way it comes to my mind in 10 seconds,
// there are should be better ways to do it faster but
// I want to make this as a one liner sooo.. yeah!
for(let i=1;i<101;i++){console.log((i%3==0&&i%15!==0)?'fizz':(i%5==0&&i%15!==0)?'buzz':i%15==0?'fizzbuzz':'')}
@vexdy
vexdy / get-earthquakes.js
Last active January 15, 2022 07:46
Get latest 500 earthquakes from Kandilli Rasathanesi's website
// No need for PHP APIs when you have nodejs :)
const fetch = require('node-fetch');
const crypto = require('crypto');
const moment = require('moment');
let url = 'http://www.koeri.boun.edu.tr/scripts/lst2.asp';
fetch(url)
.then(res => res.text())
.then(body => {
@vexdy
vexdy / find-channel-id.js
Created April 6, 2021 14:27
Find youtube channel ID with regex in javascript
const fetch = require('node-fetch');
const regex = /<link rel="canonical" href="(https?:\/\/)?(www\.)?youtube\.com\/(channel|user)\/[\w-]+">/g
fetch('https://www.youtube.com/channel/UCa10nxShhzNrCE1o2ZOPztg')
.then(res => res.text())
.then(body => console.log(body.match(regex)[0].split(" ")[2].replace('href=\"', '').replace('\">', '').split("/")[4]))
// Expected output:
// UCa10nxShhzNrCE1o2ZOPztg