Skip to content

Instantly share code, notes, and snippets.

View JimWolff's full-sized avatar

Jim Wolff JimWolff

  • CYBER1UP ApS
  • Denmark
View GitHub Profile
@paulirish
paulirish / what-forces-layout.md
Last active April 19, 2024 14:42
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@GiscardBiamby
GiscardBiamby / configure-iis-httpCompression.ps1
Last active November 14, 2017 11:45
PowerShell snippet for configuring <system.webServer><httpCompression>. Using this in the startup script for an Azure Cloud Service.
[xml]$config = (& "$env:WINDIR\system32\inetsrv\appcmd.exe" list config /section:httpCompression)
if ($config -ne $null -and ($config.GetElementsByTagName("httpCompression") -ne $null)) {
$compression = $config.GetElementsByTagName("httpCompression")[0]
$dynamic = $compression.dynamicTypes
EnableCompression $dynamic "dynamicTypes" "application/x-javascript"
EnableCompression $dynamic "dynamicTypes" "application/atom+xml"
}
@rberrelleza
rberrelleza / UseServiceBusFromPowershell.ps1
Created March 27, 2012 23:55
Send and receive messages to a Service Bus queue via PowerShell
Import-Module "PATH_TO_Microsoft.ServiceBus.dll"
#Create the required credentials
$tokenProvider = [Microsoft.ServiceBus.TokenProvider]::CreateSharedSecretTokenProvider("owner", "YOUR_ISSUERSECRET")
$namespaceUri = [Microsoft.ServiceBus.ServiceBusEnvironment]::CreateServiceUri("sb", "YOUR_NAMESPACE", "");
$namespaceManager = New-Object Microsoft.ServiceBus.NamespaceManager $namespaceUri,$tokenProvider
#Create a queue
$queue = $namespaceManager.CreateQueue("MyPowershellQueue");
@beccasaurus
beccasaurus / README.markdown
Created May 5, 2011 19:37
Adds hooks to jQuery.validate's form/element validation methods (via trigger())

jQuery Validate Hooks

If you're using [ASP.NET MVC3][], it uses [jQuery Validate][] to do client-side validations. Instead of using [jQuery Validate][] directly, however, it wraps it with its own jQuery plugin called [jQuery.Validate.Unobtrusive][]. [jQuery.Validate.Unobtrusive][] sets up [jQuery Validate][] for you, behind the scenes, so you don't have an opportunity to customize your [jQuery Validate][] settings at all!

We've been running into trouble with this when we've been doing our own custom client-side validations. We need a way to integrate with the build-in [ASP.NET MVC3][] validation so we can:

// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}