Skip to content

Instantly share code, notes, and snippets.

php.ini
xdebugの設定サンプル
[xdebug]
xdebug.remote_enable=1
xdebug.overload_var_dump=1
xdebug.var_display_max_data=1024
xdebug.var_display_max_depth=5
xdebug.remote_enable=1
xdebug.remote_host=localhost
@shmurakami
shmurakami / get_gzip_contents.php
Created August 19, 2015 03:42
Get Contents of remote gzip file with PHP
<?php
$context = stream_context_create([
'http' => ['header' => 'Accept-Encoding: gzip'],
]);
$fp = fopen($outputUrl, 'rb', false, $context);
$prediction = gzdecode(stream_get_contents($fp));
fclose($fp);
namespace :rsync do
# stage is reseting til remote origin
after :stage, :foobar do
system "cd #{fetch(:rsync_src)} && touch foobar"
end
end
<!DOCTYPE html>
<html lang="jp">
<head>
<meta charset="UTF-8">
<title>comment</title>
<style type="text/css">
* {
margin:0;
padding: 0;
}
{
"swagger": "2.0",
"info": {
"title": "ReFUEL4 API",
"version": "0.0.1"
},
"paths": {
"/advertisers/{advertiserId}/adsets": {
"get": {
"summary": "get Facebook AdSet list",
@shmurakami
shmurakami / RefreshUnitTestDB.php
Last active March 4, 2018 12:45
Generate sqlite database for Laravel/Lumen Console command
<?php
use DB;
use Illuminate\Console\Command;
class RefreshUnitTestDB extends Command
{
protected $signature = 'test:refresh-unit-test-db';
protected $description = 'Refresh local sqlitedb for API test';
<?php
// snippet
// N+1
private function bulkFetch($ids)
{
$in = array_fill(0, count($ids), '?');
$sth = $this->dbh->prepare('SELECT * FROM `users` WHERE `id` in (' . implode(',', $in) . ')');
$r = $sth->execute($ids);
<?php
class Sample
{
private $fp;
public function __construct($local_filepath)
{
$this->fp = fopen($local_filepath, 'w');
if ($this->fp === false) {
throw new \Exception(__METHOD__ . " filepath: $local_filepath への書き込みに失敗しました");
@shmurakami
shmurakami / todo.proto
Created August 14, 2020 12:33
example ToDo service proto
syntax = "proto3";
option java_package = "com.example.todo";
service TodoService {
rpc list (TodoListRequest) returns (TodoListReply);
rpc get (TodoRequest) returns (TodoReply);
rpc create (TodoCreateRequest) returns (TodoCreateReply);
rpc update (TodoUpdateRequest) returns (TodoUpdateReply);
rpc done (TodoDoneRequest) returns (TodoDoneReply);
@shmurakami
shmurakami / go_gc.go
Created March 3, 2023 06:49
golang run gc sample
package main
import (
"fmt"
"net/http"
"runtime"
"strconv"
"strings"
"time"
)