Skip to content

Instantly share code, notes, and snippets.

Avatar

Zidni Mubarock barockok

View GitHub Profile
@barockok
barockok / helper_process_cli.rb
Last active Jun 18, 2016
common function to scripting daemon process
View helper_process_cli.rb
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']
View checklist.md

Checklist Barang

Group

  • Tenda
  • Kompor
  • Peralatan masak (panci)

Pribadi

  • Ransel/tas gunung
@barockok
barockok / bar-es6.js
Last active Dec 3, 2015 — forked from OliverJAsh/bar-es6.js
sandboxed-module error with transitive ES6 deps ( solve with babel )
View bar-es6.js
export default 'bar';
@barockok
barockok / application_controller.rb
Created Aug 11, 2014
Repair Rails nested params
View application_controller.rb
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
View alias_matcher.rb
# 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 / veritrans_vtweb_activemerchant_snippet.rb
Last active Dec 24, 2015
Sample code for implementation vt-web with activemerchant
View veritrans_vtweb_activemerchant_snippet.rb
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|
@barockok
barockok / saad_al_ghamidi.rb
Last active Jun 10, 2016
Al-quran 30 Juz 114 surah downloader reciter : Saad Al Ghamidi
View saad_al_ghamidi.rb
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 / Curl.php
Created Jan 11, 2012
philsturgeon Curl CI-Library - Enabled Upload
View Curl.php
<?php defined('BASEPATH') OR exit('No direct script access allowed');
/**
* CodeIgniter Curl Class
*
* Work with remote servers via cURL much easier than using the native PHP bindings.
*
* @package CodeIgniter
* @subpackage Libraries
* @category Libraries
@barockok
barockok / Premailer.php
Created Jan 10, 2012 — forked from Synchro/Premailer.php
PHP interface class for the Premailer API
View Premailer.php
<?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 / sorting.php
Created Oct 1, 2011
Sorting algorithm in PHP
View sorting.php
function quickSort($array)
{
if (!$length = count($array)) {
return $array;
}
$k = $array[0];
$x = $y = array();
for ($i=1;$i<$length;$i++) {
You can’t perform that action at this time.