Skip to content

Instantly share code, notes, and snippets.

View yoav-lavi's full-sized avatar

Yoav Lavi yoav-lavi

View GitHub Profile
@yoav-lavi
yoav-lavi / export-vscode-extensions.ps1
Last active April 30, 2018 08:09
Exports all vscode extensions to an installable script
# For use with vscode standard (non insiders) change "code-insiders" to "code"
code-insiders.cmd --list-extensions | ForEach-Object {Write-Output "code-insiders --install-extension $_"} > vscode-extension-installer.ps1
@yoav-lavi
yoav-lavi / vscode-extension-installer.ps1
Last active April 30, 2018 08:32
Installation script for (my) vscode extensions
# For use with vscode standard (non insiders) change "code-insiders" to "code"
code-insiders --install-extension 13xforever.language-x86-64-assembly
code-insiders --install-extension adamwalzer.string-converter
code-insiders --install-extension aeschli.vscode-css-formatter
code-insiders --install-extension alefragnani.Bookmarks
code-insiders --install-extension alefragnani.project-manager
code-insiders --install-extension bengreenier.vscode-node-readme
code-insiders --install-extension buianhthang.xml2json
code-insiders --install-extension castwide.solargraph
code-insiders --install-extension christian-kohler.path-intellisense
@yoav-lavi
yoav-lavi / .hyper.js
Last active April 30, 2018 08:33
(my) Hyper.js Windows config
// https://hyper.is#cfg
module.exports = {
config:
{
updateChannel: 'stable',
// Fonts
fontFamily: 'Consolas',
fontSize: 14,
@yoav-lavi
yoav-lavi / Elevate.ps1
Created April 30, 2018 08:36
Elevation function for PowerShell scripts
function Elevate {
Param ($Path)
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator') `
-And [int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000)
{
$CommandLine = "-File `"$Path`""
Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
Exit
}
}
@yoav-lavi
yoav-lavi / Remote Debugger (System).bat
Last active December 20, 2018 14:01
Run VS2017 remote debugger as the system session, even if no prerequisites are installed
@echo off
:: BatchGotAdmin
:-------------------------------------
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
@yoav-lavi
yoav-lavi / test.js
Created October 13, 2019 19:52
Scriptable describe + test
exports.describe = async (name, callback) => {
const output = [];
const test = async (name, callback) => {
const testStartTime = Date.now();
const testResult = await callback();
const testTime =
Date.now() - testStartTime;
output.push(
`• ${name} (${testTime}ms): ${
testResult ? '✅' : '❌'
@yoav-lavi
yoav-lavi / store.test.js
Created October 15, 2019 18:06
Tests for store.js
const createStore = importModule('store');
const { describe } = importModule('test');
const store = createStore('store-test');
await describe('Store', async test => {
const key = 'key';
const value = 'value';
await test('Saves and retrieves a value', async () => {
store.set(key, value);
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: green; icon-glyph: file-code;
const getModule = importModule("getModule");
const documentDirectory = FileManager.iCloud().documentsDirectory();
module.exports = async ({ moduleName, url, forceDownload = false }) => {
if (moduleExists(moduleName) && !forceDownload) {
return importModule(moduleName);
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: green; icon-glyph: file-code;
const getString = importModule('getString');
const documentDirectory = FileManager.iCloud().documentsDirectory();
const header = `// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: deep-gray; icon-glyph: file-code;`;
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: green; icon-glyph: file-code;
module.exports = async ({ url, headers = {} }) => {
const request = new Request(url);
request.method = methods.get;
request.headers = {
...headers
};
return await request.loadString();