Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@vlakoff
vlakoff / adobe_flash_automatic_install.cmd
Created October 30, 2017 11:42
I got tired of "click click click" each and every time a new Adobe Flash version is released. Still UAC prompts, though. Includes a check of installed versions before and after the setups.
:: Installers download page:
:: https://helpx.adobe.com/flash-player/kb/installation-problems-flash-player-windows.html#main-pars_text_4
@ECHO.
@ECHO == CURRENT VERSIONS ==
@REG QUERY HKLM\SOFTWARE\Macromedia\FlashPlayerActiveX /v Version
@REG QUERY HKLM\SOFTWARE\Macromedia\FlashPlayerPlugin /v Version
@REG QUERY HKLM\SOFTWARE\Macromedia\FlashPlayerPepper /v Version
@vlakoff
vlakoff / custom_logging.php
Created April 1, 2017 04:21
Custom logging in Laravel: one dir per month, one file per day
<?php
// logs in one dir per month, one file per day
// storage/logs/YYYY-MM/YYYY-MM-DD.log
// paste in bootstrap/app.php, after $app assignation
// reference: https://laravel.com/docs/5.4/errors#custom-monolog-configuration
$app->configureMonologUsing(function () {
<?php
namespace App;
class Article extends \Illuminate\Database\Eloquent\Model
{
protected function getAttributeFromArray($key)
{
global $BENCHMARK_1;
@vlakoff
vlakoff / call-private-methods.php
Created March 19, 2016 22:14
Call private/protected PHP methods. Danger zone. Don't do this at home.
<?php
// we'll do nasty things to this instance
$instance = new Foo;
// pass instance or class name
$method = new ReflectionMethod($instance, 'privateMethod');
$method = new ReflectionMethod('Foo', 'privateMethod');
// milkshakes to the yard
@vlakoff
vlakoff / Str-replaceFirst-replaceLast.php
Created February 24, 2016 16:35
Add Str::replaceFirst, replaceLast and corresponding helpers to Laravel 5.1 LTS
<?php
use Illuminate\Support\Str;
Str::macro('replaceFirst', function ($search, $replace, $subject) {
$position = strpos($subject, $search);
if ($position !== false) {
@vlakoff
vlakoff / orderByRandom.php
Created February 24, 2016 04:30
Add orderByRandom() to Laravel query builder
<?php
// github.com/laravel/framework/issues/5223
// github.com/laravel/framework/pull/5435
use Illuminate\Database\Query\Builder;
Builder::macro('orderByRandom', function () {
$randomFunctions = [
@vlakoff
vlakoff / Spotify.ahk
Created September 13, 2015 03:17
Spotify launcher - start application if needed, add global hotkeys
; www.autohotkey.com/board/topic/36239-spotify-global-hotkeys/
; #Win !Alt ^Ctrl +Shift
#NoEnv
#SingleInstance force
DetectHiddenWindows, On
IfWinNotExist, ahk_class SpotifyMainWindow
Run, %A_AppData%\Spotify\spotify.exe, %A_AppData%\Spotify
@vlakoff
vlakoff / convert_lz4_header.php
Last active August 13, 2021 23:17
Convert from Mozilla's LZ4 format to LZ4 v1.3
<?php
/**
* Convert from Mozilla's LZ4 format to LZ4 v1.3
*
* @link https://searchfox.org/mozilla-central/source/toolkit/components/lz4/lz4.js
* @link https://lz4.software.informer.com/1.3/
*
* @param string $input File content in Mozilla's LZ4 format
* @return string File content converted to LZ4 v1.3
@vlakoff
vlakoff / basic-dom-insertion.js
Created September 2, 2015 08:29
Functions for quick'n'dirty DOM insertion when there is no JS library
// for more elaborate code, see for instance:
// https://github.com/jquery/jquery/blob/master/src/manipulation.js
function prepend(target, elem) {
target.insertBefore(elem, target.firstChild);
}
function append(target, elem) {
target.appendChild(elem);
}
@vlakoff
vlakoff / OrderByRandomTrait.php
Created July 31, 2015 19:37 — forked from vluzrmos/HasRandomStatementTrait.php
Laravel Eloquent Agnostic Random Statement
<?php
trait OrderByRandomTrait
{
/**
* Scope to order by random.
*
* @param \Illuminate\Database\Query\Builder $query
* @return \Illuminate\Database\Query\Builder
*/