Skip to content

Instantly share code, notes, and snippets.

@naosim
naosim / table2md.html
Created June 5, 2018 21:30
htmlのテーブルからmarkdownを作る
<!DOCTYPE html>
<div id="div20180606">
<table border="1">
<tr><th>名前</th><th>備考</th>
<tr><td>ほげ</td><td>改行<br>テスト</td></tr>
<tr><td>ふー</td><td>改行<br>テスト</td></tr>
</table>
</div>
<script>
@naosim
naosim / vo_string.js
Created May 13, 2018 07:47
バリューオブジェクト生成 (String)
const template = `
package __PACKAGE__;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
@AllArgsConstructor
@EqualsAndHashCode
public class __CLASS__ {
private final String value;
@naosim
naosim / lock.php
Last active April 30, 2018 22:16
phpでlockする
<?php
function lock($lockFileName, $fuc) {
if(!file_exists($lockFileName)) {
file_put_contents($lockFileName, '');
}
$lock_fp = fopen($lockFileName ,"w");
flock($lock_fp, LOCK_EX);
try {
return $fuc();
@naosim
naosim / .htaccess
Created March 31, 2018 20:49
PHP用htaccess設定
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /app/silexsample/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /app/silexsample/index.php [L]
</IfModule>
@naosim
naosim / DisplayOutMonitor.js
Created March 31, 2018 08:35
Elementが画面外に出たことを検知する
class DisplayOutMonitor {
constructor(option) {
option = option || {}
this.document = option.document || document
this.interval = option.interval || 100
}
/**
* @param {string}
* @param {(isOut:boolean)=>void}
@naosim
naosim / DocumentTopPosition.js
Created March 31, 2018 02:18
エレメントの位置を取得する
class DocumentTopPosition {
constructor(doc, win) {
this.document = doc || document;
this.window = win || window;
}
/**
* @returns {number} top position
*/
get(element) {
@naosim
naosim / myJarTask.gradle
Last active March 21, 2018 09:10
デフォルトのjarを自作のjarに差し替える
// デフォルトのjarをアーティファクトから削除
configurations.archives.artifacts.with { archives ->
def jarArtifact
archives.each {
if (it.file =~ 'jar') {
jarArtifact = it
}
}
println "JAR to delete: ${jarArtifact}"
remove(jarArtifact)
@naosim
naosim / anpan.svg
Last active December 29, 2017 15:04
アンパン
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@naosim
naosim / SheetTable.js
Last active December 20, 2017 01:33
GoogleSpreadSheetをテーブルっぽく使う
function SheetTable(sheetName) {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName);
var headers = sheet
.getDataRange()
.getValues()[0];
var headersIndexMap = headers.reduce(function(memo, key, i){
memo[key] = i;
return memo;
}, {});
@naosim
naosim / getListFromSheet.js
Last active November 5, 2017 06:22
【GAS】spreadsheetのテーブルをオブジェクトに変換する
function getListFromSheet(sheetName) {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var sheet = spreadsheet.getSheetByName(sheetName);
var range = sheet.getDataRange();
var map = range.getValues();
var header = map[0];
var ary = [];
for(var row = 1; row < map.length; row++) {
var obj = {};