Skip to content

Instantly share code, notes, and snippets.

View k2levin's full-sized avatar
:octocat:
Coding..

Kevin Khew k2levin

:octocat:
Coding..
View GitHub Profile
@k2levin
k2levin / print_strings.php
Last active January 13, 2017 08:47
print bunch of strings
<?php
$chars = ['A', 'B', 'C'];
foreach ($chars as $h => $char) {
foreach ($chars as $i => $char) {
foreach ($chars as $j => $char) {
foreach ($chars as $k => $char) {
foreach ($chars as $l => $char) {
echo $chars[$h].$chars[$i].$chars[$j].$chars[$k].$chars[$l]."\n";
@k2levin
k2levin / docker-compose-jenkins.yml
Last active July 13, 2017 07:24
Docker compose for Jenkins
version: "3"
services:
db:
image: mysql:5.7
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
- MYSQL_DATABASE=laravel
networks:
- db-network
redis:
@k2levin
k2levin / gist:4de386d22ad645fa2b4fd53293b9cf38
Last active July 13, 2017 07:19
Jenkins + Docker Installation
Jenkins + Docker Installation (Ubuntu)
======================================
(Updated at JUNE2017)
https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-ubuntu-16-04
https://pkg.jenkins.io/debian-stable/
https://docs.docker.com/engine/installation/linux/ubuntu/#prerequisites
https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-16-04
https://plugins.jenkins.io/embeddable-build-status
@k2levin
k2levin / Jenkinsfile
Created November 16, 2018 10:08
Jenkinsfile sample
#!groovy
node {
timestamps {
try {
stage("before install") {
checkout scm
def docker_job = "$env.JOB_NAME".replace('/', '_')
sh "docker stack deploy -c docker-compose.yml $docker_job"
sleep time: 30, unit: 'SECONDS'
@k2levin
k2levin / config.yaml
Created March 27, 2021 15:08
snippet using kind for k8s
apiVersion: kind.x-k8s.io/v1alpha4
kind: Cluster
nodes:
- role: control-plane
- role: worker
extraPortMappings:
- containerPort: 30080
hostPort: 30080
listenAddress: "0.0.0.0"
protocol: tcp
@k2levin
k2levin / EloquentModelCaching.php
Created September 21, 2021 06:26
EloquentModelCaching
<?php
namespace App\Models\Misc;
use Illuminate\Database\Eloquent\Model;
trait EloquentModelCaching
{
/**
* Return cache for eloquent model object
@k2levin
k2levin / knote
Last active December 21, 2023 06:24
knote
curl -X OPTIONS 'https://test.com/index.html' -H "Origin: https://www.google.com" -H "Access-Control-Request-Method: GET" -v
sudo chmod -R u=rwX,go=rX ./app
CREATE USER 'kevinkhew'@'%' IDENTIFIED BY 'KevinKhew';
GRANT ALL PRIVILEGES ON dbname.* TO 'kevinkhew'@'%';
FLUSH PRIVILEGES;
SHOW GLOBAL STATUS