Skip to content

Instantly share code, notes, and snippets.

@vlakoff
vlakoff / Stringy - extend from instance.php
Created January 13, 2015 15:18
Stringy - Create extended Stringy from existing instance
<?php
require './vendor/autoload.php';
use Stringy\Stringy;
class MyStringy extends Stringy {
// http://php.net/manual/en/language.oop5.visibility.php#language.oop5.visibility-other-objects
@vlakoff
vlakoff / Stringy - charsArray.php
Created January 13, 2015 15:16
Stringy - Get and manipulate $charsArray at runtime
<?php
require './vendor/autoload.php';
use Stringy\Stringy;
class MyStringy extends Stringy {
public $managedCharsArray;
@vlakoff
vlakoff / Stringy - quick check.php
Created January 16, 2015 23:59
Stringy - Quick check for proposed changes in $charsArray
<?php
require './vendor/autoload.php';
use Patchwork\Utf8;
use Stringy\Stringy;
class MyStringy extends Stringy {
public function charsArray() {
@vlakoff
vlakoff / HideConsole.vbs
Created May 11, 2015 07:51
Call a Windows batch file without showing the console window
' taken from FreeFileSync - www.freefilesync.org
set argIn = WScript.Arguments
num = argIn.Count
if num = 0 then
WScript.Echo "Call a Windows batch file (*.cmd, *.bat) without showing the console window" & VbCrLf & VbCrLf &_
"Command line:" & VbCrLf & "WScript HideConsole.vbs MyBatchfile.cmd <command line arguments>"
WScript.Quit 1
end if
@vlakoff
vlakoff / cookies.js
Created June 26, 2015 03:56
Simple, no-dependency JavaScript to set and delete cookies
function setCookie(name, value, days) {
var t = new Date();
t.setDate(t.getDate() + days);
document.cookie = encodeURIComponent(name)+'='+encodeURIComponent(value)+'; expires='+t.toUTCString()+'; path=/';
}
function deleteCookie(name) {
// value is an empty string
document.cookie = encodeURIComponent(name)+'=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/';
};
@vlakoff
vlakoff / relative-size.js
Created June 28, 2015 23:12
Increase or decrease CSS values thanks to jQuery
/*
cleaner than hard-coding the desired font size
refs: http://api.jquery.com/css/
some use case:
all these websites that use *huge* font sizes,
painful to read even on a 1920x1080 screen.
*/
$('.article-content').css('font-size', '-=2');
@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 / 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 / phpdump.cmd
Last active September 13, 2015 14:17
A batch file for quickly dumping PHP expressions
@SETLOCAL
@SET expr=%*
@SET expr=%expr:"=\"%
@IF ^%expr:~-1%==^; SET expr=%expr:~0,-1%
@php -r "var_dump(%expr%);"
::A few examples:
::phpdump PHP_OS // "Everything should be made as simple as possible, but not simpler."
::phpdump ord("\n") // double quotation marks don't produce errors
::phpdump hexdec('ff'); // trailing semicolon should be omitted, yet it is supported for convenience
@vlakoff
vlakoff / jquery.cookie.js
Created July 5, 2012 03:01 — forked from mathiasbynens/jquery.cookie.js
Improved jQuery.cookie plugin