Skip to content

Instantly share code, notes, and snippets.

View SunDi3yansyah's full-sized avatar
Verified

Cahyadi Triyansyah SunDi3yansyah

Verified
View GitHub Profile
@SunDi3yansyah
SunDi3yansyah / README.md
Last active July 1, 2020 15:13
Postgresql - unable to drop database because of some auto connections to DB

REVOKE CONNECTION

REVOKE CONNECT ON DATABASE [DATABASE_NAME] FROM public;

DROP DATABASE

DROP DATABASE [DATABASE_NAME];
@SunDi3yansyah
SunDi3yansyah / README.md
Created November 1, 2019 11:15
Redis: Delete All Keys – Redis-CLI
@SunDi3yansyah
SunDi3yansyah / README.md
Created November 1, 2019 10:12
Ruby: How to find and return a duplicate value in array?
@SunDi3yansyah
SunDi3yansyah / countries.json
Last active September 6, 2019 09:38
Countries all
{
"response": {
"status": 200,
"message": "OK",
"url": "http://localhost:3000/api/v1/mixed/countries"
},
"data": [
{
"country_data_or_code": {
"continent": "South America",
@SunDi3yansyah
SunDi3yansyah / README.md
Last active September 5, 2019 05:21 — forked from niallo/gist:3109252
Parse Github `Links` header in JavaScript
/*
 * parse_link_header()
 *
 * Parse the Github Link HTTP header used for pageination
 * http://developer.github.com/v3/#pagination
 */
function parse_link_header(header) {
  if (header.length == 0) {
 throw new Error("input must not be of zero length");
@SunDi3yansyah
SunDi3yansyah / README.md
Last active April 5, 2020 15:06
Rails disable Active Storage

config/application.rb

require "active_storage/engine"

config/environments/*.rb

config.active_storage.service = :local
@SunDi3yansyah
SunDi3yansyah / postman.desktop
Created August 17, 2019 11:53
Postman launcher desktop
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Name=Postman
Icon=/home/sundi3yansyah/Src/postman/app/resources/app/assets/icon.png
Path=/home/sundi3yansyah/Src/postman
Exec=/home/sundi3yansyah/Src/postman/Postman
StartupNotify=false
StartupWMClass=Postman
@SunDi3yansyah
SunDi3yansyah / images_controller.rb
Created August 17, 2019 06:03
Example API for upload image in QuillJS
class ImagesController < ActionController::Base
skip_before_action :verify_authenticity_token
def create
@image = Image.new(image_params)
if @image.save
render json: { url: @image.image_url(:original) }, status: 201
else
render json: { message: @image.errors.full_messages.first }, status: 422
@SunDi3yansyah
SunDi3yansyah / README.md
Created August 14, 2019 11:47
Chmod for .gnupg
chown -R $(whoami) ~/.gnupg
find ~/.gnupg -type f -exec chmod 600 {} \;
find ~/.gnupg -type d -exec chmod 700 {} \;
@SunDi3yansyah
SunDi3yansyah / db.rake
Created August 14, 2019 11:12 — forked from hopsoft/db.rake
Rails rake tasks for dump & restore of PostgreSQL databases
# lib/tasks/db.rake
namespace :db do
desc "Dumps the database to db/APP_NAME.dump"
task :dump => :environment do
cmd = nil
with_config do |app, host, db, user|
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump"
end
puts cmd