Skip to content

Instantly share code, notes, and snippets.

@CoreText
CoreText / curl.php
Created November 26, 2021 02:28 — forked from ozh/curl.php
Limit CURL so it doesn't download huge files
<?php
# with a callback
$sizeLimit = 100000;
curl_setopt($ch, CURL_PROGRESSFUNCTION, function ($ch, $totalBytes, $receivedBytes) use ($sizeLimit) {
if ($totalBytes > $sizeLimit) {
return 1; // return non-zero value to abort transfer
}
});
@CoreText
CoreText / each_and_map.php
Created November 26, 2021 02:27 — forked from ozh/each_and_map.php
PHP each() and map()
<?php
function map($items, $func)
{
$results = [];
foreach ($items as $item) {
$results[] = $func($item);
}
return $results;
}
@CoreText
CoreText / typefast.html
Created November 26, 2021 02:25 — forked from ozh/typefast.html
How Fast Can You Type (simple typing accuracy test I made in 2007)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Typing Speed Test &mdash; How fast can you type ?</title>
<style type="text/css">
#o_keypressed, #o_wordok, #o_wordnotok {zdisplay:none;}
#o_typein{font-size:21px; margin:15px;padding-top:6Opx;display:none;}
body {font:16px Verdana,Arial}
#timer {font-size:30px; color: #494;background:#efe; border:1px solid #cdc; width:100px; height:80px; float:left; margin:0 10px; text-align:center}
@CoreText
CoreText / userDefineLang.xml
Created November 26, 2021 02:21 — forked from ozh/userDefineLang.xml
Notepad++ : userDefineLang.xml for Markdown
<NotepadPlus>
<UserLang name="Markdown" ext="mkdn mkd md" udlVersion="2.0">
<Settings>
<Global caseIgnored="yes" allowFoldOfComments="no" forceLineCommentsAtBOL="no" foldCompact="no" />
<Prefix Keywords1="no" Keywords2="no" Keywords3="no" Keywords4="no" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" />
</Settings>
<KeywordLists>
<Keywords name="Comments" id="0">00# 00## 00### 00#### 00##### 01 02 03&lt;!-- 04--&gt;</Keywords>
<Keywords name="Numbers, additional" id="1"></Keywords>
<Keywords name="Numbers, prefixes" id="2"></Keywords>
@CoreText
CoreText / push_on_someone_pull_request.md
Created November 26, 2021 02:20 — forked from ozh/push_on_someone_pull_request.md
push on someone's pull request

Pull request from THEM to my REPO :

$ git checkout -b THEM-patch-1 master
$ git pull https://github.com/THEM/REPO.git patch-1
$ git commit --allow-empty -m "Trigger build"
$ git push https://github.com/THEM/REPO.git THEM-patch-1:patch-1
@CoreText
CoreText / edit-files-in-a-docker-container.md
Created November 26, 2021 02:15 — forked from ozh/edit-files-in-a-docker-container.md
edit files in a docker container
# get list of container id
docker ps

# launch bash into container
# prefix with winpty if no terminal available (Windows)
winpty docker exec -it <id> bash

# Install an editor
apt-get update
@CoreText
CoreText / plugin.php
Created November 26, 2021 02:14 — forked from ozh/plugin.php
YOURLS : add fake links (for test installs)
<?php
/*
Plugin Name: Insert Fake Links
Plugin URI: http://yourls.org/
Description: Populate DB with fake links for tests
Version: 1.0
Author: Ozh
Author URI: http://ozh.org/
*/
@CoreText
CoreText / gist:ced3890b074504df8a2cb7e74025faf1
Created November 26, 2021 02:13 — forked from ozh/gist:3928158
YOURLS to TweetButton
javascript:(function(){var d=document,s=d.createElement('script');window.yourls_callback=function(r){if(r.short_url){javascript:window.open('https://twitter.com/intent/tweet?text='+encodeURIComponent(' '+r.short_url+' '+d.title.replace(/^[ ]+|[ ]+$/g, '')),'Tweet','width=400,height=260');}else{alert('An error occured: '+r.message);}};s.src='http://u.vanu.jp/admin/index.php?u='+encodeURIComponent(d.location.href)+'&jsonp=yourls';void(d.body.appendChild(s));})();
@CoreText
CoreText / disable-plugins-when-doing-local-dev.php
Created November 26, 2021 02:12 — forked from ozh/disable-plugins-when-doing-local-dev.php
Disables specified WordPress plugins when doing local development
<?php
/*
Plugin Name: Disable plugins when doing local dev
Description: If the WP_LOCAL_DEV constant is true, disables plugins that you specify
Version: 0.1
License: GPL version 2 or any later version
Author: Mark Jaquith
Author URI: http://coveredwebservices.com/
*/