Instantly share code, notes, and snippets.

View single-file-api.php
<?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');
View App.ts
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({
View .chromerc.js
// ==UserScript==
// @name .chromerc
// @namespace *
// @version 0.1
// @description Utils for debugging
// @author You
// @match *
// @grant none
// ==/UserScript==
View Watchdog.ps1
# 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...";
View DownloadJSONObj.js
// 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();
View windows-identity-add.sh
#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
View background.cmd
@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
View staff.agent.yaml
#
# This is popup help messages for the Admin Panel -> Staff -> Add Staff Form
#
# Fields:
# title - Shown in bold at the top of the popover window
# content - The body of the help popover
# links - List of links shows below the content
# title - Link title
# href - href of link (links starting with / are translated to the
# helpdesk installation path)