Skip to content

Instantly share code, notes, and snippets.

View DQNEO's full-sized avatar

Daisuke Kashiwagi DQNEO

View GitHub Profile
@DQNEO
DQNEO / main.go
Created January 21, 2021 10:12
method call in go
package main
type T int
type MV interface {
mv(int)
}
type MP interface {
mp(int)
@DQNEO
DQNEO / GoQuiz.md
Last active November 18, 2020 03:52
Go quiz 解説
@DQNEO
DQNEO / itoa.go
Last active September 8, 2020 07:37
Itoa from scratch
package main
func Itoa(ival int) string {
var buf []byte
var r []byte
var next int
var right int
for {
if ival < 0 {
@DQNEO
DQNEO / img.go
Created February 24, 2020 11:43
dot image generator
package main
import (
"fmt"
"image"
"image/color"
"image/png"
"os"
)
@DQNEO
DQNEO / counter_vanila.html
Last active February 21, 2020 05:34
Reinvention of Redux
<!DOCTYPE html>
<!-- This is a port of "counter-vanilla" example without depending on Redux. -->
<!-- Original is https://github.com/reduxjs/redux/blob/v4.0.5/examples/counter-vanilla/index.html -->
<html>
<head>
<meta charset="UTF-8">
<title>Redux-like Counter</title>
</head>
<body>
<h1>Redux-like Counter</h1>
@DQNEO
DQNEO / float.php
Created November 21, 2019 09:04
PHP floating number
<?php
$my_json2 = '{"tax":2.03}';
$decoded = json_decode($my_json2, true);
echo $decoded['tax'] . PHP_EOL;
$tax_in_cents = round($decoded['tax'] * 100);
$response = ['tax_cents' => intval($tax_in_cents)];
echo json_encode($response) . PHP_EOL; // => 203
@DQNEO
DQNEO / RocketLauncher.java
Last active October 29, 2019 08:10
Unit test for Rocket Launcher
public class RocketLauncher {
public boolean launch() {
Rocket rocket = new Rocket();
rocket.addFuel(100);
rocket.unlock();
boolean result = rocket.launch();
return result;
}
}
@DQNEO
DQNEO / minigo_hello_world.go
Last active May 24, 2019 04:19
a Go compiler which compiles hello world on the Go Playground
-- 0debugbuiltin.go --
package main
// These functions are builtin in the 2gen compiler.
func dumpInterface(x interface{}) {
}
func assertInterface(x interface{}) {
@DQNEO
DQNEO / replace.sh
Last active October 25, 2021 02:33
add void to setUp and tearDown to PHP test code
#!/bin/bash
#
# a tool to apply return type declarations to "setUp" and "tearDown" for PHPUnit7
# list target files by using GNU grep
grep --files-with-matches -i -w -e setup -e teardown -r tests > /tmp/files
# do substitution
cat /tmp/files | xargs perl -pi -e 's/setUp\(\)$/setUp(): void/g'
cat /tmp/files | xargs perl -pi -e 's/tearDown\(\)$/tearDown(): void/g'
@DQNEO
DQNEO / http_client.go
Created November 16, 2018 05:15
Go httpclient sample code
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
)
func main() {