Skip to content

Instantly share code, notes, and snippets.

View angel-vladov's full-sized avatar

Angel Vladov angel-vladov

View GitHub Profile
@angel-vladov
angel-vladov / powershell-net.ps1
Last active January 9, 2024 15:41
PowerShell function you can use for reading UTF8 encoded HTML pages content. The built in Invoke-WebRequest and Invoke-RestMethod fail miserably.
function Read-HtmlPage {
param ([Parameter(Mandatory=$true, Position=0, ValueFromPipeline=$true)][String] $Uri)
# Invoke-WebRequest and Invoke-RestMethod can't work properly with UTF-8 Response so we need to do things this way.
[Net.HttpWebRequest]$WebRequest = [Net.WebRequest]::Create($Uri)
[Net.HttpWebResponse]$WebResponse = $WebRequest.GetResponse()
$Reader = New-Object IO.StreamReader($WebResponse.GetResponseStream())
$Response = $Reader.ReadToEnd()
$Reader.Close()
@angel-vladov
angel-vladov / Greasemonkey-jq-boilerplate.js
Created January 28, 2014 12:00
Boilerplate code for a Greasemonkey script which reuses the jQuery from the page it's attached to.
var jQuery, $ = null;
function addJQuery(callback) {
var p = null;
if(window.opera || window.navigator.vendor.match(/Google/)) {
var div = document.createElement("div");
div.setAttribute("onclick", "return window;");
p = div.onclick();
}
@angel-vladov
angel-vladov / Sublime-eclipse-keymap.json
Last active January 4, 2016 14:18
Eclipse Keybindings for Sublime Text 2
[
{ "keys": ["shift+enter"], "command": "run_macro_file", "args": {"file": "Packages/Default/Add Line.sublime-macro"} },
{ "keys": ["alt+up"], "command": "swap_line_up" },
{ "keys": ["alt+down"], "command": "swap_line_down" },
{ "keys": ["ctrl+alt+j"], "command": "join_lines" },
{ "keys": ["ctrl+alt+down"], "command": "duplicate_line" },
{ "keys": ["shift+ctrl+r"], "command": "show_overlay", "args": {"overlay": "goto", "show_files": true} },
{ "keys": ["ctrl+shift+s"], "command": "save_all" },
{ "keys": ["ctrl+l"], "command": "show_overlay", "args": {"overlay": "goto", "text": ":"} },
{ "keys": ["shift+ctrl+f4"], "command": "close_all" },
@angel-vladov
angel-vladov / onBeforePrint.js
Last active May 10, 2018 12:18
AngularJS 1 on before print directive
/**
* AngularJS example directive.
* Allows you to modify the page DOM and CSS styles before printing by exexuting the passed expression.
* Will force a $digest phase before the print operation.
*
* Example: <div ng-class="{printed: isPrinted}" on-before-print="printed = true" />
*/
module.directive('onBeforePrint', ['$window', '$rootScope', '$timeout', function onBeforePrint($window, $rootScope, $timeout) {
var beforePrintDirty = false;
var listeners = [];