Skip to content

Instantly share code, notes, and snippets.

View mediter's full-sized avatar
🎯
Focusing

Yuan, Jun mediter

🎯
Focusing
View GitHub Profile
@mediter
mediter / wp_reg_sidebar.php
Last active July 11, 2018 07:18
[WordPress Sidebars] #WordPress #PHP #sidebar
register sidebar in functions.php
registering a sidebar is just defining a container
if( function_exists('register_sidebar') ) {
register_sidebar(array(
'name' => 'spage',
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h3>',
'after_title' => '</h3>'
@mediter
mediter / ruby-array-sum.rb
Created October 19, 2018 02:39
[Ruby Array Sum] #ruby #iterator #sum
# you can call #sum iterator on it:
numbers = [1, 2, 3, 4, 5]
numbers.sum
# => 15
# N.B: In Ruby versions < 2.4, sum didn't exist. The idiomatic way to get the same result was with #reduce:
@mediter
mediter / bash_for_touch_echo.md
Last active December 4, 2018 15:30
[bash for-loop with echo] #bash #for-loop #touch #echo

for-loop with echo

for model in "artists" "galleries" "paintings"
do
    mkdir -p $(echo views/api/v1/$model)
    for verb in "index" "show"
    do
        touch $(echo views/api/v1/$model/$verb.json.jbuilder)
 done
@mediter
mediter / migration_rollback.rb
Created December 9, 2018 09:49
[Rollback Migration] #migration #database #rails #ruby
rails db:rollback STEP=1
# Is a way to do this, if the migration you want to rollback is the last one applied. You can substitute 1 for however many migrations you want to go back.
# For example:
rails db:rollback STEP=5
# Will also rollback all the migration that happened later (4, 3, 2 and also 1).
# In order to rollback a specific migration use: