Skip to content

Instantly share code, notes, and snippets.

@mistic100
mistic100 / delete-installer.iss
Created August 9, 2014 10:12
[InnoSetup] Delete installer on next startup
[Code]
// mark installer for deletion if argument "-delete-installer" is present
procedure DeinitializeSetup();
var i: integer;
begin
for i:= 0 to ParamCount do
begin
if ParamStr(i) = '-delete-installer' then
begin
RestartReplace(ExpandConstant('{srcexe}'), '');
@mistic100
mistic100 / tumblr-downloader.js
Last active April 24, 2022 19:49
[Node] Simple Tumblr photo downloader for NodeJS. Really basic, no options, no error handling.
/**
* TUMBLR downloader
*
* Usage:
* - enter the blog name: URL part before `.tumblr.com`
* - enter what you want to download: `posts` or `likes`
* - enter your OAuth public key (https://www.tumblr.com/settings/apps)
* - optionally enter the minimum id to retrieve (ignored if `[blog]-[mode].last` file exists)
* - if you have a small internet connection, set the queue size to 1
* - you can ask the downloader to overwrite existing files
@mistic100
mistic100 / silkscreen.class.php
Last active August 29, 2015 13:57
[PHP] Write text on image with silkscreen font
<?php
/**
* Write text on image with silkscreen font http://kottke.org/plus/type/silkscreen
*
* Usage:
* $img = imagecreatetruecolor(65, 15);
* $bg = imagecolorallocate($img, 0, 0, 0);
* $fg = imagecolorallocate($img, 255, 255, 255);
*
* silk::write($img, 5, 5, 'Hello world', $fg, 1, false, 0);
@mistic100
mistic100 / simpletextimage.class.php
Created March 8, 2014 15:25
[PHP] Generate a very simple image containing some text
<?php
/**
* Generate a very simple image containing some text
*
* Basic usage:
* (new SimpleTextImage('Hello world!'))->render();
*
* All functionalities:
* (new SimpleTextImage())
* ->setText('Hello world!')
@mistic100
mistic100 / array_pos.php
Last active January 2, 2016 20:29
[PHP] Search a string in array values
<?php
/**
* Search a string in array values
*
* @param string $needle
* @param array $haystack
* @param bool $match_all - return all instances
* @param bool $preg_mode - search in PCRE mode
* @return mixed|array
*/
@mistic100
mistic100 / array_unique_deep.php
Last active January 25, 2020 12:14
[PHP] Extract unique values of the specified key in a two dimensional array
<?php
/**
* Extract unique values of the specified key in a two dimensional array
*
* @param array $array
* @param mixed $key
* @return array
*/
function array_unique_deep($array, $key)
{
@mistic100
mistic100 / dir_is_empty.php
Last active January 7, 2021 14:33
[PHP] Check if a folder is empty
<?php
/**
* Check if a directory is empty (a directory with just '.svn' or '.git' is empty)
*
* @param string $dirname
* @return bool
*/
function dir_is_empty($dirname)
{
if (!is_dir($dirname)) return false;
@mistic100
mistic100 / file_exists_strict.php
Last active January 2, 2016 20:29
[PHP] Check if a file exists but is not dir
<?php
/**
* Check if a file exists but is not dir
*
* @param file
* @return bool
*/
function file_exists_strict($file)
{
return file_exists($file) && !is_dir($file);
@mistic100
mistic100 / safe_version_compare.php
Last active January 2, 2016 20:29
[PHP] Compare versions with alphabetical components
<?php
/**
* Compare versions with alphabetical components.
* Usesversion_compare after having converted single chars to their decimal values.
* Needed because version_compare does not understand versions like '2.5.c'.
*
* @param string $a
* @param string $b
* @param string $op
*/