Skip to content

Instantly share code, notes, and snippets.

Jonathan Ling colonelpopcorn

Block or report user

Report or block colonelpopcorn

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@colonelpopcorn
colonelpopcorn / single-file-api.php
Created Oct 5, 2018
This is dumb and I like it way more than I should.
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');
@colonelpopcorn
colonelpopcorn / App.ts
Created Aug 18, 2018
Parcel problem with hot-reloading
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...";
@colonelpopcorn
colonelpopcorn / DownloadJSONObj.js
Last active Aug 10, 2018
Great little function to download a javascript object as a JSON file.
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();
@colonelpopcorn
colonelpopcorn / windows-identity-add.sh
Created Nov 29, 2016
Loops through an array of paths to ssh keys and adds them to the agent in a git bash for windows session. Still requires passwords.
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
@colonelpopcorn
colonelpopcorn / background.cmd
Created Jun 4, 2016
Command script to change login screen background on Windows 7
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
@colonelpopcorn
colonelpopcorn / staff.agent.yaml
Created Oct 26, 2015
yaml file with role filled in
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)
You can’t perform that action at this time.