Skip to content

Instantly share code, notes, and snippets.

View coolbrg's full-sized avatar

Budh Ram Gurung (BRG) coolbrg

View GitHub Profile
class SelfDemo
def foo(val)
@value = val
bar
end
def bar
puts @value
end
end
@coolbrg
coolbrg / gist:80299aa64c1e20f0842c
Created June 25, 2014 03:24
Lambda and Proc Return Behavior
def lambda_test
lam = lambda { return }
lam.call
puts "Hello world"
end
puts "Lambda Test : #{lambda_test }"
def proc_test
proc = Proc.new { return }
@coolbrg
coolbrg / gist:80398b788cf5b02374ca
Created June 25, 2014 04:56
Rails uses open classes
class Fixnum
def hours
self * 3600
end
def from_now
Time.now + self
end
end
@coolbrg
coolbrg / gist:5a182274954ba883587f
Last active August 29, 2015 14:02
Mapping Code for Ruby Metaprogramming Course
RUBY_EXPERIENCE_POINT = 50
# Student Class
class Student
KNOWLEDGE_TARGET = 75 # 75 percentage of cencepts
DEFAULT_EXPERIENCE_PERCENT = 10
attr_accessor :enthusiastic, :class_details
def initialize(ruby_experience, enthusiastic)
# ==================== Main Behavior ================================
RUBY_EXPERIENCE_POINT = 50
metaprogramming_classes.each_with_index do |klass, index|
klass_day = index + 1
author.publish_to_repo(klass.demo_code_snippets, klass_day)
students.each do |student|
code_snippets = student.refer_to_repo(klass, klass_day)
student.run_and_understand(code_snippets, which_day) # gain some experience
@coolbrg
coolbrg / gist:d7db055ca974c43d788a
Created October 29, 2014 06:10
My sublime user default settings
{
"color_scheme": "Packages/User/Monokai (SL).tmTheme",
"detect_indentation": true,
"font_size": 13,
"hayaku_CSS_prefixes_no_unprefixed": true,
"hayaku_CSS_prefixes_only":
[
"webkit",
"moz",
"o"
@coolbrg
coolbrg / gist:05080369d4b2ca41c336
Created November 3, 2014 07:23
'sudo systemctl status etcd' result
etcd.service - etcd
Loaded: loaded (/usr/lib/systemd/system/etcd.service; disabled)
Active: failed (Result: exit-code) since Mon 2014-11-03 07:13:09 UTC; 8min ago
Docs: https://github.com/coreos/etcd
Process: 3494 ExecStart=/usr/local/bin/etcd $DAEMON_ARGS (code=exited, status=203/EXEC)
Main PID: 3494 (code=exited, status=203/EXEC)
Nov 03 07:13:09 kubernetes-master systemd[1]: Started etcd.
Nov 03 07:13:09 kubernetes-master systemd[1]: etcd.service: main process exited, code=exited, status=203/EXEC
Nov 03 07:13:09 kubernetes-master systemd[1]: Unit etcd.service entered failed state.
@coolbrg
coolbrg / gist:41ea3495f429a6acd71b
Created November 26, 2014 07:48
Error in atlantis-builder
---> 88168568ea56
Removing intermediate container 2c2e42df57a8
Step 6 : RUN runsvdir /etc/service & svpid=$! && apt-get install -f -y && kill $svpid
---> Running in 3434967838ee
Reading package lists...
Building dependency tree...
Reading state information...
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.

Resize a Hard Disk for a Virtual Machine

Our Virtual Machines are provisioned using Vagrant from a Linux base box to run using VirutalBox. If the Hard Disk space runs out and you cannot remove files to free-up space, you can resize the Hard Disk using some VirtualBox and Linux commands.

Some assumptions

The following steps assume you've got a set-up like mine, where:

package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
"sync"
)