Skip to content

Instantly share code, notes, and snippets.

View saiumesh535's full-sized avatar
🤒
so long

sai umesh saiumesh535

🤒
so long
View GitHub Profile
@saiumesh535
saiumesh535 / err-option.rs
Last active March 13, 2019 18:27
Error handling in Rust Options
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
@saiumesh535
saiumesh535 / go-routines-http.go
Last active February 28, 2019 19:51
making http calls reading them in golang using goroutines
package main
import (
"encoding/json"
"fmt"
"net/http"
)
type InfoData struct {
Seed string
@saiumesh535
saiumesh535 / shuttlecock.ts
Last active November 17, 2018 15:25
Promisify Observable with callback function
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});
}
@saiumesh535
saiumesh535 / app.js
Created November 2, 2018 10:35
Serving static HTML files using express node
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
@saiumesh535
saiumesh535 / main.rs
Created September 16, 2018 18:39
Basic types and control flow for rust
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;
@saiumesh535
saiumesh535 / app.js
Last active August 31, 2019 19:57
error handling in express applicaiton
const express = require('express');
const http = require('http');
const app = express();
app.get('/', (req, res) => {
res.send('Hey!!');
});
app.post('/exceptionRoute', async (req, res) => {
@saiumesh535
saiumesh535 / manifest.json
Created April 9, 2018 17:56
Angular extension manifest file
{
"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": [
@saiumesh535
saiumesh535 / app.js
Last active February 13, 2018 18:24
connecting MySQL in express nodejs
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'));
@saiumesh535
saiumesh535 / app.js
Created February 10, 2018 19:53
GraphQL very basic example.
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;
@saiumesh535
saiumesh535 / httpcalls.ts
Last active December 12, 2017 11:49
Angular 4/5 Http calls
// 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