Skip to content

Instantly share code, notes, and snippets.

View andrewodri's full-sized avatar
😍

Andrew Odri andrewodri

😍
View GitHub Profile
@andrewodri
andrewodri / elevating.ps1
Created January 23, 2015 21:02
Self-elevating PowerShell script with administrator styling
$myWindowsID = [System.Security.Principal.WindowsIdentity]::GetCurrent();
$myWindowsPrincipal = New-Object System.Security.Principal.WindowsPrincipal($myWindowsID);
$adminRole = [System.Security.Principal.WindowsBuiltInRole]::Administrator;
Push-Location;
Set-Location HKCU:\Console;
if(!(Test-Path -Path ".\%SystemRoot%_system32_WindowsPowerShell_v1.0_powershell.exe")){
Set-Item ".\%SystemRoot%_system32_WindowsPowerShell_v1.0_powershell.exe";
}
Set-Location ".\%SystemRoot%_system32_WindowsPowerShell_v1.0_powershell.exe";
@andrewodri
andrewodri / timescreen.sh
Created January 25, 2015 08:47
Print a full-screen clock on rendered with FIGlet fonts
#!/usr/bin/zsh
#
# timescreen
#
# A script to take the date in intelligent formats and run it through figlet.
# Output should basically give you a nice full-screen clock.
#
# Version Log? - nothing to clear though...
#
# TODO's
@andrewodri
andrewodri / build-extension.sh
Created January 25, 2015 08:50
Build and install an Adobe Dreamweaver CS4 extension from a *.mxi
extensionfile=DreamweaverExtension; extensionversion=`xpath $extensionfile.mxi /macromedia-extension/@version | sed -e "s/^.*version=[\'\"]\(.*\)[\'\"].*$/\1/"`; /Applications/Adobe\ Extension\ Manager\ CS4/Adobe\ Extension\ Manager\ CS4.app/Contents/MacOS/Adobe\ Extension\ Manager\ CS4 -suppress -package mxi="$extensionfile.mxi" mxp="$extensionfile-`echo $extensionversion`.mxp"; sleep 1; /Applications/Adobe\ Extension\ Manager\ CS4/Adobe\ Extension\ Manager\ CS4.app/Contents/MacOS/Adobe\ Extension\ Manager\ CS4 -suppress -install mxp="$extensionfile-`echo $extensionversion`.mxp"
@andrewodri
andrewodri / index.jxa
Created November 29, 2017 10:37
JXA Change Tab Background
let terminal = Application("Terminal")
terminal.includeStandardAdditions = true
let defaultBackground = terminal.defaultSettings.backgroundColor
let blueBackground = defaultBackground
terminal.windows[0].selectedTab.currentSettings.backgroundColor = blueBackground
terminal.displayDialog(terminal.windows[0].selectedTab.history.toString())
@andrewodri
andrewodri / test.js
Created January 22, 2018 18:03
String concatenation versus template literals
var precalculatedIso = (new Date()).toISOString();
console.time("es6Variable");
for(var i = 0; i < 100000; i++){
var test = `<body>
<article>
<time datetime='${ precalculatedIso }'>${ precalculatedIso }</time>
</article>
</body>`;
}
@andrewodri
andrewodri / README.md
Created January 22, 2018 19:39
High resolution (i.e. printable) screenshots in Chrome
  1. Navigate to chrome://flags/#enable-use-zoom-for-dsf and change to "Enabled"
  2. Navigate to https://maps.google.com and open Developer Tools (Cmd + Alt + I)
  3. In the top left corner of the Developer Tools panel, click "Toggle device toolbar" (Cmd + Shift + M)
  4. In the top right corner of the Developer Tools panel, open the menu and select Settings (F1), then select Devices
  5. Click on the "Add Custom Device" button, and enter your desired resolution and pixel ratio:
  • Width & Height: Each dimension should be 72 * inches
  • Device pixel ration: This value should be printResolution / 72
  1. In the device toolbar, select the new device you have created
  2. Hard refresh the page
  3. In the top right corner of the device toolbar, open the menu and select Capture full size screenshot
@andrewodri
andrewodri / package.json
Last active February 11, 2018 08:53
Monkey patch to add postcss-cssnext to create-react-app
{
"name": "create-react-app-example",
"version": "0.1.0",
"private": true,
"dependencies": {
"postcss-cssnext": "^3.0.2",
"react": "^16.1.1",
"react-dom": "^16.1.1",
"react-scripts": "1.0.17"
},
@andrewodri
andrewodri / ses.sh
Created June 13, 2018 18:20
AWS SES Validator
#!/bin/bash
export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
export AWS_DEFAULT_REGION=us-east-1
aws ses send-email \
--from "valid@domain.tld" \
--destination "ToAddresses=valid@recipient.tld" \
--message "Subject={Data=AWS SES Validation,Charset=utf8},Body={Text={Data=AWS SES Validation,Charset=utf8},Html={Data=,Charset=utf8}}"
@andrewodri
andrewodri / replace-background.sh
Created September 6, 2018 23:22
Replace Lock Screen Image in macOS
#!/bin/bash
sudo cp /Library/Caches/com.apple.desktop.admin.png /Library/Caches/com.apple.desktop.admin.png.bak
sudo sips -s format png --resampleHeightWidth 1800 2880 $@ --out /Library/Caches/com.apple.desktop.admin.png
sudo chmod 644 /Library/Caches/com.apple.desktop.admin.png
sudo chown $(whoami):admin /Library/Caches/com.apple.desktop.admin.png
@andrewodri
andrewodri / install.sh
Created October 20, 2018 19:59
One-line installs for amazonlinux:1
#!/bin/bash
curl --silent --show-error --location "https://github.com/jpignata/fargate/releases/download/v0.2.3/fargate-0.2.3-linux-amd64.zip" | bsdtar -xf - -C /usr/local/bin && chmod +x /usr/local/bin/fargate
curl --silent --show-error --location "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" | bsdtar -xf - -C /tmp && chmod 755 /tmp/awscli-bundle/install && /tmp/awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws && rm -rf /tmp/awscli-bundle