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 / 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 / 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 / custom.rs
Last active March 13, 2019 19:01
Error handling in Rust Option - improved
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")
}
}
@saiumesh535
saiumesh535 / readFile.rs
Created March 13, 2019 18:22
Error hnadling in Rust - Result
use std::io;
use std::io::Read;
use std::fs::File;
fn read_from_file(file_path: &'static str) -> Result<String, io::Error> {
let mut file_data = String::new();
// now let's try to read file
@saiumesh535
saiumesh535 / git.helper.md
Last active June 15, 2020 07:08
Different users for your git project
  1. First goto project folder
  2. Initialize git by git init command
  3. Set username with git config user.name "username” command
  4. Set email with git config user.email "some@email.com command
  5. Now create a repository in GitHub
  6. Now we will either set or add origin based on project status
  7. As github disabled using plain password in git url we need to get github personal access token from here
  8. Newly added git project git remote add origin https://username:accesstoken@github.com/saiumesh535/chi-http.git
  9. Existing git project
@saiumesh535
saiumesh535 / tsconfig.json
Last active September 20, 2019 13:29
tsconfig.json
{
"compilerOptions": {
"incremental": true,
"target": "es2017",
"module": "commonjs",
"lib": ["es2017"],
"types": ["node"],
"outDir": "./build",
"rootDir": "./",
"strict": true,
@saiumesh535
saiumesh535 / tslint.json
Created April 15, 2019 16:33
tslint.json
{
"defaultSeverity": "error",
"extends": "./node_modules/tslint/lib/configs/recommended",
"linterOptions": {
"exclude": [
"node_modules/**"
]
},
"jsRules": {},
"rules": {
@saiumesh535
saiumesh535 / package.json
Created April 15, 2019 16:34
package json for TS node
"scripts": {
"dev": "tsc-watch --onSuccess \"cross-env NODE_ENV=development node build/src/index.js\"",
"prod":"tsc && cross-env NODE_ENV=production node build/src/index.js",
"lint": "tslint --project tslint.json"
}
package main
import "fmt"
type Http struct {
}
func (http *Http) Get(url string) string {
return fmt.Sprintf("the result from %s is nothing", url)
}
@saiumesh535
saiumesh535 / git.command
Created November 22, 2019 08:19
git commands
Re-clone
GIT=$(git rev-parse --show-toplevel)
cd $GIT/..
rm -rf $GIT
git clone ...
✅ Deletes local, non-pushed commits
✅ Reverts changes you made to tracked files
✅ Restores tracked files you deleted
✅ Deletes files/dirs listed in .gitignore (like build files)
✅ Deletes files/dirs that are not tracked and not in .gitignore