Skip to content

Instantly share code, notes, and snippets.

# RSpec matcher for alias_method.
# https://gist.github.com/1950961
# Usage:
#
# describe User do
# it { should alias_from(:username).to(:email) }
# end
RSpec::Matchers.define :alias_from do |alias_method|
@barockok
barockok / sorting.php
Created October 1, 2011 19:05
Sorting algorithm in PHP
function quickSort($array)
{
if (!$length = count($array)) {
return $array;
}
$k = $array[0];
$x = $y = array();
for ($i=1;$i<$length;$i++) {
@barockok
barockok / bar-es6.js
Last active December 3, 2015 16:38 — forked from OliverJAsh/bar-es6.js
sandboxed-module error with transitive ES6 deps ( solve with babel )
export default 'bar';
@barockok
barockok / veritrans_vtweb_activemerchant_snippet.rb
Last active December 24, 2015 02:19
Sample code for implementation vt-web with activemerchant
merchant_id = 'XXXXXXXXXXXXXXXXXXX'
merchant_hash_key = 'XXXXXXXXXXXXXXXXXXX'
# implemetation for generating form
payment_service_for @order.id, merchant_id, \
merchant_hash_key: merchant_hash_key,
service: :veritrans,
amount: @order.total_amount,
currency: 'IDR',
html: {:id => 'payment-form' , :authenticity_token => false } do |service|

Checklist Barang

Group

  • Tenda
  • Kompor
  • Peralatan masak (panci)

Pribadi

  • Ransel/tas gunung
@barockok
barockok / saad_al_ghamidi.rb
Last active June 10, 2016 16:02
Al-quran 30 Juz 114 surah downloader reciter : Saad Al Ghamidi
require 'mechanize'
require 'nokogiri'
require 'active_support/all'
class SaadAlGhamidi
def initialize
@page_agent = Mechanize.new
@file_agent = Mechanize.new
@file_agent.pluggable_parser.default = Mechanize::Download
end
@barockok
barockok / helper_process_cli.rb
Last active June 18, 2016 15:06
common function to scripting daemon process
require 'socket'
require 'set'
require 'securerandom'
module Helper
module ProcessCLI
def running_daemon command
puts "RUNNING : #{command}"
pid_file = "/tmp/ruby-processcli-#{SecureRandom.uuid}.pid"
if ENV['SHOW_BG_OUTPUT']
@barockok
barockok / Premailer.php
Created January 10, 2012 20:39 — forked from Synchro/Premailer.php
PHP interface class for the Premailer API
<?php
/**
* Premailer API PHP class
* Premailer is a library/service for making HTML more palatable for various inept email clients, in particular GMail
* Primary function is to convert style tags into equivalent inline styles so styling can survive <head> tag removal
* Premailer is owned by Dialect Communications group
* @link http://premailer.dialect.ca/api
* @author Marcus Bointon <marcus@synchromedia.co.uk>
*/
@barockok
barockok / application_controller.rb
Created August 11, 2014 02:28
Repair Rails nested params
class ApplicationController < ActionController::Base
before_action :repair_nested_params
# -- your code here
protected
def repair_nested_params(obj = params)
obj.each do |key, value|
if value.is_a? Hash
# If any non-integer keys
@barockok
barockok / cleanstyle.iuml
Created August 27, 2022 02:01
plantuml styling
@startuml
' Preset: Monochrome
!define STYLE_DEFAULT_ACCENT #000
!define STYLE_DEFAULT_BGC #FFF
!define STYLE_DEFAULT_FGC #000
' Preset: Material Light Blue (200)
!define STYLE_LIGHT_ACCENT #81D4FA
!define STYLE_LIGHT_BGC #FFF