Skip to content

Instantly share code, notes, and snippets.

View sunghwan2789's full-sized avatar

Sunghwan Bang sunghwan2789

View GitHub Profile
@sunghwan2789
sunghwan2789 / cla_directzip.php
Last active February 13, 2019 07:52
묶어 받습니다
<?php
class DirectZip
{
private static $BUFFER_SIZE = 4194304; // 4MiB
private $currentOffset;
private $entries;
public function open($filename)
{
<?php
function stripFileName($name)
{
return preg_replace('/[\\\\\/:*?"<>|]/', '-', $name);
}
?>
@sunghwan2789
sunghwan2789 / download.php
Last active September 22, 2018 02:37
이어받습니다
<?php
function mimeTypeOf($path)
{
$finfo = new finfo(FILEINFO_MIME_TYPE);
return $finfo->file($path);
}
function download($path, $name = '', $mimeType = '', $expires = 0, $streaming = false)
{
// http://w-shadow.com/blog/2007/08/12/how-to-force-file-download-with-php/
set_time_limit(0);
INSERT INTO osu.osu_beatmapsets (beatmapset_id, user_id, thread_id, artist, artist_unicode, title, title_unicode, creator, source, tags, video, storyboard, epilepsy, bpm, versions_available, approved, approvedby_id, approved_date, submit_date, last_update, filename, active, rating, offset, displaytitle, genre_id, language_id, star_priority, filesize, filesize_novideo, body_hash, header_hash, osz2_hash, download_disabled, download_disabled_url, thread_icon_date, favourite_count, play_count, difficulty_names) VALUES (405053, 798668, 409296, 'Azusa Tadokoro', '田所あずさ', 'Junshin Always', '純真Always', 'Shad0w1and', '無彩限のファントム・ワールド', 'musaigen no phantom world myriad colors tv size anime opening ending cloudsplash16 little lami intoon zzhboy starrstyx aerous', 1, 0, 0, 180, 8, 1, 3621552, '2016-02-15 03:21:02', '2016-01-16 15:19:42', '2016-02-08 02:56:07', '405053.osz', 1, 9.45496, 0, '[bold:0,size:20]田所あずさ|純真Always', 3, 3, 20, 0, null, 0x7CCF1E3C52194C65DAF9F36A910F2347, 0xD159A700F97BF2DCFF2FB3A27F8E3BE7, 0x786953F
INSERT INTO osu.osu_beatmaps (beatmap_id, beatmapset_id, user_id, filename, checksum, version, total_length, hit_length, countTotal, countNormal, countSlider, countSpinner, diff_drain, diff_size, diff_overall, diff_approach, playmode, approved, last_update, difficultyrating, playcount, passcount, orphaned, youtube_preview) VALUES (889318, 405053, 798668, 'Azusa Tadokoro - Junshin Always (Shad0w1and) [Advanced].osu', '000af61ac36f4478cadc53cf77045125', 'Advanced', 89, 87, 318, 60, 129, 0, 4, 3.5, 5.5, 6.5, 0, 1, '2016-02-08 02:56:08', 2.34034, 6715, 1955, 0, null);
INSERT INTO osu.osu_beatmaps (beatmap_id, beatmapset_id, user_id, filename, checksum, version, total_length, hit_length, countTotal, countNormal, countSlider, countSpinner, diff_drain, diff_size, diff_overall, diff_approach, playmode, approved, last_update, difficultyrating, playcount, passcount, orphaned, youtube_preview) VALUES (889319, 405053, 798668, 'Azusa Tadokoro - Junshin Always (Shad0w1and) [Lami''s Extra].osu', '17c8cc1753ea26a214e321cb296
//from http://pastebin.com/jftEbWrc
public class LimitedPool<T> : IDisposable where T : class
{
readonly Func<T> _valueFactory;
readonly Action<T> _valueDisposeAction;
readonly TimeSpan _valueLifetime;
readonly ConcurrentStack<LimitedPoolItem<T>> _pool;
bool _disposed;
public LimitedPool(Func<T> valueFactory, Action<T> valueDisposeAction, TimeSpan? valueLifetime = null)
@sunghwan2789
sunghwan2789 / download_test.php
Last active August 27, 2018 06:38 — forked from sharapeco/download_test.php
Content-Disposition: attachment で日本語ファイル名をダウンロードさせるテスト
<?php
$t = isset($_GET['t']) ? $_GET['t'] : null;
$org = '此のファイル test.php';
$fn = array(
'A: UTF-8 Raw' => 'Content-Disposition: attachment; filename="' . $org . '"',
'B: UTF-8 URL Encoded' => 'Content-Disposition: attachment; filename="' . rawurlencode($org) . '"',
'C: RFC 2231' => 'Content-Disposition: attachment; filename*=UTF-8\'\'' . rawurlencode($org),
'D: UTF-8 Raw + RFC 2231' => 'Content-Disposition: attachment; filename="' . $org . '"; filename*=UTF-8\'\'' . rawurlencode($org),
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<!-- SEO Rules -->
<rule name="StripSlashes" stopProcessing="true">
<conditions>
<add input="{UNENCODED_URL}" pattern="^([^\?]*)//(.*)" />
</conditions>
<!DOCTYPE html>
<html lang="ko" class="min-vh-100">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>계산기</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>
<body class="min-vh-100">
@sunghwan2789
sunghwan2789 / epsilon-closure.cc
Last active May 21, 2022 05:35
Converts NFA to DFA using Epsilon Closure
#include <vector>
#include <set>
#include <string>
#include <iostream>
#include <map>
#include <tuple>
#include <utility>
#include <cctype>
#include <queue>
#include <algorithm>