Skip to content

Instantly share code, notes, and snippets.

View sabril's full-sized avatar

Muhammad Syaiful Sabril sabril

View GitHub Profile
@sabril
sabril / ci.yml
Last active October 23, 2019 03:26
# .github/workflows/ci.yml
name: CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:11
@sabril
sabril / appointment.rb
Created January 11, 2019 01:50
Twilio Phone Number Provision and Release
class Appointment < ApplicationRecord
# .. this model is long and has many lines of code, so we cut it where it's important :-D
phony_normalize :phone, :default_country_code => 'US', :add_plus => true
# Associations
has_many :appointment_call_logs, dependent: :destroy
has_many :call_logs, through: :appointment_call_logs, source: :call_log
has_one :masked_number, as: :callable
#callbacks
@sabril
sabril / zoho_invoice_service.rb
Created December 21, 2018 07:01
Zoho Invoide Service using Oauth
require 'oauth2'
require 'json'
module ZohoServices
class Invoice
attr_reader :oauth_auth_code, :client
def initialize
@customer_id = "CUSTOMER_ID" # define this customer_id
@query_root = "https://invoice.zoho.com/api/v3"
@sabril
sabril / checkSoldOut.js
Created November 8, 2018 02:55
Javascript test for sureswift capital
function checkSoldOut() {
if ($('#SingleOptionSelector-0').val() == 'Large') {
$( "<div id='email_when_available' style='padding: 0 5px;'><button style='color: #fff; background-color: #900; width: 100%; '>EMAIL WHEN AVAILABLE</button></div>" ).insertAfter( ".product-form" )
} else {
$('#email_when_available').remove()
}
}
$('#SingleOptionSelector-0').on('change', function() {
checkSoldOut()
@sabril
sabril / config.yml
Last active September 6, 2017 00:26
version: 2
jobs:
build:
working_directory: ~/circleci-demo-ruby-rails
docker:
- image: circleci/ruby:2.4.1-node
environment:
RAILS_ENV: test
PGHOST: 127.0.0.1
PGUSER: root
@sabril
sabril / index.html.erb
Created August 3, 2017 23:42
Halaman Index
<div class="row">
<br/>
<% @courses.each do |course| %>
<%= link_to course do %>
<div class="col s12 m6">
<div class="card">
<div class="card-image waves-effect waves-block waves-light">
<%= image_tag course.image.url %>
</div>
<div class="card-content">
@sabril
sabril / show.html.erb
Created July 14, 2017 17:01
Task Show view
<div class="row">
<div class="col m8 offset-m2">
<% if @task.video_url.present? %>
<div class="card z-depth-2">
<div class="card-image waves-effect waves-block waves-light">
<div class="center">
<iframe width="100%" height="315" src="<%= @task.video_url %>" frameborder="0" allowfullscreen></iframe>
</div>
</div>
</div>
sudo apt-get update
\curl -sSL https://get.rvm.io | bash -s stable
sudo apt-get -y install postgresql postgresql-contrib libpq-dev
touch ~/.gemrc
echo 'install: --no-rdoc --no-ri' >> ~/.gemrc
gem install bundler --prerelease
gem install rails
rails new . -d postgresql
require 'mobile/mobile_helper'
describe 'TaskOperations', type: :request, focus: false do
before(:each) do
@account = FactoryGirl.create(:account_with_admin)
@location = @account.locations.first
@admin = FactoryGirl.create(:admin, loc_id: @location.id, account_id: @account.id)
param = FactoryGirl.attributes_for(:patient, loc_id: @location.id, account: @account, email: 'patient@mail.com')
@patient = create_user(param, @account, @admin, 'Patient')
ls -lah hello.rb