Skip to content

Instantly share code, notes, and snippets.

@maderaka
maderaka / static.go
Last active October 12, 2015 19:02
Web server sederhana dengan golang
package main
import (
"fmt"
"net/http"
)
var routes map[string]func(http.ResponseWriter, *http.Request)
func main() {
package main
import (
"net/url"
"strings"
"net/http"
"os"
"io"
"fmt"
)
@maderaka
maderaka / martini.go
Last active August 4, 2019 14:28
An example of using Golang Martini & NSQ
package main
import (
"encoding/json"
"fmt"
"github.com/bitly/go-nsq"
"github.com/codegangsta/inject"
"github.com/go-martini/martini"
"log"
"net/http"
@maderaka
maderaka / librarian.go
Created October 5, 2015 05:50
Automated Testing in Golang
package librarian
import (
"time"
)
const (
FINE_DAY = 15
FINE_MONTH = 500
FINE_YEAR = 10000
@maderaka
maderaka / librarian.go
Last active October 1, 2015 04:51
A solution for fixing a librarian's problem (source of problem : https://www.hackerrank.com/challenges/library-fine)
package main
import "fmt"
const(
FINE_DAY = 15
FINE_MONTH = 500
FINE_YEAR_FIX = 10000
NO_FINE = 0
)
@maderaka
maderaka / Convert.java
Created September 2, 2015 07:10
Convert text file (.txt) into CSV file using Java
import java.io.*;
public class Convert {
public static void main(String[] args) {
System.out.println("Initialize ...");
Read read = new Read("soal01.txt");
Print print = new Print();
for (int i = 1; i <= 3; i++) {
try{
print.setFileName("jawaban"+i+".csv");
@maderaka
maderaka / Company.java
Created August 17, 2015 02:21
Sort an Integer
public class Company {
public static void main(String args[]) {
try{
System.out.println(Company.sort(145263));
} catch(NumberFormatException e) {
System.out.println("NumberFormatException : " + e.getMessage());
} catch(AsPositiveException e) {
System.out.println("AsPositiveException : " + e.getMessage());
}
}
@maderaka
maderaka / KpMigrationMake.php
Last active August 29, 2015 14:16
Laravel 5: Creating migrations for specific package with custom artisan command
<?php namespace App\Console\Commands;
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Illuminate\Container\Container;
class KpMigrationMake extends Command {
/**
@maderaka
maderaka / app.js
Created July 31, 2014 04:17 — forked from victorb/app.js
var myApp = angular.module('myApp', []);
myApp.directive('googleplace', function() {
return {
require: 'ngModel',
link: function(scope, element, attrs, model) {
var options = {
types: [],
componentRestrictions: {}
};