Skip to content

Instantly share code, notes, and snippets.

View mufid's full-sized avatar

Mufid mufid

View GitHub Profile
@mufid
mufid / pg.rb
Created February 15, 2017 08:58
Rails Nested Query
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'rails', '>= 5.0.1'
@mufid
mufid / autoconv.rb
Created March 31, 2016 00:58
Convert all file in the directory to *.FLAC
target = ARGV.last
puts "Will process: #{target}"
class Fixnum
def mb
self * 1024 * 1024
end
def to_mb
self / 1024 / 1024
@mufid
mufid / g_rbt_asia_fetcher.rb
Created July 20, 2015 02:07
g_rbt_asia_fetcher.rb
class GRbtAsia < Fetcher
BASE_URL = "https://rbt.asia/g"
PAGE_TEMPLATE = "https://rbt.asia/g/g?task=page&page=%{page}"
THREAD_TEMPLATE = "https://rbt.asia/g/thread/%{thread}"
def fetch_page page_num
puts "Start fetch page #{page_num}"
html = RestClient.get(PAGE_TEMPLATE % {page: page_num})
doc = Nokogiri::HTML(html)
@mufid
mufid / gist:c92b876d28437400597a
Created May 7, 2015 01:20
ruby-descriptive-statistics-sample.rb
#!/usr/bin/env ruby
require "rubygems"
require 'descriptive_statistics'
arr = []
ARGF.each_with_index do |line, idx|
# print ARGF.filename, ":", idx, ";", line
arr << line.to_i if line.to_i > 0

Having Fun with Java's Null

So lately i have been diving really deep (or not really) into Java. I found Java's null is interesting. I think, i hate NullPointerException very much. And most of the time, i hate my own way to deal with those things.

Btw, if you hate compiling Java's code just to test a one-line command, you may use [JavaRepl], which will give you an interactive mode of Java compiler.

String Concatenation

This is interesting. If you run

@mufid
mufid / README.md
Created December 4, 2014 15:32
Homakov's No-captcha Recaptcha Clickjacking
body {
background: red !important;
}
#!/bin/env ruby
# MIT License
# Debug purpose
first = true;
# Some dummy class
class Student
attr_accessor :id # Retrieved from myself.txt
attr_accessor :full_name # Retrieved from myself.txt
@mufid
mufid / golput.md
Last active August 29, 2015 13:57

Gw membantu rekan-rekan yang mencoba mengurangi angka golput dengan membuat artikel publik di sini. Cheers! Advertise problem ini ya! :D

Jadi, alasan golput itu adalah karena tidak percaya dengan pemerintah. Jadi ada 2 solusi atas ini:

  • solusi pertama adalah dengan memilih salah satu partai/ca-wa-pres/caleg DAN mengawal kinerja mereka. ANDAI kinerja mereka buruk di tengah pemerintahan, maka kita akan lakukan petisi / aksi protes.
  • solusi kedua adalah dengan tidak memilih, karena toh semua partai juga korupsi. TETAPI, jangan lupa seharusnya kita bisa memilih yang least evil dari semua evil.
  • solusi ketiga adalah dengan membuat pesta pemilu, mungkin itu adalah seminar / talkshow yang membahas kenapa kita harus gak golput.

Sederhana? Tetapi kedua solusi ini sepertinya tidak meng-cover masalah utama: tidak percaya (lagi) dengan pemerintah, menganggap siapapun yang terpilih, sama saja.

~ fid@lab
$ ps haux
root 1 0.0 0.2 93504 4752 ? Ss 11:07 0:01 /sbin/init
root 2 0.0 0.0 0 0 ? S 11:07 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? S 11:07 0:00 [ksoftirqd/0]
root 4 0.0 0.0 0 0 ? S 11:07 0:00 [kworker/0:0]
root 5 0.0 0.0 0 0 ? S< 11:07 0:00 [kworker/0:0H]
root 7 0.0 0.0 0 0 ? S 11:07 0:00 [migration/0]
root 8 0.0 0.0 0 0 ? S 11:07 0:00 [rcu_bh]
root 9 0.0 0.0 0 0 ? S 11:07 0:00 [rcuob/0]