Skip to content

Instantly share code, notes, and snippets.

View mirzalazuardi's full-sized avatar
🙃

Mirzalazuardi Hermawan mirzalazuardi

🙃
View GitHub Profile
@mirzalazuardi
mirzalazuardi / 01.md
Created March 18, 2024 04:50 — forked from acfatah/01.md
How to set up Rails 6 production on Digital Ocean One Click Ruby on Rails Droplet

How to set up Rails 6 production on Digital Ocean One Click Ruby on Rails Droplet

1. Clone The Source

Clone the source repository.

2. Generate Secret Key

Run rails secret to generate secret key and set SECRET_KEY_BASE to the value later in ~/.profile.

@mirzalazuardi
mirzalazuardi / README.md
Created October 31, 2023 05:07 — forked from equivalent/README.md
Rails 7 importmaps dropzone.js direct upload ActiveStorage

This is simple implementation of technologies in hobby project of mine built in Rails7 where I need direct upload to S3.

#!/bin/sh
# echo sudo apt update
# sudo apt install -y curl net-tools tmux vim
# SLACK_WEBHOOK_URL=https://yourslackwebhookurl
hs=`hostname`
down_message="$hs logger is not running, please check"
while true
do
if nc -zw1 google.com 443; then
@mirzalazuardi
mirzalazuardi / .rspec
Created April 6, 2023 22:43 — forked from alistairtweed/.rspec
Testing Rails with RSpec, Factory Bot, Faker and Shoulda Matchers
--require spec_helper
# Dockerfile
FROM ruby:2.6.3
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs postgresql-client-11 graphviz &&\
curl -sL https://deb.nodesource.com/setup_10.x | bash - && \
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt-get update && apt-get install -y nodejs yarn
RUN mkdir /app
WORKDIR /app
ADD Gemfile /app/Gemfile
@mirzalazuardi
mirzalazuardi / scrap.rb
Last active May 19, 2020 01:54
scrapping with watir and nokogiri (dynamic js)
browser = Watir::Browser.new(:chrome, headless: true)
browser.goto(url)
doc = browser.element(css: 'html').wait_until(&:present?)
Nokogiri::HTML(doc.inner_html).css('html’)
@mirzalazuardi
mirzalazuardi / .pryrc
Created October 4, 2019 06:46
pry configuration
require 'rubygems'
Pry.commands.alias_command 'c', 'continue'
Pry.commands.alias_command 's', 'step'
Pry.commands.alias_command 'n', 'next'
Pry.config.editor = "nvim"
def pbcopy(input)
str = input.to_s
IO.popen('pbcopy', 'w') { |f| f << str }
str
@mirzalazuardi
mirzalazuardi / pipeline.php
Last active January 18, 2019 05:01
PHP #2
<?php
/**As part of a data processing pipeline, complete the implementation of the make_pipeline method:
- The method should accept a variable number of functions, and it should return a new function that accepts one parameter $arg.
- The returned function should call the first function in the make_pipeline with the parameter $arg, and call the second function with the result of the first function.
- The returned function should continue calling each function in the make_pipeline in order, following the same pattern, and return the value from the last function.
For example, Pipeline::make_pipeline(function($x) { return $x * 3; }, function($x) { return $x + 1; }, function($x) { return $x / 2; }) then calling the returned function with 3 should return 5.
**/
class Pipeline
{
public static function make_pipeline()
<?php
/**A palindrome is a word that reads the same backward or forward. Write a function that checks if a given word is a palindrome.
* Character case should be ignored. For example, isPalindrome("Deleveled") should return true as character case should be ignored, resulting in "deleveled", which is a palindrome since it reads the same backward and forward.
**/
class Palindrome
{
public static function isPalindrome($word)
{
$word = trim($word);
$word = strtolower($word);
-- Students
-- Given the following data definition, write a query that returns the number of students whose first name is John.
-- TABLE students
-- id INTEGER PRIMARY KEY,
-- firstName VARCHAR(30) NOT NULL,
-- lastName VARCHAR(30) NOT NULL
SELECT COUNT(*) AS numOfStudent
FROM students
WHERE firstName = 'John'