Skip to content

Instantly share code, notes, and snippets.

View shootacean's full-sized avatar
🏠
Working from home

Shota Narisaka shootacean

🏠
Working from home
View GitHub Profile
@shootacean
shootacean / Program.cs
Created January 16, 2018 17:14
毎日作成するファイルを自動リネームする
using System;
using System.IO;
namespace console_sample
{
internal class Program
{
private const string TemplatePath = "../../resources/daily_yyyymmdd.txt";
private const string DestPath = "../../dest/";
@shootacean
shootacean / Main.kt
Created January 23, 2018 14:56
create daily report.
import java.io.File
import java.nio.file.Files
import java.text.DateFormat
import java.text.SimpleDateFormat
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
val TemplateFile = "DailyReport.xlsx"
val FileName = "DailyReport_"
@shootacean
shootacean / main.rs
Last active February 21, 2018 15:22
Rust 言語処理 100本ノック
// 言語処理 100本ノック http://www.cl.ecei.tohoku.ac.jp/nlp100/#ch1
fn main() {
knock_3("パトカー", "タクシー");
knock_2();
knock_1();
}
fn knock_3(s1: &str, s2: &str){
println!("{}", s1);
@shootacean
shootacean / index.html
Last active September 11, 2018 05:59
UIkit3を使ったサインインフォーム
<div class="uk-flex uk-flex-center uk-flex-middle">
<div class="uk-section-muted uk-section-small">
<div class="uk-container">
<form class="uk-form-stacked">
<div class="uk-margin">
<label class="uk-form-label">E-mail</label>
<div class="uk-inline">
<span class="uk-form-icon" uk-icon="icon: mail"></span>
<input type="email" class="uk-input"/>
</div>
@shootacean
shootacean / grep_deps.sh
Created November 10, 2018 05:01
あるキーワードを含むファイル、を使用しているファイルを検索する
# step 1
grep -rl hello ./php >> result.txt
# step 2
# edit result.txt
# step 3
grep -rlf result.txt ./target_dir
package main
import (
"bufio"
"os"
"strconv"
)
var sc = bufio.NewScanner(os.Stdin)
// ファイルをダウンロードさせる
func forceDownloadFile(c *gin.Context, fileName string) {
targetPath := filepath.Join(downloadsPath, fileName)
if !strings.HasPrefix(filepath.Clean(targetPath), downloadsPath) {
c.String(403, "Look like you attacking me")
return
}
c.Header("Content-Description", "File Transfer")
c.Header("Content-Transfer-Encoding", "binary")
c.Header("Content-Disposition", "attachment; filename="+fileName)
@shootacean
shootacean / main.go
Last active February 14, 2019 04:40
Golangでデータベースに接続する
package main
import (
"database/sql"
)
func main() {
// open database
db, err := sql.Open("mysql", "root:root@tcp(127.0.0.1:3306)/my_database")
if err != nil {
func gcd(a, b int) int {
if b == 0 {
return a
}
return gcd(b, a%b)
}
// sliceの重複要素を削除
func slimSlice(slice []int) []int {
m := make(map[int]int)
slim := make([]int, 0)
for _, element := range slice {
if _, ok := m[element]; !ok {
m[element] = 0
slim = append(slim, element)
}
}