Skip to content

Instantly share code, notes, and snippets.

View ogaty's full-sized avatar

Yuji Ogata ogaty

View GitHub Profile
@ogaty
ogaty / show-all-256-colors.py
Created August 6, 2018 10:37 — forked from mgedmin/show-all-256-colors.py
Script to show all 256 colors supported by xterms
#!/usr/bin/python
"""Print a swatch using all 256 colors of 256-color-capable terminals."""
__author__ = "Marius Gedminas <marius@gedmin.as>"
__url__ = "https://gist.github.com/mgedmin/2762225"
__version__ = '2.0'
def hrun(start, width, padding=0):
@ogaty
ogaty / ajax.js
Last active June 5, 2019 11:13
template
$.ajax({
url: '/api/uploads/upload',
type: 'POST'
}).done({
}).fail({
}).always({
});
@ogaty
ogaty / eloquent.md
Last active December 9, 2018 03:32
laravel

紛らわしい2つのget

Laravelには2つのgetがある。
vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.phpと
vendor/laravel/framework/src/Illuminate/Support/Collection.php

$p = Post::where('id', '<', 3)->get();

これはCollectionの配列になる

@ogaty
ogaty / docker.md
Last active August 5, 2019 13:16
docker

よく使う

docker run -itd -p 8080:80 --name astro-maki astro-maki
docker exec -it astro-maki /bin/bash
docker stop $(docker ps -q)
docker rm $(docker ps -aq)

流れ

チートシート参考に(後で貼る)

@ogaty
ogaty / aws.md
Last active May 22, 2024 04:42
aws 統括 dynamo s3

configファイルを別の場所にした場合

export AWS_CONFIG_FILE=/config/.aws/config
export AWS_SHARED_CREDENTIALS_FILE=/config/.aws/credentials

regionとかは
--profile banana
--region=dummy
--endpoint-url=https://xxx
で書き換えられる

@ogaty
ogaty / alldirectories.php
Created September 8, 2018 04:10
特定ディレクトリ配下をrecursiveで探索 php directory
<?php
$path = 'node_modules';
function getFileList($dir) {
$iterator = new RecursiveDirectoryIterator($dir);
$iterator = new RecursiveIteratorIterator($iterator);
$list = array();
foreach ($iterator as $fileinfo) { // $fileinfoはSplFiIeInfoオブジェクト
if ($fileinfo->isFile() && preg_match('/\.js$/', $fileinfo->getPathname())) {
$list[] = $fileinfo->getPathname();
@ogaty
ogaty / javascript.md
Last active February 19, 2020 00:21
まれによく使う javascript node.js node npm

おなじみ正規表現

/^abc/.test(val)

nodeListをnode配列に

objectList = querySelectorAll(".wrap")
[].slice.call(objectList)
@ogaty
ogaty / couch.md
Last active September 30, 2018 07:27
couch couchdb

docker

docker run -d -p 5984:5984 -v /home/tea/couchdata:/opt/couchdb/data --name my-couchdb-vol couchdb

create database

curl -X "PUT" -H "Content-type:application/json" http://127.0.0.1:5984/series
@ogaty
ogaty / show-all-256-colors.py
Created October 7, 2018 03:37
Script to show all 256 colors supported by xterms
#!/usr/bin/python
"""Print a swatch using all 256 colors of 256-color-capable terminals."""
__author__ = "Marius Gedminas <marius@gedmin.as>"
__url__ = "https://gist.github.com/mgedmin/2762225"
__version__ = '2.0'
def hrun(start, width, padding=0):
@ogaty
ogaty / bash-commands.md
Last active July 13, 2019 00:07
bash linux command

プロンプト

export PS1="xxxxxxxx"
\u ユーザー名    
\h ホスト名  
\W ディレクトリ  
\$ ユーザーは$、rootは#  
\t 時刻
\[\e[1;32m\] 色変える  
\[\e[m\] 色戻す