Skip to content

Instantly share code, notes, and snippets.

@Sankame
Sankame / next.config.js
Created May 21, 2022 10:44
Next.js設定ファイルの値変更
module.exports = {
reactStrictMode: true,
webpackDevMiddleware: config => {
config.watchOptions = {
//小さな値にすると、ポーリングの頻度が上がるので、重くなるっぽい。
//poll: 800,
poll: 5000,
aggregateTimeout: 300,
}
@Sankame
Sankame / SampleTest.php
Created May 6, 2020 06:45
Sample code using Laravel, PHPUnit and Mockery
/**
* @runInSeparateProcess
* @preserveGlobalState disabled
*/
public function testEditWhenRecordNotFound()
{
$this->mock = M::mock('alias:App\Contact')->makePartial();
$this->mock->shouldReceive('find')->once()->with(self::ID)->andReturnUsing(function(){
return null;
@Sankame
Sankame / SampleTest.php
Last active May 6, 2020 06:44
Sample code using Laravel, PHPUnit and Mockery
/**
* @runInSeparateProcess
* @preserveGlobalState disabled
*/
public function testEditNormal()
{
$this->mock = M::mock('alias:App\Contact')->makePartial();
$this->mock->shouldReceive('find')->once()->with(self::ID)->andReturnUsing(function(){
$contacts = (object)array(
@Sankame
Sankame / Sample.php
Created May 6, 2020 06:21
Sample code using Laravel, PHPUnit and Mockery
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
$contact = Contact::find($id);
@Sankame
Sankame / KanaSample.html
Last active September 22, 2019 15:31
A sample code to change the half-sized kana to full-sized one in Japanese
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
</head>
<body>
<script>
function Kana(){
File file = ...
// (1)
// intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
// (2)
Uri uri = FileProvider.getUriForFile(
【アクティビティ名】.this
,getApplicationContext().getPackageName() + ".provider"
, file);
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="external_files" path="."/>
</paths>
<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
<application ...>
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
@Sankame
Sankame / HttpPostSuccess.java
Last active May 9, 2018 13:21
サーバーからのレスポンスが多くてもOK
public JSONObject post(String urlString) throws Exception{
URL url = new URL(urlString);
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
con.setConnectTimeout(Const.HTTP_CONNECT_TIMEOUT);
con.setReadTimeout(Const.HTTP_READ_TIMEOUT);
con.setUseCaches(false);
con.setDoInput(true);
con.setDoOutput(true);
con.setChunkedStreamingMode(0);
@Sankame
Sankame / HttpPostFailure.java
Last active May 9, 2018 13:17
サーバーからのレスポンスデータが多いとエラーになる
public JSONObject post(String urlString) throws Exception{
URL url = new URL(urlString);
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
con.setConnectTimeout(Const.HTTP_CONNECT_TIMEOUT);
con.setReadTimeout(Const.HTTP_READ_TIMEOUT);
con.setUseCaches(false);
con.setDoInput(true);
con.setDoOutput(true);
con.setChunkedStreamingMode(0);