Skip to content

Instantly share code, notes, and snippets.

View code-atom's full-sized avatar
🏠
Working from home

Ankit Rana code-atom

🏠
Working from home
View GitHub Profile
@emptyother
emptyother / Guid.ts
Last active July 4, 2023 21:00
GUID class for Typescript
class Guid {
public static newGuid(): Guid {
return new Guid(crypto.randomUUID());
// Old IE supported way:
/*return new Guid('xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
const r = Math.random() * 16 | 0;
const v = (c == 'x') ? r : (r & 0x3 | 0x8);
return v.toString(16);
}));*/
@aniston
aniston / Get-ScriptPath.ps1
Last active March 5, 2023 07:36 — forked from glombard/Get-ScriptPath.ps1
Use different techniques to determine a PowerShell script's directory: try `$PSScriptRoot`, `$MyInvocation.MyCommand.Path`, `$ExecutionContext.SessionState.Module.Path` and `$PWD`.
function Get-ScriptPath {
$scriptDir = Get-Variable PSScriptRoot -ErrorAction SilentlyContinue | ForEach-Object { $_.Value }
if (!$scriptDir) {
if ($MyInvocation.MyCommand.Path) {
$scriptDir = Split-Path $MyInvocation.MyCommand.Path -Parent
}
}
if (!$scriptDir) {
if ($ExecutionContext.SessionState.Module.Path) {
$scriptDir = Split-Path (Split-Path $ExecutionContext.SessionState.Module.Path)
@donaldgray
donaldgray / setHeader.ps1
Created November 7, 2016 09:16
Powershell script for setting IIS header
$PSPath = 'MACHINE/WEBROOT/APPHOST/' + $WebsiteName
$Filter = 'system.webServer/httpProtocol/customHeaders'
# Ensure working with IIS 7 and 7.5(+?)
try {
Add-PSSnapin WebAdministration
}
catch {
try {
Import-Module WebAdministration
@code-atom
code-atom / ScrollHandler.js
Created October 24, 2016 13:06
Best Practice of use Scroll event in application
var timer = null;
var scrollEvent = function () {
if(timer!=null)
clearTimeout(timer);
timer = setTimeout(function(){
console.log('hello');
}, 100);
}