Skip to content

Instantly share code, notes, and snippets.

View SmugZombie's full-sized avatar

Ron Egli SmugZombie

View GitHub Profile
function getLocalStorage(name){
var now = parseInt(new Date() / 1000);
var expires = localStorage.getItem(name+"_expire");
if(!expires){ return localStorage.getItem(name); }
else if(now >= expires){ localStorage.removeItem(name+"_expire"); localStorage.removeItem(name); return ""; }
else{ return localStorage.getItem(name); }
}
function setLocalStorage(name, value, minutes){
if(minutes == null){ localStorage.setItem(name, value); localStorage.removeItem(name+"_expire"); return true} // No set expiration
#!/usr/bin/python
# A simple python script to create new issues in GIT for a specific repo
# Ron Egli
# github.com/smugzombie
import json
import urllib2
import argparse
repo_owner = ''
// Converts a UTC timezone to a GMT - or + timezone - github.com/smugzombie
// Accepts a timestamp like this: Y-m-d H:i:s
// And a timezone like this: (0,1,8,-8,-12)
// Example $time_out = convertTimestamp("2016-05-16 20:13:44","-7"); // 2016-05-16 21:13:44
function convertTimestamp($time_in, $time_zone){
$time_zone = floatval($time_zone); //Ensure Timezone is a number, if not replace with 0 (UTC)
if(strpos($time_zone, "-") === false){$modifier = "+";}else{ $modifier = "";} //See if modifier is needed, add + if positive
$time_out = date('Y-m-d H:i:s',strtotime("$time_in $modifier$time_zone hour")); // Convert
$tz = "GMT $modifier$time_zone";
?php
// Simple Proxy script created to manage Cisco Devices in a different vlan. Uses Basic Auth
// github.com/smugzombie
$username = "";
$password = "";
$url = $_GET['url'];
if(!$url){ echo "<form action='/proxy/' method='get'>URL: <input type='text' name='url'/> <button>Go</button></form>"; return;}
$ch = curl_init();
OneDirectoryUp(path){
parts := StrSplit(path, "\")
result := ""
Loop % parts.MaxIndex() - 1
{
if(StrLen(result)) {
result .= "\"
}
result .= parts[A_Index]
}
;ComObjError(false)
;AccessMask: 2032127 = FULL | 1179817 = READ | 1179958 = WRITE | 1245631 = CHANGE
;Flags: 0 = This folder only | 1 = This folder and files | 2 = This folder and subfolders | 3 = This folder, subfolders and files
;Examples
SetSecurityRegister("HKLM\Software\Test", "S-1-1-0", "2032127")
SetSecurityFile("C:\Temp", "S-1-1-0", "1179817", "3")
ExitApp
Process_Suspend(PID_or_Name){
PID := (InStr(PID_or_Name,".")) ? ProcExist(PID_or_Name) : PID_or_Name
h:=DllCall("OpenProcess", "uInt", 0x1F0FFF, "Int", 0, "Int", pid)
If !h
Return -1
DllCall("ntdll.dll\NtSuspendProcess", "Int", h)
DllCall("CloseHandle", "Int", h)
}
Process_Resume(PID_or_Name){
function getHost($Address) {
$parseUrl = parse_url(trim($Address));
return trim($parseUrl['host'] ? $parseUrl['host'] : array_shift(explode('/', $parseUrl['path'], 2)));
}
getHost("example.com"); // Gives example.com
getHost("http://example.com"); // Gives example.com
getHost("www.example.com"); // Gives www.example.com
getHost("http://example.com/xyz"); // Gives example.com
; Allows you to tail a file providing the path
Tail(k,file) ; Return the last k lines of file
{
Loop Read, %file%
{
i := Mod(A_Index,k)
L%i% = %A_LoopReadLine%
}
L := L%i%
<?php
// Its recommended to place this in a file that is then included in all subsequent files,
// as without this information the page will not be able to access the proper session.
session_name("2620368ghwahw90w"); // Set to whatever arbitrary value you would like. The more complex the more secure
session_set_cookie_params(0, '/', '.mydomain.com'); // Set to the base level of the domain you wish to use
session_start(); // Start the session