Skip to content

Instantly share code, notes, and snippets.

@mytory
mytory / anything2html.php
Last active March 1, 2016 10:51
Created by [gnoownow10](https://github.com/gnoownow10). docx, doc, hwp to html.
<?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 January 7, 2016 10:41
euc-kr to utf-8. PHP detect file encoding and if encoding is euc-kr or ms949, it convert the file.
<?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);
@mytory
mytory / batch_detect_encoding.php
Last active January 7, 2016 10:43
PHP command line script. It detect encoding from files on directory and subdirectories and print it.
<?php
function print_file_encoding_from($dir){
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);
$extension = pathinfo($file_path, PATHINFO_EXTENSION);
<?php
// Emulate register_globals off
// source: http://php.net/manual/en/faq.misc.php#faq.misc.registerglobals
function unregister_GLOBALS()
{
if (!ini_get('register_globals')) {
return;
}
// Might want to change this perhaps to a nicer error
<?php
// Emulate register_globals on
// source: http://php.net/manual/en/faq.misc.php#faq.misc.registerglobals
if (!ini_get('register_globals')) {
$superglobals = array($_SERVER, $_ENV,
$_FILES, $_COOKIE, $_POST, $_GET);
if (isset($_SESSION)) {
array_unshift($superglobals, $_SESSION);
}
foreach ($superglobals as $superglobal) {
#/bin/sh
soffice --headless --convert-to html:HTML "$1"
basename=$(basename "$1")
filename="${basename%.*}"
html2text "$filename.html" > "$filename.md"
/**
* Create Select2 library field that also can direct input.
* @param selector
*/
function direct_write_select2(selector){
$(selector).select2({
minimunInputLength: 1,
query: function(options){
var data = {results: []};
var dataSource;
// execute with nodejs on bash terminal.
var string = "test text";
for(var i = 0; i < 110; i++){
// 스타일링 : \033[스타일번호m문자열\033[m
// 강조 스타일링 : \033[01;스타일번호m문자열\033[m
console.log(i + " => " + "\033[" + i + "m" + string + "\033[m" + " " + "\033[01;" + i + "m" + string + "\033[m");
}
@mytory
mytory / randombg.sh
Last active December 30, 2015 03:59
Select a file on specified directory, and set that to wallpaper using Esetroot. I'm using this script to change wallpaper by 5 minutes on fluxbox with cron.
#!/bin/sh
filename=$(shuf -n1 -e /home/mytory/wallpapers/*)
Esetroot -f $filename