Skip to content

Instantly share code, notes, and snippets.

View ctrl-freak's full-sized avatar

Bryce Sheehan ctrl-freak

View GitHub Profile
@ctrl-freak
ctrl-freak / index.php
Created April 25, 2017 05:08
EVE Simple CREST Cache
<?
ini_set('max_execution_time', 60);
set_time_limit(60);
error_reporting(0);
$options = array(
'base_url' => 'https://public-crest.eveonline.com',
'cache_expiry' => 1200
)
$filename = 'cache-'.md5($_SERVER['REQUEST_URI']);
if (!file_exists($filename)) {
# By dastylinrastan
# https://www.reddit.com/r/PowerShell/comments/5n5aux/way_to_tell_how_long_the_last_command_took_to_run/dc8umh2/
# Chocolatey profile
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
if (Test-Path($ChocolateyProfile)) {
Import-Module "$ChocolateyProfile"
}
#Justin's Powershell Prompt
@ctrl-freak
ctrl-freak / gist:9abb5aea0d89d7bd9df6a3d0ac08b73c
Created November 2, 2016 01:18
Android ADB `adb shell input keyevent` Codes
// http://stackoverflow.com/questions/7789826/adb-shell-input-events
0 --> "KEYCODE_0"
1 --> "KEYCODE_SOFT_LEFT"
2 --> "KEYCODE_SOFT_RIGHT"
3 --> "KEYCODE_HOME"
4 --> "KEYCODE_BACK"
5 --> "KEYCODE_CALL"
6 --> "KEYCODE_ENDCALL"
7 --> "KEYCODE_0"
@ctrl-freak
ctrl-freak / Copy-ADUser-ADGroups.ps1
Created July 20, 2016 08:21
Copy Active Directory Groups from User to User
Function Write-Log($string) {
$timestamp = Get-Date -Format "s"
Write-Host "[$timestamp]"$string
}
Write-Log "Importing ActiveDirectory PowerShell module"
Import-Module ActiveDirectory
[void] [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.VisualBasic.Interaction")
Write-Log "Requesting credentials"
@ctrl-freak
ctrl-freak / trackit_wallboard.sql
Created July 15, 2016 02:43
BMC Track-It Wallboard SQL Queries
-- Today
SELECT
COUNT(*)
FROM dbo.TASKS
WHERE
WorkOrderStatusId <> 2
AND WorkOrderStatusId <> 101
AND WorkOrderTypeId = 0
AND DUEDATE < (CAST(DATEADD(day, 1, GETDATE()) AS DATE))
AND RESPONS IN ('ICT Support');
@ctrl-freak
ctrl-freak / write-log.ps1
Last active August 2, 2017 01:05
PowerShell Output Timestamping: Write-Log
Function Write-Log($string, $color) {
# Colors: [enum]::GetValues([System.ConsoleColor]) | Foreach-Object {Write-Host $_ -ForegroundColor $_}
$timestamp = Get-Date -Format "s"
$oldFGcolor = $host.ui.RawUI.ForegroundColor
if ($color -ne $null) {
$host.ui.RawUI.ForegroundColor = $color
Write-Output ("["+$timestamp+"] " + $string)
$host.ui.RawUI.ForegroundColor = $oldFGcolor
} else {
Write-Output ("["+$timestamp+"] " + $string)
@ctrl-freak
ctrl-freak / CodeCompletionCode.php
Last active June 2, 2016 13:19
Code completion without root namespaces for Netbeans/PHPStorm
<?php
/*
by: HiroKws
Generate list of Class names so code completion works in Netbeans/PHPStorm without the whole namespace
http://fuelphp.com/forums/discussion/7283/functions-code-completion-on-netbeans-and-also-phpstorm
on windows, open cmd.exe , type 'php oil r ccc' to help. On linux, open terminal , type 'oil r ccc' to help. (I didn't test this code on linux. ) The best and simplest way to use this, 'php oil -all -without=tasks+migrations+vendor+tests+oil+orm+parser' and check output. When no proble on generated code, redirect it php file like 'php oil -all -without=tasks+migrations+vendor+tests+oil+orm+parser > CodeCompletionCode.php' As you know, you can put this code anywhere under sorce code folder on your project. If you use NetBeans, can put it into nbproject directory, it is default general include folder. If you can't use oil well, use this code for FuelPHP 1.1. But the best way is run this on your FuelPHP installed environment.
@ctrl-freak
ctrl-freak / android-adb-pull-apk.md
Last active April 9, 2024 11:31
Retrieve APK from Non-Rooted Android Device through ADB

https://stackoverflow.com/a/18003462/348146

None of these suggestions worked for me, because Android was appending a sequence number to the package name to produce the final APK file name (this may vary with the version of Android OS). The following sequence of commands is what worked for me on a non-rooted device:

  1. Determine the package name of the app, e.g. com.example.someapp. Skip this step if you already know the package name.

    adb shell pm list packages

    Look through the list of package names and try to find a match between the app in question and the package name. This is usually easy, but note that the package name can be completely unrelated to the app name. If you can't recognize the app from the list of package names, try finding the app in Google Play using a browser. The URL for an app in Google Play contains the package name.

@ctrl-freak
ctrl-freak / hosts.bat
Last active February 11, 2016 06:08
Edit HOSTS file in elevated Notepad
rem Store this in system32 or a %PATH% location and use from Run: "hosts"
rem Using http://code.kliu.org/misc/elevate/ in a %PATH% location
elevate notepad %WINDIR%\system32\drivers\etc\hosts
@ctrl-freak
ctrl-freak / functions.php
Created October 7, 2013 06:33
Wordpress Theme-based Camouflage
<?
/**
* 'Fix' Stylesheet URLs
*/
function intranet_short_css($args = '') {
$parts = explode('/', $args);
return '/css/'.$parts[count($parts)-1];
// return '/css/'.$args[0];