Skip to content

Instantly share code, notes, and snippets.

View UXnomaan's full-sized avatar

Nomaan Ahgharian UXnomaan

View GitHub Profile
@UXnomaan
UXnomaan / findMissingNumber.js
Last active February 25, 2019 17:49
Find Missing Numbers in an array
/*
You are given a list of n-1 integers and these integers are in the range of 1 to n.
There are no duplicates in list. One of the integers is missing in the list.
Write an efficient code to find the missing integer.
*/
const findMissing = (nums) => {
let n;
@UXnomaan
UXnomaan / compressSequence.js
Last active March 14, 2018 03:19
Compresses a sequence
// Assuming that someone dictates you a sequence of numbers and you need to write it down.
// For brevity, he dictates it as follows: first says the number of consecutive identical numbers and then
// says the number itself. E.g. The sequence 1 1 3 3 3 2 2 2 2 14 14 14 11 11 11 2 will be dictated as
// "Two times one, three times three, four times two, three times fourteen, three times eleven, one time two",
// so you will write down the sequence 2 1 3 3 4 2 3 14 3 11 1 2.
// Compresses a given sequence using this approach
const compressSequence = seq => {
let counter = 1;
let result = "";
@UXnomaan
UXnomaan / LongestLine.js
Last active April 26, 2019 03:17
Get the N longest line
/* Write a program to read a multiple line text file and write the 'N' longest lines to stdout. Where the file to be read is specified on the command line.
Input sample:
Your program should read an input file (the first argument to your program). The first line contains the value of the number 'N' followed by multiple lines. You may assume that the input file is formatted correctly and the number on the first line i.e. 'N' is a valid positive integer.e.g.
2
Hello World
CodeEval
Quick Fox
@UXnomaan
UXnomaan / gist:9574934f09b0c131b41887513ef351ae
Created December 13, 2017 03:50
Create a macOS bootable USB
sudo /Applications/Install\ OS\ X\ El\ Capitan.app/Contents/Resources/createinstallmedia --volume /Volumes/Untitled --applicationpath /Applications/Install\ OS\ X\ El\ Capitan.app --nointeraction
- Download the image to your computer: https://www.raspberrypi.org/downloads/
- Use Etcher to brun the ISO to your sd card: https://etcher.io/
- Create a `wpa_supplicant.conf` file:
`sudo nano /etc/wpa_supplicant/wpa_supplicant.conf`
- add the following to the `wpa_supplicant.conf`
```
network={
ssid="YOUR SSID"
psk="YOUR PASSWORD"
}
@UXnomaan
UXnomaan / gist:2b53d9d0eea911520ba27801fd3572cc
Last active September 4, 2017 22:52
AWS ubuntu for a nodejs backend
#node
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
#git
sudo apt-get install git