Skip to content

Instantly share code, notes, and snippets.

View rishabhgupta's full-sized avatar
🏠
Working from home

Rishabh Gupta rishabhgupta

🏠
Working from home
View GitHub Profile
hoisting();
console.log(a);
var a = "hello hoisting";
function hoisting() {
console.log('hoisted function');
}
@rishabhgupta
rishabhgupta / directive-compile.js
Last active April 18, 2018 19:15
Directives in Angular JS
myapp.directive("searchResult",function(){
return {
restrict: "AECM",
temlateUrl: "directives/searchResult.tpl.html",
replace: true,
scope: {
studentName: "@", // Symbol for creating a text hole
studentObject: "=", // Symbol for object hole
studentFunction: "&", // Symbol for function hole
},
@rishabhgupta
rishabhgupta / directive-example.html
Created April 15, 2018 15:00
Directives in Angular JS
<h1>Results</h1>
<searchResults></searchResults>
<searchResults></searchResults>
<searchResults></searchResults>
@rishabhgupta
rishabhgupta / alexa-card-options.js
Last active April 22, 2018 00:00
Alexa Skill Developement
options.cardTitle = "Hello World";
options.cardContent = "Hello" + name + " from Helloworld";
# import Flask
from flask import Flask
# import Ask Class and statement method from flask_ask
from flask_ask import Ask, statement
# create a flask app
app = Flask(__name__)
# define alexa endpoint
ask = Ask(app, '/alexa_end_point')
@rishabhgupta
rishabhgupta / global_script.js
Last active May 8, 2018 22:56
Javascript Design Patterns
var prefixes = ['hello', 'hi', 'ola'],
quotes = [
"Set a goal that makes you want to jump out of bed in the morning",
"When you start each day with a grateful heart…",
"I opened two gifts this morning. They were my eyes.",
"Some days you just have to create your own sunshine"
],
said = [],
print = function(msg){
said.push('<div>' + msg + '</div>');
@rishabhgupta
rishabhgupta / abs_factory_create.js
Last active May 19, 2018 13:45
Creational Design Patterns in Javascript
(function (win, $) {
...
...
var NumberplateFactory = function () {
// To manage which number plate needs to be created.
this.types = {};
this.create = function(type){
return new this.types[type]().create();
};
var getNum = () => 5;
// Translates to
var getNum = function(){
return 5;
}
@rishabhgupta
rishabhgupta / array_iterator.js
Last active July 12, 2018 04:37
symbols Iterators and generators
let emailIds = ['a@gmail.com','b@gmail.com','c@gmail.com']
console.log( emailIds[Symbol.iterator] ); // Property name is a symbol
// OUTPUT: function
@rishabhgupta
rishabhgupta / avengers.js
Last active August 23, 2020 22:02
Photoshop
#include "/Users/cipherhack/Documents/Adobe Scripts/json2.js"
// Suppress dialogs
app.displayDialogs = DialogModes.NO;
// Read cast data from json file
const jsonFile = File("/Users/cipherhack/Documents/Adobe Scripts/cast.json");
jsonFile.open ('r');
const data = jsonFile.read();
jsonFile.close();
// Close the file as we don't need it anymore
var castData= JSON.parse(data);