Skip to content

Instantly share code, notes, and snippets.

@wildlarva
wildlarva / udp-port-forwarding.ps1
Last active October 4, 2024 08:15
WSL Port Forwarding Example for UDP
#--------------------------------------------------------
# Background: WSL UDP port forwarding
#--------------------------------------------------------
# Microsoft recommends "netsh interface portproxy" for port forwarding, but it does not support UDP for now.
# See https://learn.microsoft.com/en-us/windows/wsl/networking#accessing-a-wsl-2-distribution-from-your-local-area-network-lan.
# For UDP port forwarding, you can use Windows NAT mechanism.
# See https://gist.github.com/the-moog/e7a1b5150ce9017309afbcf91848e622.
@loopyd
loopyd / Get-HashEx.psm1
Last active May 1, 2024 17:23
[PowerShell 7] Get-HashEx - All-in-one file and folder hashing module for Windows PowerShell 7.0+
<#
.Synopsis
Hash a file or a folder via the lifestrea- er I mean, bytestream. Then return the results.
.Description
I improved Get-FileHash just a bit. Hash a file or a folder via the lifestrea- er I mean,
bytestream. Then returns the results. A lot of options, and what ever supported, hardware
accelerated CryptoStream HashAlgorithm provider you want. Also with real time progress,
which you can turn off if you want.
@adimancv
adimancv / css_dark_mode_gist_embed_code.css
Last active November 4, 2024 15:22
CSS Dark Mode Gist Embed Code
/*!
* Gist DarkCode ver 0.2.1
* Update 03/12/2021 www.adiman.web.id
*/
.gist{font-size: 18px}.gist-meta, .gist-file, .octotree_toggle, ul.comparison-list > li.title,button.button, a.button, span.button, button.minibutton, a.minibutton,span.minibutton, .clone-url-button > .clone-url-link{background: linear-gradient(#202020, #181818) !important;border-color: #383838 !important;border-radius: 0 0 3px 3px !important;text-shadow: none !important;color: #b5b5b5 !important}.markdown-format pre, .markdown-body pre, .markdown-format .highlight pre,.markdown-body .highlight pre, body.blog pre, #facebox pre, .blob-expanded,.terminal, .copyable-terminal, #notebook .input_area, .blob-code-context,.markdown-format code, body.blog pre > code, .api pre, .api code,.CodeMirror,.highlight{background-color: #1D1F21!important;color: #C5C8C6!important}.gist .blob-code{padding: 1px 10px !important;text-align: left;background: #000;border: 0}::selection{background: #24890d;color: #fff;text-shadow: none}::-moz-selection{background:
@davidjenni
davidjenni / cidrToIpRange.ps1
Created January 7, 2020 18:08
CIDR to IP range conversion using PowerShell
# calculate IP address range from CIDR notation
# https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing
function cidrToIpRange {
param (
[string] $cidrNotation
)
$addr, $maskLength = $cidrNotation -split '/'
[int]$maskLen = 0
@alecos71
alecos71 / Fix-Curl-SQLite3-in-PHP-7.4-under-Windows.md
Last active December 16, 2023 02:46
How to fix errors generated by PHP 7.4 related to CURL & SQLite3 under Windows

Fix for CURL & SQLite3 under Windows on PHP 7.4

If you have just downloaded and configured PHP 7.4 and you want to use CURL and SQLite3 you could run into a serious PHP-generated error for the reason that both CURL and SQlite3 make use of an external library located in the PHP directory. First SQLite3 was integrated into PHP but from version 7.4 no longer. The errors are these:

PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_sqlite'

PHP Warning: PHP Startup: Unable to load dynamic library 'sqlite3'

PHP Warning: PHP Startup: Unable to load dynamic library 'php_curl'

@AlexR1712
AlexR1712 / checkSession.php
Last active November 1, 2022 01:43 — forked from lukas-buergi/checkSession.php
Check whether sessions work in php
<?php
error_reporting( E_ALL );
ini_set( 'display_errors', 1);
if(!isset($_GET['action'])){
die('Param is missing. Look at the <a href="https://gist.github.com/2995743">source</a>.');
}
switch($_GET['action']) {
@jasondewitt
jasondewitt / headers.php
Created May 9, 2016 21:58
dump all headers in php
<?php
if (!function_exists('getallheaders')) {
function getallheaders()
{
if (!is_array($_SERVER)) {
return array();
}
$headers = array();
@thorsten
thorsten / setUserAgent.js
Created May 9, 2016 15:12
Override user agent on all browsers
function setUserAgent(window, userAgent) {
// Works on Firefox, Chrome, Opera and IE9+
if (navigator.__defineGetter__) {
navigator.__defineGetter__('userAgent', function () {
return userAgent;
});
} else if (Object.defineProperty) {
Object.defineProperty(navigator, 'userAgent', {
get: function () {
return userAgent;
@jsxinvivo
jsxinvivo / convertCharArrayToLPCWSTR.cpp
Created October 6, 2015 13:18
convert char* to LPCWSTR
wchar_t *convertCharArrayToLPCWSTR(const char* charArray)
{
wchar_t* wString=new wchar_t[4096];
MultiByteToWideChar(CP_ACP, 0, charArray, -1, wString, 4096);
return wString;
}
@lukas-buergi
lukas-buergi / checkSession.php
Created June 26, 2012 13:18
Check whether sessions work in php
<?php
error_reporting( E_ALL );
ini_set( 'display_errors', 1);
if(!isset($_GET['action'])){
die('Param is missing. Look at the <a href="https://gist.github.com/2995743">source</a>.');
}
switch($_GET['action']) {