Skip to content

Instantly share code, notes, and snippets.

a = ["B$u$i$ld", "$t$$h$e", "N$e$x$t", "E$$ra", "$$o$f$", "S$$of$t$wa$r$e", "De$$ve$l$op$me$n$t"]
for i in a
i.to_s
i.gsub!('$', '')
puts "#{i.upcase}"
end
@wicky-andrian
wicky-andrian / regenerate_credentials.md
Created June 30, 2020 06:01 — forked from db0sch/regenerate_credentials.md
How to regenerate the master key for Rails 5.2 credentials

If your master.key has been compromised, you might want to regenerate it.

No key regeneration feature at the moment. We have to do it manually.

  1. Copy content of original credentials rails credentials:show somewhere temporarily.
  2. Remove config/master.key and config/credentials.yml.enc
  3. Run EDITOR=vim rails credentials:edit in the terminal: This command will create a new master.key and credentials.yml.enc if they do not exist.
  4. Paste the original credentials you copied (step 1) in the new credentials file (and save + quit vim)
  5. Add and Commit the file config/credentials.yml.enc
@wicky-andrian
wicky-andrian / Kazam Audio Problem on Ubuntu 20.04 LTS
Last active June 28, 2020 04:32
Kazam audio on Ubuntu 20.04 LTS no sound, not detected audio device
I got solution from ask ubuntu and youtube chanel here the solution, its about python program:
# open terminal and run
$ sudo gedit /usr/lib/python3/dist-packages/kazam/pulseaudio/pulseaudio.py
# change all with this python code copy all after dash
-------------------------------------------------------------------------
# -*- coding: utf-8 -*-
#
# pulseaudio.py
#
# Copyright 2012 David Klasinc <bigwhale@lubica.net>
@wicky-andrian
wicky-andrian / backup.rake
Created June 25, 2020 05:09 — forked from rantoniuk/backup.rake
Rake task for backing up MySQL database in Rails projects
namespace :db do desc "Backup project database. Options: DIR=backups RAILS_ENV=production MAX=7"
task :backup => [:environment] do
datestamp = Time.now.strftime("%Y-%m-%d_%H-%M-%S")
base_path = Rails.root
base_path = File.join(base_path, ENV["DIR"] || "backups")
backup_base = File.join(base_path, 'db_backups')
backup_folder = File.join(backup_base, datestamp)
backup_file = File.join(backup_folder, "#{RAILS_ENV}_dump.sql")
FileUtils.mkdir_p(backup_folder)
db_config = ActiveRecord::Base.configurations[RAILS_ENV]
@wicky-andrian
wicky-andrian / Forms.md
Created June 19, 2020 20:04 — forked from jnewman12/Forms.md
Forms, form_for, link_to lesson

Forms, form_for, and link_to


Lesson Objectives

  1. Understand forms and the ways we write them
  2. Understand the difference between form_tag and form_for
  3. Understand link_to and how we can use it to dynamically link our application together
@wicky-andrian
wicky-andrian / upcase.rb
Created April 23, 2020 16:42
Contoh metode string part 6
a = "halooooooooooo"
puts "a = halooooooooooo"
puts "Objek id dari a: #{a.object_id}"
b = a.upcase
puts "b = a.upcase"
puts b
puts "Objek id dari b: #{b.object_id}"
@wicky-andrian
wicky-andrian / to_i.rb
Created April 23, 2020 16:37
Contoh metode string part 6
a = "234"
puts "a = 234"
puts "Contoh pakai to_i: #{a.to_i}"
b = "1234.5667"
puts "b = 1234.5667"
puts "Contoh b ada angka di belakangan: #{b.to_i}"
c = "abc"
@wicky-andrian
wicky-andrian / to_f.rb
Created April 23, 2020 16:30
Metode string part 6
a = "1234.567"
puts a
puts "Kelas awal #{a.class}"
b = a.to_f
puts b
puts "Kelas b #{b.class}"
@wicky-andrian
wicky-andrian / swapcase.rb
Created April 23, 2020 16:24
Contoh metode string part 6
a = "Pemrograman Ruby"
puts a
puts "Objek ID: #{a.object_id}"
b = a.swapcase
puts b
puts "Objek ID: #{b.object_id}"