Skip to content

Instantly share code, notes, and snippets.

View betterversion's full-sized avatar

Dmitriy Zhernoviy betterversion

  • Chicago
View GitHub Profile
@betterversion
betterversion / Log-.md
Created November 21, 2019 19:23 — forked from bgrins/Log-.md
Prevent errors on console methods when no console present and expose a global 'log' function.

Javascript log Function

Every time I start a new project, I want to pull in a log function that allows the same functionality as the console.log, including the full functionality of the Console API.

There are a lot of ways to do this, but many are lacking. A common problem with wrapper functions is that the line number that shows up next to the log is the line number of the log function itself, not where log was invoked. There are also times where the arguments get logged in a way that isn't quite the same as the native function.

This is an attempt to once and for all document the function that I pull in to new projects. There are two different options:

  • The full version: Inspired by the plugin in HTML5 Boilerplate. Use this if you are writing an application and want to create a window.log function. Additionally,
@betterversion
betterversion / boxstarter.ps1
Created August 20, 2019 22:58 — forked from jessfraz/boxstarter.ps1
Boxstarter Commands for a new Windows box.
# Description: Boxstarter Script
# Author: Jess Frazelle <jess@linux.com>
# Last Updated: 2017-09-11
#
# Install boxstarter:
# . { iwr -useb http://boxstarter.org/bootstrapper.ps1 } | iex; get-boxstarter -Force
#
# You might need to set: Set-ExecutionPolicy RemoteSigned
#
# Run this boxstarter by calling the following from an **elevated** command-prompt:
import jenkins.*
import jenkins.model.*
class Environment{
def static void write(name, value){
def instance = Jenkins.getInstance()
def globalProps = hudson.model.Hudson.instance.globalNodeProperties
def props = globalProps.getAll(hudson.slaves.EnvironmentVariablesNodeProperty.class)
for (prop in props) {
function Get-Uptime {
$os = Get-WmiObject win32_operatingsystem
$uptime = (Get-Date) - ($os.ConvertToDateTime($os.lastbootuptime))
Write-Host "$(Get-Date -Format 'HH:MM') up $(($uptime).Days) days, $(($uptime).Hours):$(($uptime).Minutes)"
}
function Set-EnvironmentVariable {
param(
[Parameter(Mandatory=$true)][string]$VariableName,
[Parameter(Mandatory=$true)][string]$VariableValue
)
$Changed = $False
$InitialValue = [Environment]::GetEnvironmentVariable("$VariableName", "Machine")
function Execute-Main{
$Paths = @(
'C:\Program Files\Notepad++',
'C:\Program Files (x86)\Notepad++',
'C:\Program Files (x86)\WinDirStat',
'C:\Program Files\WinDirStat'
)
Disable-ServerManager
foreach ($Path in $Paths) {
function Add-EnvPath {
param(
[Parameter(Mandatory=$true)][string]$NewPath,
[ValidateSet('Machine', 'User', 'Session')][string]$Level = 'Machine'
)
$Changed = $False
if ($Level -ne 'Session') {
$LevelType = [EnvironmentVariableTarget]::$Level
function Logoff-User {
param(
[Parameter(Mandatory=$true)][string]$UserName,
[string]$Server = 'localhost'
)
$sessionId = ((quser /server:$Server | Where-Object { $_ -match $UserName }) -split ' +')[2]
logoff $sessionId /server:$Server
}
# Written by: Robert J.
# Robert@scriptmyjob.com
function Invoke-RDP {
param(
[Parameter(Mandatory=$true)][string]$ConnectionString
)
Start-Process `
"$env:windir\system32\mstsc.exe" `
# Written by: Robert J.
# Robert@scriptmyjob.com
function Get-LargestFiles {
<#
.SYNOPSIS
Retrieves the largest files under a specific directory.
.DESCRIPTION
This commandlet will get the largest files in the current directory if no Path is specified.