Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

appkr appkr

🎯
Focusing
View GitHub Profile
@appkr
appkr / h2.md
Last active Aug 8, 2019
use h2 database in file
View h2.md
# 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 Aug 7, 2019
Spring Gradle Project Setup
View setup.md

See the images

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

@appkr
appkr / default.conf
Created Jun 10, 2019
Apache configuration
View default.conf
# 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
Auto prune old database records with MySQL event
View auto_prune_old_database_records_with_mysql_event.md
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 May 19, 2019
Guzzle RequestResponseLog Middleware Example
View guzzle_req_res_middleware.php
<?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
How to run phpunit in intellij or phpstorm
View how_to_run_phpunit_in_intellij_or_phpstorm.md

Set phpunit

Run test

Run with coverage

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

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
How to use Xdebug Debugger for a PHP CLI project(eg. PHPUnit)
View how_to_install_xdebug_for_php7.1.md

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
How to use Xdebug Debugger for a PHP project running on a docker
View how_to_use_xdebug_debugger_for_a_php_project_running_on_a_docker.md

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,
View cpp.md

Dev Env

Programming

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

using namespace std;