Skip to content

Instantly share code, notes, and snippets.

View lesstif's full-sized avatar

KwangSeob Jeong lesstif

View GitHub Profile
@lesstif
lesstif / TemperatureTest.php
Created August 10, 2020 04:47
PHP Mockery simple example TestCase.
<?php
namespace Tests\Feature;
use App\Temperature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Mockery;
use Tests\TestCase;
@lesstif
lesstif / put_sent_mail_into_the_mailbox_using_imap.php
Last active August 4, 2020 04:56
sending email with PHP Swiftmailer and put into the SentBox using imap protocol.
<?php
$message = (new Swift_Message('Wonderful Subject'))
->setFrom(['noreply@example.org' => 'John Doe'])
->setReplyTo('reply@example.org', 'Reply To')
->setTo(['receiver@domain.org', 'other@domain.org' => 'A name'])
->setBody('mail body', 'text/html')
;
// Swiftmail 는 sent box 에 남기지 않으므로 아래 꽁수로 imap_처리
// https://stackoverflow.com/questions/19497557/add-mail-to-send-folder-with-swiftmailer
@lesstif
lesstif / swift_mailer_example.php
Last active August 4, 2020 01:18
Send email using PHP Swift mailer
<?php
require_once '/path/to/vendor/autoload.php';
$host = env('MAIL_HOST');
$user = env('MAIL_USERNAME');
$port = env('MAIL_PORT');
$password = env('MAIL_PASSWORD');
$security = env('MAIL_ENCRYPTION');
@lesstif
lesstif / ln-gnu-utils.sh
Last active August 13, 2020 11:28
symbolic link gnu utils to system command for convenience. for example /usr/local/bin/ggrep symlink to /usr/local/bin/grep
#!/usr/bin/env bash
if ! command -v "gls" &> /dev/null; then
echo "GNU coreutils not installed!";
exit 1;
fi
if [ "$EUID" -ne 0 ];then
echo "Please run as root"
exit
@lesstif
lesstif / validation_biz_number.php
Last active May 20, 2022 09:56
사업자 등록 번호 검증 php code
<?php
/**
* 사업자 번호 유효성 검증
*
* @param string $bizNumberParam 검증할 사업자 번호
*
* @return bool
*
* @see https://www.lesstif.com/pages/viewpage.action?pageId=93126973 사업자 번호 검증 규칙
@lesstif
lesstif / confluence-nginx-vhost.conf
Last active July 2, 2020 05:11
specific domain(ex: example.com)'s nginx virtual host configuration for confluence server.
## confluence vhost
server {
listen 80;
server_name example.com default_server;
root /var/www/www.example.com;
error_page 502 = /http_502.html;
return 301 https://www.example.com$request_uri;
}
@lesstif
lesstif / HMacTest.java
Last active February 27, 2024 07:10
HMAC SHA256 example java code
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
public class HMacTest {
public static final String ALGORITHM = "HmacSHA256";
public static String calculateHMac(String key, String data) throws Exception {
Mac sha256_HMAC = Mac.getInstance(ALGORITHM);
@lesstif
lesstif / HelloWorld.php
Last active June 4, 2020 08:52
phpstan test class
<?php declare(strict_types = 1);
/**
* phpstan sample
*
* Class HelloWorld
* @package App
*/
class HelloWorld
{
@lesstif
lesstif / my.ini
Last active July 1, 2020 04:59
MySQL ini config file for laragon
# Other default tuning values
# MySQL Server Instance Configuration File
# ----------------------------------------------------------------------
# Generated by the MySQL Server Instance Configuration Wizard
#
#
# Installation Instructions
# ----------------------------------------------------------------------
#
# On Linux you can copy this file to /etc/my.cnf to set global options,
@lesstif
lesstif / php.ini
Created May 9, 2020 01:45
php ini for windows devel environment
[PHP]
;;;;;;;;;;;;;;;;;;;
; About php.ini ;
;;;;;;;;;;;;;;;;;;;
; PHP's initialization file, generally called php.ini, is responsible for
; configuring many of the aspects of PHP's behavior.
; PHP attempts to find and load this configuration from a number of locations.
; The following is a summary of its search order: