Skip to content

Instantly share code, notes, and snippets.

Avatar
🐢

Eunkwang Shin gracefullight

🐢
View GitHub Profile
View nginx_php_ssl_virtualhost.conf
# HTTP
server {
listen 80;
server_name example.com www.example.com;
# certbot --webroot 인증을 받기위한 설정
#location ^~ /.well-known/acme-challenge/ {
# default_type "text/plain";
# root /var/www/letsencrypt;
#}
View bitbucket_webhooks.php
<?php
define('LOG_FILE_NAME', 'deploy.log');
// bitbucket payload
// https://confluence.atlassian.com/bitbucket/event-payloads-740262817.html#EventPayloads-Push
$input = json_decode(file_get_contents('php://input'), true);
$username = $input['actor']['username'];
$dpname = $input['actor']['display_name'];
$pushData = array_pop($input['push']['changes']);
$branch = $pushData['new'] ? $pushData['new']['name'] : '';
View http_request_promisify.js
function httpRequest(params, postData) {
return new Promise(function(resolve, reject) {
var req = http.request(params, function(res) {
// reject on bad status
if (res.statusCode < 200 || res.statusCode >= 300) {
return reject(new Error('statusCode=' + res.statusCode));
}
// cumulate data
var body = [];
res.on('data', function(chunk) {
View check_sequence_numbers.js
function checkSequnceNumbers(target, counterLength= 6){
// under es6
// let sequentialCounter = Array.apply(null, Array(counterLength)).map(Number.prototype.valueOf,0);
let sequentialCounter = new Array(counterLength).fill(0);
let count = 0;
for (let i = 0, len = target.length; i < len; i++) {
let subCount = 0;
for (let j = 1; j < len; j++) {
View splitBetweenStr.php
<?php
/**
* [splitBetweenStr 텍스트 사이의 문자열을 배열로 반환]
* @param [string] $str [전체 문자열]
* @param [string] $startWord [찾을 시작 문자열]
* @param [string] $endWord [찾을 종료 문자열]
* @return [array] [텍스트 사이의 문자열 배열]
*
* ex) splitBetweenStr('<br>hi</br><b>test</b><br>graceful_light</br>', '<br>', '</br>')
* => ['hi', 'graceful_light']
View postData.php
<?
/**
* [postData 외부파일을 POST 방식으로 읽기]
* @param [string] $str [url]
* @param [array] $data [parameters]
* @param [int] $sleepMs [연결지연ms]
* @return [string] [내용]
*/
function postData($str, $data, $sleepMs=0){
$url = parse_url($str);
View getData.php
<?
/**
* [getData 외부파일을 GET 방식으로 읽기]
* @param [string] $str [url]
* @param [array] $data [parameters]
* @return [string] [내용]
*/
function getData($str, $data){
$url = parse_url($str);
switch(strtoupper($url['scheme'])){
View clientside_image_download.js
/**
* [downloadImage]
* @param {[string]} img [base64encoded image data]
* @param {[string]} fileName [new file name]
* @return [image file]
*/
function downloadImage(img, fileName) {
var imgData = atob(img.src.split(',')[1]),
len = imgData.length,
buf = new ArrayBuffer(len),
View xmlrpc_blog_posting.php
<?
include_once "xmlrpc.inc";
$title = $_POST['title'];
$content = $_POST['content'];
$result = newPost($title, $content);
echo json_encode($result);
// 블로그 API 함수
View sublime_text_key_bindings.js
[
// ctrl+d 로 줄삭제
{ "keys": ["ctrl+d"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete Line.sublime-macro"} },
// 기존 ctrl+d의 기능을 옮김
{ "keys": ["ctrl+shift+k"], "command": "find_under_expand" },
{ "keys": ["ctrl+k", "ctrl+shift+k"], "command": "find_under_expand_skip" },
// 들여쓰기 활성화
{ "keys": ["f12"], "command": "reindent" , "args": { "single_line": false } },
// 파일 새로고침
{ "keys": ["f5"], "command": "revert" },