Skip to content

Instantly share code, notes, and snippets.

View anshdivu's full-sized avatar

Diviyansh Bhatnagar anshdivu

View GitHub Profile
local MAC_USER_ID = "db880u"
local AUTH_METHOD = "2" -- code 2 is for push notification
local SHORTCUT_HOTKEY = "F1"
-- command => osascript -e 'id of app "Cisco AnyConnect Secure Mobility Client"'
-- local CISCO_BUNDLE_ID = 'com.cisco.Cisco-AnyConnect-Secure-Mobility-Client' -- vpn version <=4.6
local CISCO_BUNDLE_ID = 'com.cisco.anyconnect.gui' -- vpn version >=4.9
local function fetchPassword(userId)
-- when you run this command the first time it will require your admin password to read keychain
{
// Place your settings in this file to overwrite the default settings
"typescript.check.npmIsInstalled": true,
"editor.snippetSuggestions": "top",
"files.autoSave": "onFocusChange",
"workbench.activityBar.visible": true,
"editor.minimap.enabled": false,
// "editor.formatOnSave": true,
// "javascript.implicitProjectConfig.checkJs": true,
"prettier.singleQuote": true,
@anshdivu
anshdivu / Node Training Catalog.md
Last active November 21, 2017 13:30
Node Training Catalog

I will add a new full stack javascript Training catalog section. This will include:

  • Getting started sections for Node.js and React.js
  • Add SWAT talk presentation for React.js and Node.js
  • Links to turtorials/learn more pages for Node and react
  • (optionally) getting started with deploying it to heroku.

Background (Technical Details)

Node.js is an open-source, cross-platform JavaScript run-time environment for executing JavaScript code server-side. It has an event-driven architecture and operates on a single thread, using non-blocking I/O calls. Since all requests are single threaded, it requires that any function performing I/O must use a callback (using an observer pattern). These design choices aim to optimize throughput and scalability, allowing Node.js to support tens of thousands of concurrent connections without incurring the cost of thread context switching.

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.Text;
package com.diviyansh.solid.openclose.step4;
class EmployeeFactory {
private String type;
public EmployeeFactory(String type) {
this.type = type;
}
public Employee create(int id, float hours) {
▶ vagrant destroy
core-01: Are you sure you want to destroy the 'core-01' VM? [y/N] y
==> core-01: Forcing shutdown of VM...
==> core-01: Destroying VM and associated drives...
==> core-01: Pruning invalid NFS exports. Administrator privileges will be required...
==> core-01: Running cleanup tasks for 'file' provisioner...
==> core-01: Running cleanup tasks for 'shell' provisioner...
==> core-01: Running cleanup tasks for 'file' provisioner...
==> core-01: Running cleanup tasks for 'shell' provisioner...
==> core-01: Running cleanup tasks for 'shell' provisioner...
core@core-01 ~ $ docker version
Client:
Version: 1.9.1
API version: 1.21
Go version: go1.4.3
Git commit: 9894698
Built:
OS/Arch: linux/amd64
Server:
@anshdivu
anshdivu / watch_to_observer.md
Created April 20, 2016 19:05
`$scope.$watch` to an Observer
References:
  • RxJS api
  • ReactiveX - main website which explains what are observables/observers.
  • RxMarbles - super cool website which visually explains all the observable operators/api functions.
$scope.$watch to rxjs.observer:

Angular $watch and rxjs observers are basically the same thing. They just have different semantics. This is why angular 2 will completely remove $watch and directly use rxjs.

// promise handles user not found by returning `null`
// advantage - don't have to write a reject handler
// disadvantage - requires developer to know the implementation detail of the facade function
// that it returns `null` or not. Higher possibility of forgeting to write `null`
// check and cause null pointer exception
function checkEmail(emailAddress) {
return facade.user.getUserByEmailAddress(emailAddress).chain(function (user) {
if (!user) {
return {available: true};
}
screen_width = `stty size`.scan(/\d+/)[1].to_i;
snow_char = ["2743".to_i(16)].pack("U*");
# clear screen
puts "\033[2J";
screen = {}; # screen as a 2D array
loop {
# select random column in first row of screen
screen[rand(screen_width)] = 0;