Skip to content

Instantly share code, notes, and snippets.

View appkr's full-sized avatar
🎯
Focusing

appkr appkr

🎯
Focusing
View GitHub Profile
@appkr
appkr / h2.md
Last active August 8, 2019 06:08
use h2 database in file
# config/application.yml

spring:
    application:
        name: deliverybundler
    datasource:
        type: com.zaxxer.hikari.HikariDataSource
        url: jdbc:h2:file:./build/h2db/deliverybundler;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;MULTI_THREADED=FALSE
 name:
@appkr
appkr / setup.md
Last active August 7, 2019 10:03
Spring Gradle Project Setup

See the images

From IDEA 2019.2 version on, the third image has been chnaged to the following

@appkr
appkr / default.conf
Created June 10, 2019 16:12
Apache configuration
# Ubuntu 18.04
# etc/apache2/sites-available/default.conf
# a2ensite default
<VirtualHost *:80>
ServerName localhost
DocumentRoot /var/www/html/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log common
@appkr
appkr / auto_prune_old_database_records_with_mysql_event.md
Created May 31, 2019 08:23
Auto prune old database records with MySQL event
CREATE EVENT AutoDeleteOldNotifications
ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 DAY 
ON COMPLETION PRESERVE
DO 
DELETE LOW_PRIORITY FROM databaseName.tableName WHERE datetime < DATE_SUB(NOW(), INTERVAL 30 DAY)

source: https://stackoverflow.com/a/13009906

@appkr
appkr / guzzle_req_res_middleware.php
Last active July 19, 2023 14:15
Guzzle RequestResponseLog Middleware Example
<?php
namespace App\Providers;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Middleware;
use GuzzleHttp\Promise\PromiseInterface;
use Illuminate\Contracts\Foundation\Application;
@appkr
appkr / how_to_run_phpunit_in_intellij_or_phpstorm.md
Last active May 13, 2019 22:58
How to run phpunit in intellij or phpstorm

Set phpunit

Run test

Run with coverage

@appkr
appkr / how_to_use_hamcrest_matcher_with_phpunit.md
Created May 5, 2019 18:26
How to use Hamcrest Matcher with PHPUnit

1 Set up

<?php // tests/HamcrestTestCase.php

namespace Tests;

use Hamcrest\MatcherAssert;
use Hamcrest\Util;
@appkr
appkr / how_to_install_xdebug_for_php7.1.md
Last active May 28, 2019 15:22
How to use Xdebug Debugger for a PHP CLI project(eg. PHPUnit)

1 Install PHP 7.1

$ brew instal php@7.1
$ php -v
# PHP 7.1.29 (cli) (built: May 21 2019 20:05:17) ( NTS )
# Copyright (c) 1997-2018 The PHP Group
# Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
#     with Zend OPcache v7.1.29, Copyright (c) 1999-2018, by Zend Technologies
@appkr
appkr / how_to_use_xdebug_debugger_for_a_php_project_running_on_a_docker.md
Last active May 5, 2019 17:15
How to use Xdebug Debugger for a PHP project running on a docker

1 Set Xdebug in docker

Open a shell in the docker. Note that we use php and xdebug in the docker, not in the host machine.

$ docker exec -it 6b04d4c03211 bash

Set the xdebug like the following. xdebug.remote_host=host.docker.internal is IMPORTANT.

root@6b04d4c03211:/var/www/html# php --ini | grep xdebug
# /etc/php/7.0/cli/conf.d/20-xdebug.ini,
@appkr
appkr / cpp.md
Created April 28, 2019 13:25
Cpp

Dev Env

Programming

  • Note that a semicolon at the end of class definition
#include <iostream>
#include <string>

using namespace std;