Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am vensko on github.
  • I am vensko (https://keybase.io/vensko) on keybase.
  • I have a public key ASAEwvPAu2XYJM9XiQDDWVdSf8FFrGspQ72VdUvjd3cTzAo

To claim this, I am signing this object:

@vensko
vensko / SaveSelectedTextToGoogleDrive.gs
Last active January 22, 2017 17:20
Save selected text to Google Drive
/*
Generate your bookmarklet here: https://d.vensko.net/google-script-save-snippets-to-google-drive
Copyright (c) 2017 Dzmitry Vensko
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
<?php
$wmi = new COM("winmgmts:{impersonationLevel=impersonate}!//./root/cimv2");
$events = $wmi->ExecNotificationQuery("Select * From __InstanceOperationEvent Within 2 Where (Targetinstance Isa 'CIM_DataFile' Or Targetinstance Isa 'CIM_Directory') And TargetInstance.Drive='e:' And TargetInstance.Path='\\\\WATCH_DIRECTORY\\\\'");
while ($latestEvent = $events->NextEvent()) {
print_r($latestEvent->Path_->Class);
print_r([
$latestEvent->TargetInstance->Name,
@vensko
vensko / facebook-like.js
Last active August 29, 2015 14:24
Facebook like button as a bookmarklet
/*
Based on https://addons.mozilla.org/en-US/firefox/addon/facebook-share-button/
Bookmarklet:
javascript:var%20doc=window.document,fbdiv=doc.getElementById("fblk_div");if(fbdiv)fbdiv.style.display="block"!=fbdiv.style.display?"block":"none";else{fbdiv=doc.createElement("div"),fbdiv.setAttribute("id","fblk_div"),fbdiv.setAttribute("style","display:block;%20top:0;%20right:0;%20z-index:2147483647;%20margin:0;%20padding:10px;%20position:fixed;%20background-color:white;%20border:1px%20solid%20black;");var%20iframe=doc.createElement("iframe");iframe.setAttribute("type","content"),iframe.setAttribute("style","overflow:hidden;%20height:25px;%20width:230px;%20border:none;"),iframe.setAttribute("src","https://www.facebook.com/plugins/like.php?href="+encodeURIComponent(window.location.href)+"&layout=button_count&show_faces=false&share=true&action=like&colorscheme=light&height=25&width=230"),fbdiv.appendChild(iframe),doc.body.appendChild(fbdiv)}void(0)
*/
var doc = window.document;
var fbdiv = doc.getElementById("fblk
@vensko
vensko / markdown.css
Last active August 29, 2015 14:21 — forked from imjasonh/markdown.css
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
@vensko
vensko / stop_server.bat
Last active August 29, 2015 14:17
stop_server.bat
rem http://blog.vensko.net/webdev/web-server-batch-script
@echo off
tasklist /FI "IMAGENAME eq php.exe" 2>NUL | find /I /N "php.exe" >nul
if "%ERRORLEVEL%"=="0" (
echo Stopping PHP server...
taskkill /F /FI "IMAGENAME eq php.exe" 2>&1 >nul
)
tasklist /FI "IMAGENAME eq memcached.exe" 2>NUL | find /I /N "memcached.exe" >nul
@vensko
vensko / start_server.bat
Last active August 29, 2015 14:17
start_server.bat
rem http://blog.vensko.net/webdev/web-server-batch-script
@echo off
@setlocal
@setlocal enabledelayedexpansion
@cls
SET PARAMS=%*
if "!PARAMS!"=="" SET PARAMS=php
if exist "%cd%\www" SET DOCUMENT_ROOT=%cd%\www
@vensko
vensko / router.php
Last active September 27, 2017 10:57
router.php
<?php
$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$uri = urldecode($uri);
if ($uri === '/' || isset($_SERVER['SCRIPT_FILENAME']) || file_exists($_SERVER['DOCUMENT_ROOT'].$uri)) {
return false;
} else {
if (file_exists(__DIR__.$uri)) {
if (is_dir(__DIR__.$uri)) {