Skip to content

Instantly share code, notes, and snippets.

View piharpi's full-sized avatar

Harpi piharpi

View GitHub Profile
@piharpi
piharpi / .block
Created March 16, 2020 05:27 — forked from tvalentius/.block
HDI Indonesia Choropleth Map
border: no
license: MIT

Rails naming conventions

General Ruby conventions

Class names are CamelCase.

Methods and variables are snake_case.

Methods with a ? suffix will return a boolean.

Rails naming conventions

General Ruby conventions

Class names are CamelCase.

Methods and variables are snake_case.

Methods with a ? suffix will return a boolean.

@piharpi
piharpi / group_posts_by_year_jekyll.html
Created November 24, 2019 04:43
Liquid Template language to group jekyll blog posts by year.
{% for post in site.posts %}
{% capture current_year %}
{{post.date | date: "%Y"}}
{% endcapture %}
{% if current_year != previous_year %}
{% assign previous_year = current_year %}
<h4 class="post-header">
<span role="img" aria-label="icon-book" aria-hidden="true">🎉</span>
{{ current_year }}
</h4>
@piharpi
piharpi / devise.id.yml
Last active February 12, 2021 05:54 — forked from freeskys/devise.id.yml
A translation for devise >= 4.7.1 in indonesia
# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
id:
devise:
confirmations:
confirmed: "Email anda telah berhasil dikonfirmasi."
send_instructions: "Anda akan menerima sebuah email dengan instruksi bagaimana cara untuk mengkonfirmasikan email anda."
send_paranoid_instructions: "Jika email anda telah terdaftar, anda akan menerima email dengan instruksi bagaimana cara untuk mengkonfirmasikan email anda."
failure:
already_authenticated: "Anda telah masuk."
@piharpi
piharpi / _spacing.scss
Last active September 8, 2019 03:40
Bulma spacing helper.
/*
source from bulma issues, thanks to @furey
https://github.com/jgthms/bulma/issues/451#issuecomment-331758839
*/
$sizeUnit: rem;
$marginKey: 'm';
$paddingKey: 'p';
$separator: '-';
$spacing-sizes: (
@piharpi
piharpi / auth.rb
Created April 28, 2019 17:27
just little sample authentication with bcrypt.
require 'bcrypt'
# if u not ready with bcrypt u can install by typing 'gem install bcrypt'
accounts = [
{ username: 'choirul', password: 'passwd' },
{ username: 'harpi', password: 'strongpass' },
{ username: 'mahendra', password: 'isverysecret' }
]
def create_hash(string)

Keybase proof

I hereby claim:

  • I am piharpi on github.
  • I am piharpi (https://keybase.io/piharpi) on keybase.
  • I have a public key ASDNM4bQVpTM3nJBu4QrYPj4dnAmgjgAqUXwmgS4oKdFWwo

To claim this, I am signing this object:

@piharpi
piharpi / kill-jekyll.md
Created March 17, 2019 12:25 — forked from lukehedger/kill-jekyll.md
Kill Jekyll server

Stopping a Jekyll server with ctrl-z can cause issues as the process is not stopped fully. To kill it:

$ lsof -wni tcp:4000
$ kill -9 <PID of process>

And next time, use crtl-c to stop.

@piharpi
piharpi / main.rb
Created March 11, 2019 06:47
This find day of year by number
start_of_year = Time.new(2016, 1, 1)
# p start_of_year
# p start_of_year - 180 # second
# p start_of_year - (60 * 60 * 24)
def find_day_of_year_by_number(number)
current_date = Time.new(2016, 1, 1)
one_day = 60 * 60 * 24