Skip to content

Instantly share code, notes, and snippets.

View yuptogun's full-sized avatar

엽토군 yuptogun

View GitHub Profile
### Keybase proof
I hereby claim:
* I am yuptogun on github.
* I am eojin (https://keybase.io/eojin) on keybase.
* I have a public key ASDWfzN5LzBVBiG8vzqIMAidm-v5UVCWWytRBwN01nvZ8Qo
To claim this, I am signing this object:
@yuptogun
yuptogun / renumber-srt.php
Created February 17, 2022 11:55
re-number SRT file captions
<?php
$file = trim(file_get_contents('foo.srt')); // read SRT file
$subtitles = explode("\r\n\r\n", $file); // get each caption block by double line breaks
echo '<pre>'; // print it on the browser - you may set a new file handler here instead
foreach ($subtitles as $i => $subtitle) {
echo ($i + 1).PHP_EOL; // print the new sequence number
$lines = explode(PHP_EOL, $subtitle);
for ($i = 1; $i < count($lines); $i++) { // skip the first line i.e. the existing sequence number
echo $lines[$i].PHP_EOL; // print the rest i.e. the caption content
@yuptogun
yuptogun / linuxserver-ffmpeg-resize.sh
Last active February 9, 2022 05:25
resize all media files in directory using linuxserver/ffmpeg
#!/bin/bash
# usage
# linuxserver-ffmpeg-resize.sh mkv 720
# linuxserver-ffmpeg-resize.sh avi 1080 480
if [ -z "$1" ]; then
echo "please provide extension! aborting."
exit
elif [ -z "$2" ]; then
@yuptogun
yuptogun / imageRetro.php
Created June 12, 2018 07:27
make GD image instance retro!
<?php
/**
* Make GD image instance RETRO! 😎
* @param instance $image instance of GD image resource
* @param int $bits number of bits to represent
* @param arr|null $screenColor [0, 255, 0] will give it a "Nintendo Game Boy" look
* @return intance RETRO image instance
*/
function imageRetro($image, $bits = 1, $screenColor = null)
@yuptogun
yuptogun / swmu-controller.js
Last active September 6, 2017 16:24
The javascript controller of http://20timeline.com/oversmart/smwu
/*
* 네 압니다 알아요 엄청 쪽팔린 코드인 거
* 깃헙 gist에 꽂아놨으니까 수정 좀 같이 합시다
* https://gist.github.com/yuptogun
*/
// 각종 외부 이미지
// 리셋
@yuptogun
yuptogun / readme.md
Last active September 24, 2015 21:36
wordpress category watchlist add/remove

watchlist.php

After finding out that nobody has ever built a "favorite category" plugin or anything like that, I just decided to write one by myself. 6 hours of sleepless var_dump() debugging, a sheet of paper with handwritten function drafts, no possible acknowledgement from the boss.

How it works

  1. You put it anywhere inside your Wordpress directory. I prefer the root.
  2. You create the dynamically generated checkin/checkout buttons in your Wordpress site. Well that's your homework.
  3. They click the button to go to somewhere like: /watchlist.php?user=16&check=out&program=2
  4. It add_user_meta() or update_user_meta() to record what they checked in or out to the program, or a certain taxonomy.
@yuptogun
yuptogun / clean_the_mess.js
Last active August 29, 2015 14:26
sorifestival javascripts
/*
* 뷰를 통제하는 각종 잡다한 스니펫들입니다.
* anyway written by eojin@20timeline.com
*/
// 상단 메뉴의 ul 출력을 정돈합니다.
$("#topmenu").find('.c_cnt').remove();
/* 적당히 텍스트를 2등분하기 위한 스크립트입니다. 참고: jsfiddle.net/interdream/Qpzsq/3 */
$("#topmenu ul li ul li a").each(function() {
@yuptogun
yuptogun / Handwritten jQuery div Slider.md
Last active August 29, 2015 14:26
Handwritten jQuery div Slider

Handwritten jQuery div Slider

A generated gist from a pen by me.

Spent 4 hours to build the simplest div carousel from scratch. I studied setInterval(), animate(), flag variables, the principles of z-index and so on for the first time. Damn sorifestival I really thank you so much.