Skip to content

Instantly share code, notes, and snippets.

View gokusenz's full-sized avatar
🎯
Focusing

Nattawut Ruangvivattanaroj gokusenz

🎯
Focusing
View GitHub Profile
@gokusenz
gokusenz / Makefile
Created February 17, 2018 14:02
Sample Makefile
SERVICE=sample
COMMIT_SHA=$(shell git rev-parse HEAD)
PWD:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
default:
# `make prod` - build and deploy to prod
# `make stag` - build and deploy to stag
prod:
NAMESPACE=production make deploy
@gokusenz
gokusenz / gist:fb1d051dda326573a8f84f6ec5e4447a
Created February 18, 2018 06:14
OSX: Install PHP Mcrypt
brew update
brew upgrade
brew tap josegonzalez/homebrew-php
brew install php70-mcrypt
php --version // To Test your php
sudo composer update
$code = '100005';
$bin = hex2bin(str_repeat('0', 8 - strlen($code)) . $code);
$emoticon = mb_convert_encoding($bin, 'UTF-8', 'UTF-32BE');
@gokusenz
gokusenz / vscode config
Created March 16, 2018 03:54
vscode config
// Place your settings in this file to overwrite the default settings
{
"window.zoomLevel": 0,
"workbench.statusBar.visible": true,
// "diffEditor.ignoreTrimWhitespace": false,
"editor.fontSize": 13,
"window.nativeTabs": false,
"editor.renderIndentGuides": true,
"workbench.activityBar.visible": false,
"workbench.iconTheme": "vs-seti",
@gokusenz
gokusenz / jsonToFile.js
Created March 19, 2018 11:17
JSON to files
var fs = require('fs')
var obj
fs.readFile('test.json', 'utf8', function (err, data) {
if (err) throw err
obj = JSON.parse(data)
var keys = Object.keys(obj)
for (var i = 0; i < keys.length; i++) {
if(obj[keys[i]] == "[object Object]") {
obj[keys[i]] = JSON.stringify(obj[keys[i]], null, 4)
}
#!/bin/bash
IFS=$'\n\t'
set -eou pipefail
if [[ "$#" -ne 2 || "${1}" == '-h' || "${1}" == '--help' ]]; then
cat >&2 <<"EOF"
gcrgc.sh cleans up tagged or untagged images pushed before specified date
for a given repository (an image name without a tag/digest).
@gokusenz
gokusenz / github.groovy
Created April 19, 2018 19:04
Git and Jenkins using webhooks
node {
def msg
stage ('read post var from webhook') {
echo 'Hello World webhook'
echo 'action :' + action
def repository = readJSON text: repository;
def pull_request = readJSON text: pull_request;
def title = pull_request.title.replaceAll(" ","-")
if (action == "submitted") {
msg = 'New pull request on ' + repository.name + '%0ATitle: ' + title + '%0ABranch: ' + pull_request.head.ref + ' -> ' + pull_request.base.ref + '%0ABy: ' + pull_request.user.login + '%0A%0A' + pull_request.html_url
stage('Git Push To Origin') {
steps {
withCredentials([usernamePassword(credentialsId: your_credentials, passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) {
sh "git tag ${your_tag}"
sh "git push https://${GIT_USERNAME}:${GIT_PASSWORD}@${repository} ${your_tag}"
}
@gokusenz
gokusenz / .netrc
Created May 16, 2018 03:48
auth github
machine github.com
login [YOUR_GITHUB_USERNAME]
password [YOUR_GITHUB_TOKEN]
@gokusenz
gokusenz / Dockerfile
Created May 16, 2018 13:48
docker golang for build
FROM golang:1.10-alpine
RUN apk add --no-cache curl git
RUN curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
WORKDIR /go/src