Skip to content

Instantly share code, notes, and snippets.

View wingyplus's full-sized avatar
😶‍🌫️
Burned out

Thanabodee Charoenpiriyakij wingyplus

😶‍🌫️
Burned out
View GitHub Profile
package main
type A struct {
}
func (a A) Hello() string {
return "hello"
}
type B struct {
package main
import (
"fmt"
"io/ioutil"
"net"
)
func main() {
listener, err := net.Listen("tcp", ":8000")
@wingyplus
wingyplus / regex_test.go
Last active August 29, 2015 14:00
Sample Regexp usage
package regex_test
import (
"regexp"
"testing"
)
func TestMatchingIntegerURLString(t *testing.T) {
re := regexp.MustCompile(`/view/(\d)`)
if re.FindStringSubmatch("/view/1")[1] != "1" {
func solution(n int) int {
var factorial = func(begin int, end int, c chan int) {
var sum int = 1
for i := begin; i <= end; i++ {
sum *= i
}
c <- sum
}
var c = make(chan int)
package consensus
import "fmt"
type Journal struct {}
func (journal Journal) Write(msg string) {
}
func GetConsensus(journal Journal) boolean {
@wingyplus
wingyplus / sample_json.php
Last active August 29, 2015 14:01
Sample json RESTful request
<?php
header('Content-Type', 'application/json');
echo json_encode([1,2,3]);
<?php
$list = array();
array_push($list, $item);
@wingyplus
wingyplus / rewrite.sh
Last active August 29, 2015 14:01
Go Format rewrite rule
gofmt -r 'a[b:len(a)] -> a[b:]' h.go
import org.junit.Assert;
public class FizzBuzzTest {
public void testFizzBuzShouldReturn_1_WhenInput_1() {
FizzBuzz fizzBuzz = new FizzBuzz();
Assert.assertEquals("1", fizzBuzz.doFizzBuzz(1));
}
public void testFizzBuzShouldReturn_2_WhenInput_2() {
package main
import "fmt"
func sender(to chan string, done chan bool) {
for {
select {
case t := <-to:
fmt.Println(t)
case <-done: