Skip to content

Instantly share code, notes, and snippets.

@mytory
mytory / duplicate_line_xcode.md
Created Apr 8, 2019 — forked from emotality/duplicate_line_xcode.md
Xcode - Duplicate Line key binding
View duplicate_line_xcode.md

Xcode line duplicate

Bind keys to duplicate lines in Xcode

  1. Open below directory in Finder with Cmnd + Shift + G
/Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources/
@mytory
mytory / php_apache_homebrew.md
Created Oct 11, 2018 — forked from DragonBe/php_apache_homebrew.md
Installation of Apache 2.4 and PHP 7.1 with Homebrew
View php_apache_homebrew.md

I posted several talks about compiling PHP from source, but everyone was trying to convince me that a package manager like Homebrew was a more convenient way to install.

The purpose of Homebrew is simple: a package manager for macOS that will allow you to set up and install common packages easily and allows you to update frequently using simple commands.

I used a clean installation of macOS Sierra to ensure all steps could be recorded and tested. In most cases you already have done work on your Mac, so chances are you can skip a few steps in this tutorial.

Apache and PHP with homebrew

I’ve made this according to the installation instructions given on GetGrav.

@mytory
mytory / short-open-tag-converter.php
Last active Sep 30, 2018
Change short open tag to long open tag.
View short-open-tag-converter.php
<?php
// This script convert short open tag to long open tag.
// Inspired from https://stackoverflow.com/a/3621669
//
// Source: https://gist.github.com/mytory/5380b6a970ed4c14e16dd1be498e0919
// Usage: php short-open-tag-converter.php target_file_path.php
// Notice: This script change original file.
//
// If you want to change '<?=' to '<?php echo ' uncomment line 45~50.
@mytory
mytory / Dockerfile
Created Aug 7, 2018
Dockerfile basic template for Korean ubuntu user.
View Dockerfile
FROM ubuntu:18.04
ENV DEBIAN_FRONTEND=noninteractive
# repository
RUN sed -i 's|archive.ubuntu.com|mirror.kakao.com|g' /etc/apt/sources.list
RUN apt-get update
RUN apt-get upgrade -y
# timezone
@mytory
mytory / fetch-attachment.js
Created Aug 18, 2016 — forked from hasinhayder/fetch-attachment.js
Fetch WordPress Media Files (Attachments) Via Backbone Model
View fetch-attachment.js
var attachment_id = 1234;
var attachment = new wp.media.model.Attachment.get(attachment_id);
attachment.fetch({success:function(att){
if (_.contains(['png','jpg','gif','jpeg'],att.get('subtype'))) {
console.log(att.attributes);
$("<img/>").attr("src",att.attributes.sizes.thumbnail.url).appendTo($("body"));
}
}});
@mytory
mytory / webfont.js
Created Jun 15, 2016
Updated version of 'The deferred font loading logic for Smashing Magazine' by An, Hyeong-woo.
View webfont.js
(function () {
"use strict";
// 스매싱 매거진의 '지연된 웹폰트 불러오기' javascript를 안형우가 수정한 것.
// https://gist.github.com/hdragomir/8f00ce2581795fd7b1b7
// 한 번 캐시하면 css 파일은 클라이언트 측에 저장한다.
// 아래 css_href 가 바뀌면 그 때 다시 받는다.
// woff base64를 내장한 css
var css_href = 'css/webfont.woff.css';
// localStorage 를 지원하지 않는 브라우저를 위한 css
@mytory
mytory / get_smashing_magazine_calendar.php
Last active May 9, 2016
script get smashing magazine monthly wallpaer
View get_smashing_magazine_calendar.php
<?php
/**
* Author: An, Hyeong-woo
* Email: mytory@gmail.com
* Blog: http://mytory.net
* Description: See detail on help message. You can see by running this script without args.
* Dependencies: Tidy extension.
*/
function cmd_echo($str){
echo $str . PHP_EOL;
@mytory
mytory / download-functions.php
Created Apr 21, 2016
Download file with specific name in all browser.
View download-functions.php
/**
* Download file from path and mimetype.
*
* @param $path
* @param $mimetype
* @param null $filename
*/
function download_file ($path, $mimetype, $filename = NULL) {
if (empty($filename)) {
$filename = pathinfo($path, PATHINFO_BASENAME);
@mytory
mytory / anything2html.php
Last active Mar 1, 2016
Created by [gnoownow10](https://github.com/gnoownow10). docx, doc, hwp to html.
View anything2html.php
<?php
/**
* @see dependencies: libreoffice, pyhwp https://pythonhosted.org/pyhwp/ko/
* Class Anything2html
*/
class Anything2html {
static $hwp5html;
static $libreoffice;
static $error;
@mytory
mytory / batch_convert2utf8.php
Created Jan 7, 2016
euc-kr to utf-8. PHP detect file encoding and if encoding is euc-kr or ms949, it convert the file.
View batch_convert2utf8.php
<?php
function batch_convert_encoding($dir, $out_charset = 'utf-8'){
if($handle = opendir($dir)){
echo "\n\n## Directory is $dir\n\n";
while(false !== ($file = readdir($handle))){
if(in_array($file, array('.', '..', '.git'))){
continue;
}
$file_path = realpath($dir . DIRECTORY_SEPARATOR . $file);
$pathinfo = pathinfo($file_path);