Skip to content

Instantly share code, notes, and snippets.

@CoreText
CoreText / update.sql
Created November 26, 2021 02:31 — forked from ozh/update.sql
mass update post times in WordPress
-- substract 3 hours
UPDATE `wp_posts`
SET `post_date` = DATE_ADD( `post_date`,INTERVAL -3 HOUR )
WHERE post_status = 'publish';
@CoreText
CoreText / bookmarklet.js
Created November 26, 2021 02:31 — forked from ozh/bookmarklet.js
Total sales on CodeCanyon
var total = 0;
var items = 0;
$('.sale-info').each( function(i,e){
var price = $(e).find('.price').text().replace('$','');
var sales = $(e).find('.sale-count').text().replace(' Sales','');
total = total + ( price * sales );
items++;
});
alert( '$' + total + ' with ' + items + ' items');
@CoreText
CoreText / gist:a197430c8d4735f0e58605eb595eb78f
Created November 26, 2021 02:29 — forked from ozh/gist:b118f0f7865203417a6c
var_dump() for your Unit Tests
<?php
function ut_var_dump( $what ) {
ob_start();
var_dump( $what );
$display = ob_get_contents();
ob_end_clean();
fwrite( STDERR, $display );
}
@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