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 ( | |
"fmt" | |
"strings" | |
) | |
func main() { | |
word := "elephant" |
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
arr = [5, 1, 3, 1, 4, 4, 5] | |
// using Set | |
/* Set is a new data structure introduced in ES6 which contains only unique elements */ | |
unique_arr = [...new Set(arr)] | |
// expanding the process | |
a_set = new Set(arr) // {5, 1, 3, 4} | |
unique_arr = Array.from(a_set) //[5, 1, 3, 4] | |
// using filter |
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 waitFor = (ms) => new Promise(r => setTimeout(r, ms)) | |
const asyncForEach = async (array, callback) => { | |
for (let index = 0; index < array.length; index++) { | |
await callback(array[index], index, array) | |
} | |
} | |
const start = async () => { | |
await asyncForEach([1, 2, 3], async (num) => { | |
await waitFor(50) |
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
default: &default | |
adapter: postgresql | |
database: bs_development | |
host: localhost | |
encoding: unicode | |
pool: 5 | |
stage: &stage-reactui | |
adapter: postgresql | |
database: bs_react_demo_apis_staging |
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
#include<bits/stdc++.h> | |
using namespace std; | |
//Define structure of linked list. i.e each block in linked list | |
struct Node { | |
int data; | |
Node* link; | |
}; | |
/* head tail |
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 ( | |
"fmt" | |
) | |
type Node struct { | |
data int | |
next *Node | |
} |
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
-- 1 is treated as prime as per this function. | |
create function is_prime(num integer) returns boolean as $$ | |
begin -- begin block; | |
for i in 2..(num/2) loop | |
if num % i = 0 then | |
return false; -- return false if it's get divided by any number smaller than half of it or half itself. | |
end if; | |
end loop; | |
return true; |
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
# Uninstall Docker | |
sudo apt-get remove docker docker-engine docker-ce docker.io | |
# Update the apt package index | |
sudo apt-get update | |
# Allow apt to use a repository over HTTPS | |
sudo apt-get install \ | |
apt-transport-https \ | |
ca-certificates \ |
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
# in you home direactory in the bash profile to display branch name in terminal add parsing script | |
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
} | |
export PS1="\u@\h \W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ " |
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
# PostgreSQL. Versions 9.3 and up are supported. | |
# | |
# Install the pg driver: | |
# gem install pg | |
# On macOS with Homebrew: | |
# gem install pg -- --with-pg-config=/usr/local/bin/pg_config | |
# On macOS with MacPorts: | |
# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config | |
# On Windows: | |
# gem install pg |
OlderNewer