Skip to content

Instantly share code, notes, and snippets.

@yudapc
yudapc / example hash to object
Last active November 18, 2015 02:34
Ruby - Hash to Object
class Hashit
def initialize(hash)
hash.each do |k,v|
self.instance_variable_set("@#{k}", v.is_a?(Hash) ? Hashit.new(v) : v)
self.class.send(:define_method, k, proc{self.instance_variable_get("@#{k}")})
self.class.send(:define_method, "#{k}=", proc{|v| self.instance_variable_set("@#{k}", v)})
end
end
end
@yudapc
yudapc / boxgue.conf
Created November 13, 2015 16:25
Apache2 OS X
# /etc/apache2/vhost
<VirtualHost *:80>
ServerName local.boxgue.com
ServerAlias local.boxgue.com
DocumentRoot "/Users/cogati/Sites/boxgue"
ErrorLog "/private/var/log/apache2/boxgue.com-error_log"
CustomLog "/private/var/log/apache2/boxgue.com-access_log" common
ServerAdmin [email protected]
</VirtualHost>
@yudapc
yudapc / Add User for specific database
Last active August 29, 2015 14:19
Mysql Ubuntu 14.04
CREATE USER 'userbaru'@'localhost' IDENTIFIED BY 'password_disini';
GRANT ALL PRIVILEGES ON namadatabase.* To 'userbaru'@'localhost' IDENTIFIED BY 'password_disini';
change password user:
use mysql;
update user set password=PASSWORD('your_new_password') where User='root';
@yudapc
yudapc / php
Last active July 29, 2016 07:41
fizzbuzz code
<?php
for($i = 1; $i <= 100; $i++) {
$val = $i;
if($i % 3 == 0) $val = "Fizz";
if($i % 5 == 0) $val = "Buzz";
if($i % 3 == 0 && $i % 5 == 0) $val = "FizzBuzz";
echo $val."\n";
}