Skip to content

Instantly share code, notes, and snippets.

@cereal-s
cereal-s / ping.gs.php
Created September 8, 2017 13:44
Get number of pages from a PDF, using GhostScript.
<?php
/**
* Return the number of pages of a PDF.
*
* Imagick::pingImage() takes too much when dealing with big files.
*
* Command to execute:
*
* gs -q -dNODISPLAY -c "(%s) (r) file runpdfbegin pdfpagecount = quit"
@cereal-s
cereal-s / convert_link.py
Created April 27, 2021 20:22 — forked from dixonsiu/convert_link.py
Python scripts for Pandoc
@cereal-s
cereal-s / pandoc_multi_input.md
Created April 25, 2021 23:39 — forked from xuanlongma/pandoc_multi_input.md
Combine multiple input files when using Pandoc

If multiple input files are given, pandoc will concatenate them all (with blank lines between them) before parsing. -- from Pandoc website

Pandoc command: pandoc -s input1.md input2.md input3.md -o output.html

@cereal-s
cereal-s / pandoc_filter_procedures.md
Created April 24, 2021 15:14 — forked from dixonsiu/pandoc_filter_procedures.md
How to convert markdown link to html using Pandoc

How to convert markdown link to html using Pandoc

Issue

Pandoc cannot convert a link's URL as expected.
Markdown:

[Document](./document.md)

HTML:

Document

@cereal-s
cereal-s / net start & stop commands
Created March 25, 2021 09:47 — forked from jamiejohnsonkc/net start & stop commands
net start / net stop #win, #cmd
net start [serviceName]
and
net stop [serviceName]
tell you whether they have succeeded or failed pretty clearly. For example
U:\>net stop alerter
The Alerter service is not started.
@cereal-s
cereal-s / VideoStream.php
Last active February 5, 2020 14:39 — forked from ranacseruet/VideoStream.php
PHP VideoStream class for HTML5 video streaming
<?php
/**
* Description of VideoStream
*
* @author Rana
* @link http://codesamplez.com/programming/php-html5-video-streaming-tutorial
*/
class VideoStream
{
private $path = "";
@cereal-s
cereal-s / yt.php
Created December 5, 2019 22:57
Convert YouTube to thumbnail
<?php
/**
* Get video info
* @param string $code
* @return object | null
*/
function _get_info($code)
{
$yt = json_decode(file_get_contents("https://www.youtube.com/oembed?url=https://youtu.be/{$code}&format=json"));
@cereal-s
cereal-s / command.md
Last active November 28, 2019 12:20
Add contrast to pale PDF document with ImageMagick and pdfimages

COMMANDS

  pdfimages -j -p file.pdf ./images/prefix
  cd images
  mogrify -level 80%,85% -sharpen 0x1 prefix*.jpg
  convert -background white -page a4 prefix*.jpg new.pdf

NOTES

<?php
/**
* Plugin Name: Custom Fields for WooCommerce
* Description: Add custom fields to WooCommerce products
* Version: 1.0.0
* Author: Gareth Harris
* Author URI: https://pluginrepublic.com/
* Text Domain: cfwc
* WC requires at least: 3.4.0
* WC tested up to: 3.4.2
@cereal-s
cereal-s / combos.php
Last active August 26, 2019 09:26 — forked from farinspace/combos.php
Recursive functions, I can never find exactly what I need in a pinch
<?php
/**
* Generate combinations from multidimensional array
*/
function combos($data, $count, &$all = [], $group = [], $val = null, $i = 0) {
if (null !== $val) {
$group[] = $val;