Skip to content

Instantly share code, notes, and snippets.

View alexcambose's full-sized avatar
🦄

Alexandru Cambose alexcambose

🦄
View GitHub Profile
const express = require('express');
const axios = require('axios');
const mime = require('mime');
const morgan = require('morgan');
const { URL } = require('url');
const app = express();
const port = process.env.PORT || 80;
// app.use(morgan('tiny'));
We couldn’t find that file to show.
@alexcambose
alexcambose / commands.sh
Last active July 2, 2019 09:25
Common commands to run after installing linux
sudo snap install chromium && sudo snap install code --classic && sudo snap install webstorm --classic && sudo snap install spotify && sudo snap install slack --classic && sudo pt instal nodejs -y && sudo apt install npm -y && sudo apt install git
# gestures
sudo gpasswd -a $USER input
/usr/bin/gnome-session-quit --no-prompt
sudo apt-get install libinput-tools
const getOffset = (element, horizontal = false) => {
if(!element) return 0;
return getOffset(element.offsetParent, horizontal) + (horizontal ? element.offsetLeft : element.offsetTop);
}
// calling
const someElement = document.getElementById('someElementId');
const X = getOffset(someElement);
const Y = getOffset(someElement, true);
@alexcambose
alexcambose / offset.js
Created February 7, 2019 08:39
Offset
const getOffsetTop = element => {
let offsetTop = 0;
while(element) {
offsetTop += element.offsetTop;
element = element.offsetParent;
}
return offsetTop;
}
// calling
@alexcambose
alexcambose / selectionSort.js
Created January 12, 2019 13:37
JavaScript Selection Sort
let array = [3, 1, 4, 5, 3, 2, 6];
for (i = 0; i < array.length - 1; i++) {
let nextMinIndex = i;
for (j = i + 1; j < array.length; j++) {
// search for the smallest number in the unsorted partition
if (array[j] < array[nextMinIndex]) nextMinIndex = j;
}
if (nextMinIndex != i) {
@alexcambose
alexcambose / insertionSort.js
Created January 11, 2019 20:43
JavaScript Insertion Sort
let array = [3,1,4,5,3,2,6];
for(let i = 1; i < array.length; i++) {
let j = i - 1; // array[0...i-1] is sorted
let temp = array[i];
while(j >= 0 && array[j] > temp) {
array[j+1] = array[j];
j--;
}
@alexcambose
alexcambose / bubbleSort.js
Last active January 12, 2019 09:39
JavaScript bubble sort
let array = [3,1,4,5,3,2,6];
for(let i = 0; i < array.length; i++) {
for(j = i + 1; j < array.length; j++) {
if(array[i] > array[j]) {
// swap
const temp = array[i];
array[i] = array[j];
array[j] = temp;
}
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;
int n, i, l;
char s[200], cuv[200];
int main() {
//cin.getline(cuv, 200);
strcpy(cuv, "TPQAREDSXMRYIUVE");
import threading
import time
import urllib.request
global x;
x=0
def workf():
global x;
while True:
urllib.request.urlopen('http://')
x=x+1