This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$content = Get-Content "./.env"; | |
$contentArr = $content.Trim().Split([Environment]::NewLine); | |
ForEach-Object -InputObject $contentArr { | |
$keyValPair = $_.Split("=", 2); | |
$key = $keyValPair[0].Trim(); | |
$val = $keyValPair[1].Trim(); | |
$envSign = '$env:' | |
$afterEnvSign = "$key=$val" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const tryWithDefault = <T>(func: () => T, defaultVal: T): T => { | |
try { | |
return func(); | |
} catch (e) { | |
// Log or do something here. | |
// logger.error(e); | |
return defaultVal; | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// get the HTTP method, path and body of the request | |
$method = $_SERVER['REQUEST_METHOD']; | |
$request = explode('/', trim($_SERVER['PATH_INFO'],'/')); | |
$input = json_decode(file_get_contents('php://input'),true); | |
// connect to the mysql database | |
$link = mysqli_connect('localhost', 'user', 'pass', 'dbname'); | |
mysqli_set_charset($link,'utf8'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vue from 'vue'; | |
import Vuetify from 'vuetify'; | |
import 'vuetify/dist/vuetify.min.css'; | |
import 'material-design-icons-iconfont/dist/material-design-icons.css'; | |
import App from './App.vue'; | |
Vue.use(Vuetify); | |
Vue.config.productionTip = false; | |
new Vue({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name .chromerc | |
// @namespace * | |
// @version 0.1 | |
// @description Utils for debugging | |
// @author You | |
// @match * | |
// @grant none | |
// ==/UserScript== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://stackoverflow.com/questions/12319382/file-system-watcher-event-when-run-using-a-script#12323930 | |
$watcher = new-object System.IO.FileSystemWatcher | |
$watcher.Path = '.\' | |
$watcher.Filter = '*.js' # whatever you need | |
#$watcher.IncludeSubDirectories = $true # if needed | |
$watcher.EnableRaisingEvents = $true | |
Register-ObjectEvent $watcher -EventName Changed -SourceIdentifier 'Watcher' -Action { param($sender, $eventArgs) | |
Write-Host "Detected change in files copying..."; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Great little function to download a javascript object as a JSON file. Found here: | |
// https://stackoverflow.com/questions/19721439/download-json-object-as-a-file-from-browser | |
function downloadObjectAsJson(exportObj, exportName){ | |
var dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(exportObj)); | |
var downloadAnchorNode = document.createElement('a'); | |
downloadAnchorNode.setAttribute("href", dataStr); | |
downloadAnchorNode.setAttribute("download", exportName + ".json"); | |
downloadAnchorNode.click(); | |
downloadAnchorNode.remove(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#declares an array of keys to loop through and add to the ssh-agent, run before a git bash session on windwows. | |
#bin/sh | |
declare -a keys=("/c/users/jonathan/path/to/key" "/c/users/jonathan/path/to/other/key") | |
eval $(ssh-agent -s) | |
for i in "${keys[@]}"; do | |
ssh-add "$i" | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
SET SOURCE=%~dp0% | |
SET DESTINATION=C:\Windows\System32\oobe\info\backgrounds | |
REG ADD HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background /f /v OEMBackground /t REG_DWord /d 0x00000001 | |
IF NOT EXIST "%DESTINATION%" MKDIR "%DESTINATION%" | |
copy %SOURCE%\backgroundDefault.jpg %DESTINATION% | |
pause |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
something |
NewerOlder