Skip to content

Instantly share code, notes, and snippets.

View avidmaulanas's full-sized avatar

Avid Maulana Saputra avidmaulanas

  • KOPIHUB
  • Bandung
View GitHub Profile
@avidmaulanas
avidmaulanas / adjust_quantity.rb
Created March 15, 2023 14:36
make nested attributes work changes on parent save
# == Schema Information
#
# Table name: adjust_quantities
#
# quantity_in_stock :int
class AdjustQuantity
attr_accessor :adjust_quantity
def adjust_quantity=(val)
@avidmaulanas
avidmaulanas / Preferences.sublime-settings.txt
Last active May 7, 2018 05:47
Preferences.sublime-settings
{
"color_scheme": "Packages/Theme - Spacegray/base16-eighties.dark.tmTheme",
"file_exclude_patterns":
[
"*.sql",
"*.log",
"*.pyc",
"*.pyo",
"*.exe",
"*.dll",
@avidmaulanas
avidmaulanas / fix_warning_ssh
Last active March 20, 2017 04:02
Fix warning SSH
Fixing “WARNING: UNPROTECTED PRIVATE KEY FILE!” on Linux
If you are getting this error then you probably reset the permissions on your hidden .ssh directory in your user folder, and your keys aren’t going to work anymore. It’s very important that these files not be writable by just anybody with a login to the box, so openssh will give you an error if you try to use them.
The full error message:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0744 for '/home/geek/.ssh/id_rsa' are too open.
It is recommended that your private key files are NOT accessible by others.
@avidmaulanas
avidmaulanas / simple-image-upload.js
Created January 23, 2017 05:24 — forked from irfanfadilah/simple-image-upload.js
Simple Validation and Preview for Image Upload (JavaScript)
var _URL = window.URL || window.webkitURL;
$("#article_image").change(function(){
var file, img, reader;
if ((file = this.files[0])) {
img = new Image();
img.onload = function(){
if ( (this.width < 960) || (this.height < 300) ) {
alert("Image must be larger than 960x300 pixels!")
} else {
@avidmaulanas
avidmaulanas / add_ssh_key
Created July 23, 2016 09:31
Add ssh-key to server
add ssh-key to:
~/.ssh/authorized_keys
@avidmaulanas
avidmaulanas / config
Created May 19, 2016 02:52
SSH Config
# contents of $HOME/.ssh/config
Host dev
HostName example.com
User username
@avidmaulanas
avidmaulanas / check_size
Created May 16, 2016 07:56
Commad Linux for check directory size
du -sh is a good place to start. The options are (from man du):
-s, --summarize
display only a total for each argument
-h, --human-readable
print sizes in human readable format (e.g., 1K 234M 2G)
To check more than one directory and see the total, use du -sch:
-c, --total
@avidmaulanas
avidmaulanas / list_number
Last active May 12, 2016 02:26
List number in English
## List number
1st, 2nd, 3rd, 4th, 5th,
6th, 7th, 8th, 9th, 10th,
11th, 12th, 13th, 14th, 15th,
16th, 17th, 18th, 19th, 20th,
21st, 22nd, 23rd, 24th, 25th,
31st, 42nd, 53rd, 61st, 72nd,
73rd, 101st, 102nd, 103rd, 104th,
111th, 112th, 113th, 121st, 131st,
132nd, 133rd, 210th, 211th, 212th,
@avidmaulanas
avidmaulanas / cai
Created May 10, 2016 07:02
Color Scheme for Gnome Terminal http://mayccoll.github.io/Gogh/
$ wget -O xt http://git.io/v3Dli && chmod +x xt && ./xt && rm xt
https://raw.githubusercontent.com/Mayccoll/Elementary-OS-Terminal-Colors/master/images/cai.png
@avidmaulanas
avidmaulanas / net_ftp.rb
Last active May 10, 2016 04:51
Open FTP Connection with Ruby Net::FTP
require 'net/ftp'
Net::FTP.new('host.example.com') do |ftp|
ftp.passive = true
ftp.login('username', 'password')
ftp.getbinaryfile('ftp/dir', 'example.file')
end