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 / gist:2583811
Created May 3, 2012 06:34
Repetitive Click One-line Script
a='.js-action-dismiss';c=function(){if($(a).length){setTimeout(c,1000);$(a).click();}};c();
@ctrl-freak
ctrl-freak / gist:2593530
Created May 4, 2012 09:17
PHP User-input Sanitation and Defaults
<?
// Usage: search($_GET);
function search($args) {
$vars = array(
'order_by' => 'date',
'order' => 'DESC',
)
@ctrl-freak
ctrl-freak / gist:2817155
Created May 28, 2012 04:07
jQuery Validation Required Fields CSS Styling
input {
border: 1px solid #CCCCCC;
padding-left: 2px;
}
*[class*="validate[required"] {
border-left: 3px solid #F9A608;
padding-left: 0px;
}
@ctrl-freak
ctrl-freak / gist:2880578
Created June 6, 2012 08:09
Check Whether PHP Array is Indexed or Associative
<? // http://stackoverflow.com/a/4254008/348146
function is_assoc($array) {
return (bool)count(array_filter(array_keys($array), 'is_string'));
}
// function assumes:
// 1. is_array($array) == true
// 2. if there is at least one string key, $array will be regarded as associative array
@ctrl-freak
ctrl-freak / gist:3168078
Created July 24, 2012 04:41
Working HTML maxlength on <textarea> Using jQuery
$(document).ready(function(e){
$('textarea[maxlength]').keydown(function(){
if ($(this).val().length > $(this).attr('maxlength')) {
e.preventDefault();
}
});
});
@ctrl-freak
ctrl-freak / jquery.bt.min.js
Created November 2, 2012 04:19
Automatically Instantiate BeautyTips for Help Content (Degrades Nicely)
<script type="text/javascript" src="/js/jquery.bt.min.js"></script>
<style type="text/css">
.help-link {
padding-left: 18px;
background-position: center left;
background-repeat: no-repeat;
text-indent: -9001px;
display: block;
@ctrl-freak
ctrl-freak / gist:4044194
Created November 9, 2012 07:18
Conditional Supersized Background Image using Modernizr
<link rel="stylesheet" href="/css/supersized.core.css" type="text/css" media="screen" />
<script type="text/javascript" src="/js/supersized.3.1.1.min.js"></script>
<script type="text/javascript">
$(document).ready( function(){
if ($('html:not(.multiplebgs)').length) {
jQuery.supersized({ slides : [{image : '/images/site-bg.jpg'}]});
}
}
</script>
@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];
@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 / android-adb-pull-apk.md
Last active August 28, 2025 23:00
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.