Skip to content

Instantly share code, notes, and snippets.

@yano3nora
yano3nora / charles.md
Last active July 1, 2017 06:18
[dev: Charles with Vagrant] Actual terminal test in VM via HTTP proxy. #vagrant #charles #test #dev

Overview

iPhone, iPad, Android など [ios] [android] の実機テストについて、 Vagrant で建てたローカル開発環境上のWEBサーバにアクセスして行いたいよ。

Premise

実機テストしたい端末 (iPad, iPhone, Android) がローカル開発環境のあるPCと同一の Wi-Fi 上でネットワーク接続されている必要あり。

TIPS

  • 有料につき30分で自動終了
  • なんかおかしくなった→再起動
  • iOS Chromeでつながらない→仕様です
@yano3nora
yano3nora / programming_symbols.md
Last active July 1, 2017 06:18
[dev: Programming symbols] What should call out the name of the programming symbols? #dev
( )	parenthesis (口語: paren)
[ ]	bracket, square bracket ([:open bracket, ]:close bracket)
{ }	braces, curly bracket
< >	angle bracket (<: less than, >:greater than)
<- ->	arrow
<= =>	fat arrow, double allow
#	pound, hash, number sign
-	minus,hyphen (正確には違うがdash)
‘	single quote, apostrophe
@yano3nora
yano3nora / js-date.md
Last active August 25, 2022 18:31
[js: Date] Date Object on JavaScript. #js

Overview

Date - developer.mozilla.org

JS の Date オブジェクト死ぬほど使いづらいので、luxon など原則ライブラリで触ったほうがいい。どうしてもライブラリ使えないケースでは注意して取り扱いたい。

toISOString 形式で timezone 考慮したい

new Date(
  new Date().getTime() -
 new Date().getTimezoneOffset() * (60 * 1000) // 分で UTC との offset を取れる
/**
* isTypeOf
* @param string type (String, Number, Boolean, Date, Error, Array, Function, RegExp, Object)
* @param mix data
*/
function isTypeOf(type, obj) {
var clas = Object.prototype.toString.call(obj).slice(8, -1);
return obj !== undefined && obj !== null && clas === type;
}
@yano3nora
yano3nora / cheapFixGarbledChars.php
Created July 1, 2017 04:31
[php: Cheap fix of garbled chars] Attension on old code. #php
// let's change default charset to utf8mb4, in next time...
function cheapFixGarbledChars($str) {
$step_1 = str_replace('&',"\\",$str);
$step_2 = str_replace('#','',$step_1);
$step_3 = str_replace('x','',$step_2);
$step_4 = str_replace(';','',$step_3);
return $step_4;
}
@yano3nora
yano3nora / xcopy.md
Last active July 1, 2017 04:38
[win: xcopy example] Attention on old code. #win

Purpose

標準機能だけで社内のWinサーバのHDD中身まるっとコピーして毎日夜中に外付けHDDとかにバックアップを取りたい。

Process of fool

  1. 新規ファイルを[ .bat ] 拡張子で作成して編集。

  2. XCOPYと言うコマンドを使って、ファイルをバックアップバッチシステムを作る

$ xcopy “バックアップ元” “バックアップ先” /D /S /E /H /C /Y /R
@yano3nora
yano3nora / spreadsheets.md
Last active September 14, 2022 23:22
[gas: Google Spreadsheets] Google Spreadsheets note. #gas #js

Google オフラインドキュメント Extension

https://chrome.google.com/webstore/detail/google-docs-offline/ghbmnnjooekpmoecnnnilnnbdlolhkhi

  • オフラインでも spreadsheet 開けるようにするやつ
  • 異なる sheet 間で「コピー => 値のみ貼り付け」とかの追加機能拡張もある

一括結合解除

なんか普通にだとできにゃい。多分「結合を解除」を選択できるようにしてから範囲選択 ... ってのが必要。GAS はいらない。

@yano3nora
yano3nora / long_time_process.php
Created July 1, 2017 04:48
[php: process of over execute time] Attention on old code. #php #js
<?php
$step_max = 999;// 1回の処理回数
// foreachなら (count($array)-1) を上に
// ループ処理の外側は全部この中に...
?>
<html>
<head>
<script language="JavaScript"><!--
function PageJump(){
if ('function' === typeof window.PageJump2){
@yano3nora
yano3nora / imgCompress.php
Created July 1, 2017 04:50
[php: imgCompress()] Attention on old code. #php
<?php
// 1. ある特定のディレクトリを参照し、中にいくつディレクトリがあるか数える
// 2. ディレクトリがあるだけ中の画像ファイル(jpg)を参照して、ファイルサイズが $size を超えるようなら圧縮処理をかける
set_time_limit(0);
// メイン関数
function imgCompress($src,$size,$comp) {
$fs = @filesize($src);
$jpg = @imagecreatefromjpeg($src);
while($fs > $size && $comp > 0) {
@yano3nora
yano3nora / imgResizer.php
Created July 1, 2017 04:53
[php: imgResizer()] Attention on old code. #php
<?php
/**
## なにこれ
生画像にアクセスしつつサムネイルを自動的に作って的な感じだと思う多分。多用すると遅くなるので注意。
## 使い方
- html側でこんな風に呼び出す <img src="imgResizer.php?url=画像ファイルパス&width=***">
- 画像の圧縮率を以下で設定できる