This file contains 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
#!/bin/bash | |
set -e | |
update() { | |
sudo apt update #&& sudo apt upgrade -y | |
} | |
credential() { | |
sudo apt install make g++ git curl redis-server libgmp3-dev zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev postgresql postgresql-contrib libpq-dev -y |
This file contains 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
#!/bin/bash | |
set -e | |
# clone sublime config from github | |
clone() { | |
git clone https://github.com/aaripurna/sublime-config.git ~/sublime-config | |
rm -rf sublime-config/.git | |
cd ~/.config/sublime-text-3/Installed\ Packages/ | |
mv ~/sublime-config/* ./ |
This file contains 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
# EditorConfig is awesome: https://EditorConfig.org | |
# top-most EditorConfig file | |
root = true | |
# Unix-style newlines with a newline ending every file | |
[*] | |
end_of_line = lf | |
insert_final_newline = true |
This file contains 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
#!/bin/bash | |
set -e | |
export ror='https://gist.githubusercontent.com/aaripurna/56ff2ab5f6320984c105f337d500cd3f/raw' | |
get-config() { | |
link=${!1} | |
if [[ ! -z $link ]]; then | |
curl -L $link | tee $HOME/.editorconfig/$1 | |
else |
This file contains 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
I am assuming that the modles will look like this | |
class Customer < ApplicationRecord | |
has_many :purcases | |
# Rest of the code | |
end | |
class Purcase < ApplicationRecord | |
has_one :discount_coupon_usage | |
# Rest of the code |
This file contains 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
{ | |
"data": [ | |
{ | |
"code": "pos", | |
"name": "POS Indonesia (POS)" | |
}, | |
{ | |
"code": "jne", | |
"name": "Jalur Nugraha Ekakurir (JNE)" | |
}, |
This file contains 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
// Sometimes will retun None | |
fn some_operation() -> Option<String> { | |
// Some operation that may return None | |
} | |
fn write_text() { | |
match some_iperation() { | |
Some(text) => println!("{}", text), | |
None => println!("There is nothing") | |
} |
This file contains 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
// Destructuring a struct | |
Person { | |
name: person_name, | |
age: person_age, | |
... | |
} = person; | |
println!("{}", person_name); |
This file contains 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 some_operation() -> Result<str, Error> { | |
if succeded() { | |
Ok("We did it") | |
} else { | |
Err(Error::from("this not working")) | |
} | |
} | |
fn main() { | |
match some_operation() { |
This file contains 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
match connect_database() { | |
Ok(mut conn) => match conn.fetch_user() { | |
Ok(user) => conn.get_post(user.id) { | |
Ok(post) => conn.get_comments(post.id) { | |
Ok(_comments) => println!("We got the coments"), | |
Err(_) => println!("its error, no comment") | |
} | |
Err(_) => println!("Can't find post") | |
} | |
Err(_) => println!("Can't find user") |
OlderNewer