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
import (
"bufio"
"fmt"
"math/rand"
"os"
"strconv"
"strings"
"time"
async function cacheDo() {
return await cache.do(key, async () => {
return await db.findOne();
});
}
(async () => {
let missyou = await cacheDo();
})()
@wingyplus
wingyplus / hangman.exs
Created September 22, 2018 11:33
Hangman implementation in Elixir
defmodule Hangman do
def hangman(secret_word, inputs) do
MapSet.subset?(MapSet.new(String.graphemes(secret_word)), MapSet.new(inputs))
end
end
package hangman
import "strings"
func Hangman(word string, inputs []string) bool {
for _, input := range inputs {
if word = strings.Replace(word, input, "", -1); word == "" {
return true
}
}
$ git diff
diff --git a/check.go b/check.go
index 6a25548..485f92e 100644
--- a/check.go
+++ b/check.go
@@ -2,6 +2,10 @@ package main
func check(input string) bool {
for i := 0; i < len(input); i++ {
+ if input[len(input)-1] == '{' {
@wingyplus
wingyplus / upload.go
Created June 22, 2017 16:35
How to upload file with go-json-rest
package main
import (
"io"
"log"
"net/http"
"os"
"github.com/ant0ine/go-json-rest/rest"
)
#!/bin/sh
docker run -d -p 4444:4444 --name selenium-hub selenium/hub:3.4.0-dysprosium
docker run -d --link selenium-hub:hub selenium/node-chrome:3.4.0-dysprosium
docker run -d --link selenium-hub:hub selenium/node-firefox:3.4.0-dysprosium
protocol A {
func doSomething() -> String
}
// AbstractA
extension A {
func doSomething() -> String {
return "Hello from AbstractA"
}
}
#include <stdio.h>
int count_vowe(const char *text) {
const char *ch = text;
int count = 0;
for (; *ch != '\0'; ch++) {
switch (*ch) {
case 'a':
case 'e':
@wingyplus
wingyplus / todomvc.robot
Created November 23, 2016 17:15
TodoMVC with Robot Framework
*** Settings ***
Library Selenium2Library
*** Test Cases ***
เพิ่ม Todo เข้าไปใน List
[Setup] Open Browser http://todomvc.com/examples/polymer/index.html browser=gc
พิมพ์ Learn AngularJs
กด Enter
ผู้ใช้จะเห็น Learn AngularJs อยู่ใน List
[Teardown] Close Browser