Skip to content

Instantly share code, notes, and snippets.

View jayjariwala's full-sized avatar
👾
Debugging

Jay Jariwala jayjariwala

👾
Debugging
View GitHub Profile
@jayjariwala
jayjariwala / gist:94681a9a6a94a0b41f74660da612e7bb
Last active December 22, 2017 15:44
Steps to get up and running with node js server using nginx reverse proxy
sudo apt-get install finger
sudo apt-get install openssh-server openssh-client
change ssh port if necessary: /etc/ssh/sshd_condig
sudo adduser student
#Give Sudo Privilages to the new user
visudo
# User privilege specification
newuser ALL=(ALL:ALL) ALL
sudo systemctl disable nginx
sudo systemctl enable nginx
sudo systemctl stop nginx
sudo systemctl start nginx
sudo systemctl restart nginx
sudo systemctl reload nginx
#To check the current directory
pwd - remote system
lpwd - local system
cd, lcd
# Copy the file from remote to local
get filename
~from local to remote
@jayjariwala
jayjariwala / gist:c4e5b0442506e8cc38ea7f7b3024c42e
Last active June 15, 2018 14:59
Apostrophe in Production on Digital Ocean or any linux server
1) Create a droplet
You will recieve an email with root password information.
2) login using ssh though your local remote terminal (find your ipaddress on the digital ocean droplet control panel) or use ssh authentication
ssh root@ipaddress
password:write from email
change password upon first login
3) Once login as a root. update latest ubuntu packages
sudo apt-get install update
sudo apt-get install upgrade
4) Add a non-root user with root previlagies
@jayjariwala
jayjariwala / gist:5fdabef00c0fb0d187a1405c1d4c29a8
Last active January 4, 2018 19:24
Mongodb Import and export commands
#Import into database
sudo mongoimport --db newdb --collection restaurants --file primer-dataset.json
#export database collection
sudo mongoexport --db newdb -c restaurants --out newdbexport.json
# Take backup
create a folder regular backup folder
sudo mkdir /var/backups/mongobackups
@jayjariwala
jayjariwala / Pomodoro-Clock .txt
Last active January 11, 2018 18:56
Pomodoro Clock
// desgin inspiration https://dribbble.com/shots/2324994-Daily-UI-Day-14-Countdown-Timer/attachments/442297
(function(){
let focusSecs;
let breakSecs;
let timer;
let isPaused = false;
let pausedSecs = 0;
You can think of clousre as a way of "remember" and continue to access a function's scope even once the function has finished running.
function makeAddr(x)
{
//paraneter 'x' is an inner variable
//inner function add() uses 'x', so it has clousre over it
function add(y)
{
return x + y;
@jayjariwala
jayjariwala / gist:f2555d900cd81150e215c2684481fa53
Last active January 17, 2018 02:02
YDK JS - Scope and Closure
Program state: the ability of a language to store value in a variable and later retrive or modify those values. In fact,
the ability store values and pull values out of variables is what gives a program state.
where do those variables live?
where are they store?
how does our program find them?
The set of rules for storing varibales in some location, and for finding those variables at a later time is called scope.
In traditional compiled-language, a chunk of source code, your program , will undergo typically three steps before it is executed, roughly called "compilcation".
This is not an author-time binding but a runtime binding.
this has nothing to do with where a function is declared, but has everthing to do with the manner in which the function is called.
when a function is invoked, an activation record, otherwise known as an exection context, is created.
it contains information about where the function was called from (the call-stack), how the function was invoked, what parameters where passed. etc.
one of the properties of this record is this reference, which will be used for the duration of that function's execution.
To understand the this binding, we have to understand the call-site.
call site and call stack
@jayjariwala
jayjariwala / Objects.md
Last active January 19, 2018 21:02
YDKJS - Objects

Objects

Syntax

Object come in two forms

  1. the declarative form (litral)
  2. Constrcted form

Declarative/litral Object