This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // let's code some emitters | |
| function Emitter(){ | |
| this.events = {}; | |
| } | |
| const emtr = new Emitter(); | |
| // on function to push events in array | |
| Emitter.prototype.on = function(type,listener){ | |
| this.events[type] = this.events[type] || []; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| async function loginController(){ | |
| try{ | |
| const a = await loginService(). | |
| catch((error)=> {throw new CustomErrorHandler({code: 101, message:"a failed",error: error})}); | |
| const b = await someUtil(). | |
| catch((error)=> {throw new CustomErrorHandler({code: 102, message:"b failed",error: error})}); | |
| //someoeeoe | |
| if(a && b) console.log("no one failed") | |
| }catch(error){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // this is example to make http calls in angular 4/5 | |
| // not silver bullet to follow but it get's job done | |
| import { HttpClient,HttpHeaders,HttpParams } from '@angular/common/http'; | |
| export class SomeHttpService { | |
| constructor(private httpClient: HttpClient){} | |
| // simple get method |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const express = require('express'); | |
| const graphqlHTTP = require('express-graphql'); | |
| const { buildSchema } = require('graphql'); | |
| const app = express(); | |
| let updatedCount = 0; | |
| let updatedDate = new Date(); | |
| class GetCount{ | |
| constructor(){ | |
| this.counter = updatedCount; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const express = require('express'); | |
| const app = express(); | |
| /* requiring middleware */ | |
| const { getConnection } = require('./app/middlewares/mysql'); | |
| /* connecting mysql before going to requested route */ | |
| app.use('/auth', getConnection, require('./app/controllers/auth')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "manifest_version": 2, | |
| "name": "Extension third party login", | |
| "description": "Let's do some login", | |
| "version": "1.0", | |
| "browser_action": { | |
| "default_icon": "favicon.ico", | |
| "default_popup": "index.html" | |
| }, | |
| "permissions": [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const express = require('express'); | |
| const http = require('http'); | |
| const app = express(); | |
| app.get('/', (req, res) => { | |
| res.send('Hey!!'); | |
| }); | |
| app.post('/exceptionRoute', async (req, res) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn main() { | |
| // defining variable | |
| let name = "Rust!!"; | |
| println!("Welcome to {}", name); | |
| // name = "this will throw error"; | |
| // that's beacasue by default variables are immutable | |
| // mutation of variables | |
| let mut i_can_mut = 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const path = require('path'); | |
| const express = require('express'); | |
| const app = express(); | |
| const publicPath = path.join(__dirname,'./build'); | |
| const port = process.env.PORT || 3001; | |
| app.use(express.static(publicPath)); | |
| // write all api routes here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Observable, of } from "rxjs"; | |
| export const promisify = <T>(obser: Observable<T>): Promise<T> => { | |
| return obser.toPromise(); | |
| }; | |
| function something(func: (...args) => Promise<void>): any { | |
| return func({cockIt: promisify}); | |
| } |