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 read_from_vec(input: &Vec<i32>, index: usize) -> Result<i32, &'static str> { | |
return match input.get(index) { | |
Some(value) => Ok(*value), | |
None => Err("Out of bound exception") | |
} | |
} | |
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() { | |
// first let's define vector/array of numbers | |
let numbers = vec![1, 2, 4]; | |
// now let's try to read value from vector | |
let index_one = numbers[1]; | |
println!("value at index {}", index_one); | |
// now let's try to read 10th index which doesn't exists | |
// since Rust doesn't have neither null nor try/catch to handle 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
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
"net/http" | |
) | |
type InfoData struct { | |
Seed string |
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}); | |
} |
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
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 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
{ | |
"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 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
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; |