Skip to content

Instantly share code, notes, and snippets.

@cereal-s
cereal-s / shell
Created January 6, 2018 17:09
Ubuntu 17.10 prevents Gparted and other applications that require root access to run in GUI, run the following before executing the program.
xhost +si:localuser:root
@cereal-s
cereal-s / 00. tutorial.md
Created October 2, 2017 17:02 — forked from maxivak/00. tutorial.md
Importing/Indexing database (MySQL or SQL Server) in Solr using Data Import Handler
<?php
/**
* Trait helps to allow for some limited overloading of
* methods in the class this is attached to.
*/
trait Overloader {
/**
* Where the magic happens
@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 / index.html
Created September 7, 2017 09:32 — forked from karbassi/index.html
How to handle single and double click events separately in javascript.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Single and Double Click</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="the_div"></div>
<span>Double click the block</span>

Keybase proof

I hereby claim:

  • I am cereal-s on github.
  • I am cereal_ (https://keybase.io/cereal_) on keybase.
  • I have a public key whose fingerprint is FD33 B0C7 6279 29DD C23F 8180 374E DDFF 4BE9 C8D4

To claim this, I am signing this object:

@cereal-s
cereal-s / gist:3ec7c45353e8e259ec16cf10ea2ad1a7
Last active August 24, 2019 14:09 — forked from codler/gist:3906826
Support HTTP Header Range, mp4, php.php/mp4.mp4
<?php
# Nginx doesn't have PATH_INFO
if (!isset($_SERVER['PATH_INFO'])) {
$_SERVER['PATH_INFO'] = substr($_SERVER["ORIG_SCRIPT_FILENAME"], strlen($_SERVER["SCRIPT_FILENAME"]));
}
$request = substr($_SERVER['PATH_INFO'], 1);
$file = $request;
$fp = @fopen($file, 'rb');
@cereal-s
cereal-s / format_size.php
Last active April 21, 2018 16:27
Format bytes to KiB, MiB, GiB and TiB.
<?php
if( ! function_exists('_format_size'))
{
/**
* Return formatted bytes.
*
* @see http://www.iec.ch/si/binary.htm
* @param integer $bytes
* @param integer $kilo 1000, 1024
@cereal-s
cereal-s / gist:c4c07138aded7c6cf17bb4da5aa3c1cc
Created May 22, 2017 12:26
[BASH] Watch specific process
watch -n 2 'ps -opid,pri,%cpu,%mem,user,args -p `pgrep php`'
@cereal-s
cereal-s / index.html
Created January 29, 2017 11:58
rjYgPe
<div>
Helloz
</div>