Skip to content

Instantly share code, notes, and snippets.


Cahyadi Triyansyah SunDi3yansyah

View GitHub Profile
View gist:56a87c0246847d916b716aa32e93bd67

Rails naming conventions

General Ruby conventions

Class names are CamelCase.

Methods and variables are snake_case.

Methods with a ? suffix will return a boolean.

jQuery(document).on 'turbolinks:load', ->
u = $("#current_user").val()
window.current_user = JSON.parse(u)
messages = $('#messages')
user_is_typing = $('#user_is_typing')
App.global_chat = App.cable.subscriptions.create {
channel: "ChatRoomsChannel"
SunDi3yansyah /
Created Jul 24, 2020
List Programming Language
473L Query
Kez Barnes Basic
SunDi3yansyah /
Created Jun 6, 2020
[GIT PULL] Pulling without specifying how to reconcile divergent branches is discouraged

warning: Pulling without specifying how to reconcile divergent branches is discouraged. You can squelch this message by running one of the following commands sometime before your next pull:

git config pull.rebase false  # merge (the default strategy)
git config pull.rebase true   # rebase
git config pull.ff only       # fast-forward only
SunDi3yansyah / test_channel_spec.rb
Created May 31, 2020 — forked from tomekw/test_channel_spec.rb
Unit testing ActionCable channels with RSpec
View test_channel_spec.rb
# app/channels/hello_channel.rb
class HelloChannel < ActionCable::Channel::Base
def say_hello(data)
times_to_say_hello = data.fetch("times_to_say_hello")
hello = "Hello, #{}!"
times_to_say_hello.times do
ActionCable.server.broadcast(, hello)
SunDi3yansyah / nginx.conf
Created May 13, 2020 — forked from weapp/nginx.conf
Return common errors as json in Nginx
View nginx.conf
error_page 500 /500.html;
location /500.html{
return 500 '{"error": {"status_code": 500,"status": "Internal Server Error"}}';
error_page 502 /502.html;
location /502.html{
return 502 '{"error": {"status_code": 502,"status": "Bad Gateway"}}';
SunDi3yansyah / message_encryptor.rb
Created Apr 17, 2020 — forked from pixeltrix/message_encryptor.rb
Action Mailer interceptor for encrypting emails using S/MIME
View message_encryptor.rb
require 'openssl'
class MessageEncryptor
class << self
include OpenSSL
def delivering_email(message)
encrypted_message = sign_and_encrypt(message.encoded,
overwrite_body(message, encrypted_message)
overwrite_headers(message, encrypted_message)
SunDi3yansyah /
Last active Apr 17, 2020
Call Exception for Sentry on Ruby

Call Exception for Sentry on Ruby

extra = {
  environment: Rails.env,
  class: exception.class,
  message: exception.message,
  backtraces: exception.backtrace,
  requests: {
    url: request.original_url,
SunDi3yansyah / build.rb
Created Apr 11, 2020 — forked from dugsmith/build.rb
Example Capistrano configuration to run RSpec tests on build instance
View build.rb
role :app, 'your-build-server-ip'
set :scm, :git
set :repository, "your-git-repo-url"
set :user, 'your-user-name'
set :deploy_to, "/Users/#{user}/deployments/build/#{application}"
set :deploy_via, :export
set :branch, 'master'
set :rails_env, 'build'
SunDi3yansyah / character_set_and_collation.rb
Created Apr 9, 2020 — forked from tjh/character_set_and_collation.rb
Convert all Rails table column collation and character set
View character_set_and_collation.rb
#!/usr/bin/env ruby
# Put this file in the root of your Rails project,
# then run it to output the SQL needed to change all
# your tables and columns to the same character set
# and collation.
# > ruby character_set_and_collation.rb
You can’t perform that action at this time.