Skip to content

Instantly share code, notes, and snippets.

View mufid's full-sized avatar

Mufid mufid

View GitHub Profile
mainTextFrame.Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum"
[1] pry(main)> require 'pp'
=> false
[2] pry(main)> pp RubyVM::InstructionSequence.compile('["aku", "suka", "ini"]').to_a
["YARVInstructionSequence/SimpleDataFormat",
2,
3,
1,
{:arg_size=>0, :local_size=>0, :stack_max=>3},
"<compiled>",
"<compiled>",
@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