Skip to content

Instantly share code, notes, and snippets.

View danigunawan's full-sized avatar
🏸
sehat+i

Dani Gunawan danigunawan

🏸
sehat+i
View GitHub Profile
@danigunawan
danigunawan / 2019-https-localhost.md
Created May 31, 2021 12:37 — forked from cecilemuller/2019-https-localhost.md
How to create an HTTPS certificate for localhost domains

How to create an HTTPS certificate for localhost domains

This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only.

Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial).

@danigunawan
danigunawan / subdomain-localhost-rails-5.md
Created July 15, 2020 13:00 — forked from indiesquidge/subdomain-localhost-rails-5.md
how to access subdomains locally with Rails 5

Subdomaining Localhost with Rails 5

I've been following this blog post on how to set up an api-only Rails 5 application. One of the sections talks about creating a subdomain for your api

Rails.application.routes.draw do
  constraints subdomain: "api" do
    scope module: "api" do
@danigunawan
danigunawan / .bashrc
Created July 5, 2020 19:18 — forked from hyfen/.bashrc
Save unlimited bash history in OSX
# save history to ~/.bash_history as soon as command is run
export PROMPT_COMMAND='history -a'
# save unlimited history
# osx doesn't seem to respect =-1 or = options
export HISTSIZE=9999999999
export HISTFILESIZE=999999999
# osx doesn't actually respect this and it'll fall back to unix timestamp (which we want)
export HISTTIMEFORMAT="%d/%m/%y %T "
@danigunawan
danigunawan / post-receive.sh
Created June 18, 2020 05:38 — forked from benfrain/post-receive.sh
post-receive hook for multiple branches
#!/bin/bash
while read oldrev newrev ref
do
branch=`echo $ref | cut -d/ -f3`
if [ "master" == "$branch" ]; then
git --work-tree=./path/under/root/dir/live-site/ checkout -f $branch
echo 'Changes pushed live.'
fi
@danigunawan
danigunawan / amazon-rekognition.md
Created May 27, 2020 11:38 — forked from alexcasalboni/amazon-rekognition.md
Amazon Rekognition - Python Code Samples

Amazon Rekognition - Python Code Samples

  1. Labels Detection
  2. Faces Detection
  3. Faces Comparison
  4. Faces Indexing
  5. Faces Search
@danigunawan
danigunawan / amazon-rekognition.md
Created May 27, 2020 11:38 — forked from alexcasalboni/amazon-rekognition.md
Amazon Rekognition - Python Code Samples

Amazon Rekognition - Python Code Samples

  1. Labels Detection
  2. Faces Detection
  3. Faces Comparison
  4. Faces Indexing
  5. Faces Search
@danigunawan
danigunawan / rails http status codes
Created March 24, 2020 03:25 — forked from mlanett/rails http status codes
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
@danigunawan
danigunawan / UserProfile.rb
Created March 19, 2020 17:08 — forked from rahul100885/UserProfile.rb
Simple json file upload in rails api
class UserProfile < ActiveRecord::Base
has_attached_file :picture,
styles: {
original: {geometry: '1000x0>'},
thumb: '100x100#',
large: '300x200>',
},
convert_options: {large: "-quality 80 -strip -interlace Plane"},
default_url: "http://s3-ap-southeast-1.amazonaws.com/#{ENV["S3_BUCKET"]}/user_profiles/placeholder.png",
path: (Rails.env == 'test' || Rails.env == 'development') ? ":rails_root/public/images/:class/:id/:style/:filename" : "/:class/:id/:style/:filename",
@danigunawan
danigunawan / Dockerfile.webcam
Created February 29, 2020 15:17 — forked from enric1994/Dockerfile.webcam
Using the webcam in a GPU enabled Docker Compose
FROM tensorflow/tensorflow:latest-gpu-py3
RUN apt update -y && apt install -y \
libsm6 \
libxext6 \
libxrender-dev
RUN pip install \
opencv-python
@danigunawan
danigunawan / file_string_io.rb
Created February 11, 2020 17:37 — forked from moreta/file_string_io.rb
ruby image base64 string upload to s3
class CustomFileStringIO < StringIO
def initialize(*args)
super(*args[1..-1])
@file_name = args[0]
end
def original_filename
@file_name
end
end