Skip to content

Instantly share code, notes, and snippets.

View thunsaker's full-sized avatar
💻
Always Working

Thomas Hunsaker thunsaker

💻
Always Working
View GitHub Profile
@thunsaker
thunsaker / C Mobile Browser Redirect.cs
Created February 11, 2011 16:54
C# Code to detect most mobile browsers and redirect to another page.
string u = Request.ServerVariables["HTTP_USER_AGENT"];
Regex b = new Regex(@"android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|symbian|treo|up\\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino", RegexOptions.IgnoreCase | RegexOptions.Multiline);
Regex v = new Regex(@"1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\\-(n|u)|c55\\/|capi|ccwa|cdm\\-|cell|chtm|cldc|cmd\\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\\-s|devi|dica|dmob|do(c|p)o|ds(12|\\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\\-|_)|g1 u|g560|gene|gf\\-5|g\\-mo|go(\\.w|od)|gr(ad|un)|haie|hcit|hd\\-(m|p|t)|hei\\-|hi(pt|ta)|hp( i|ip)|hs\\-c|ht(c(\\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\\-(20|go|ma)|i230|iac( |\\-|\\/)|ibro|idea|ig01|ikom|im
@thunsaker
thunsaker / miloshadzic-alt.zsh-theme
Created November 19, 2019 06:54
Alternate Version of the Miloshadzic zsh theme
# Yay! High voltage and arrows!
ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[yellow]%}⚡%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN=""
PROMPT='%{$fg[cyan]%}%1~%{$reset_color%}%{$fg[red]%}|%{$reset_color%}$(git_prompt_info)%{$fg[cyan]%}⇒%{$reset_color%} '
@thunsaker
thunsaker / .slate
Last active February 11, 2019 16:57
Slate config that doesn't take over all of my keyboard shortcuts.
# Slate: https://github.com/jigish/slate
config defaultToCurrentScreen true
config nudgePercentOf screenSize
config resizePercentOf screenSize
# Push Bindings
bind right:ctrl;cmd push right bar-resize:screenSizeX/2
bind left:ctrl;cmd push left bar-resize:screenSizeX/2
bind up:ctrl;cmd push up bar-resize:screenSizeY
@thunsaker
thunsaker / LineEntry.cs
Last active September 17, 2018 10:53 — forked from davidtavarez/LineEntry.cs
Xamarin.Forms Entry just with bottom border. Added IsValid and ErrorColor Properties to better handle Validation Scenarios
using System;
using Xamarin.Forms;
namespace YOURNAMESPACE
{
public class LineEntry : Entry
{
public static BindableProperty BorderColorProperty =
BindableProperty.Create(
@thunsaker
thunsaker / git-hub-ribbon-custom.html
Created September 2, 2011 13:53
GitHub Custom Ribbon in CSS
<!-- Add to the <head> section -->
<style type="text/css">
.git-ribbon {
background-color: #a00;
overflow: hidden;
/* top left corner */
position: absolute;
left: -3em;
top: 2.5em;
/* 45 deg ccw rotation */
@thunsaker
thunsaker / weather
Created March 9, 2017 16:48
Alias for wttr.in which only displays today's weather
alias weather='curl "http://wttr.in/[YOUR CITY HERE]" -s | head -7'
@thunsaker
thunsaker / atom-sane-tab-switching.cson
Last active December 31, 2016 06:33
Atom - Sane Tab Switching
# Add the following to your keymap.cson file
#
# Get to keymap.cson through Settings -> Keybindings or ~/.atom/keymap.cson (on Mac)
'body':
'ctrl-tab':'pane:show-next-item'
'ctrl-shift-tab':'pane:show-previous-item'
@thunsaker
thunsaker / android_build_types.gradle
Last active November 20, 2016 17:23
Common build.gradle snippets for Android
// Android debug/release build types including package renaming for debug
android {
buildTypes {
debug {
zipAlign true
debuggable true
runProguard false
packageNameSuffix ".debug"
versionNameSuffix "-debug"
signingConfig signingConfigs.debugSigning
@thunsaker
thunsaker / modernizr-ios-check.js
Last active April 27, 2016 21:56 — forked from danott/modernizr-tests.js
Custom Modernizr tests that are useful.
/* modernizr-ios-check.js
* Daniel Ott (with modifications)
* 3 March 2011
* Custom Tests using Modernizr's addTest API
*/
/* iOS
* There may be times when we need a quick way to reference whether iOS is in play or not.
* While a primative means, will be helpful for that.
*/
@thunsaker
thunsaker / timeline.js
Last active February 17, 2016 16:20
Small JS sample to push pins from inside a PebbleKit JS app
/******************************* timeline lib *********************************/
// The timeline public URL root
var API_URL_ROOT = 'https://timeline-api.getpebble.com/';
/**
* Send a request to the Pebble public web timeline API.
* @param pin The JSON pin to insert. Must contain 'id' field.
* @param type The type of request, either PUT or DELETE.
* @param topics Array of topics if a shared pin, 'null' otherwise.