Skip to content

Instantly share code, notes, and snippets.

@krohrbaugh
krohrbaugh / gist:36637
Created December 16, 2008 15:48
Example code block for authenticating .NET web services secured using HTTP Basic auth
/*
* Web service auth example
* - ReferencedWebService is the Web Reference service object
* and should be replaced with your actual service object
*/
ReferencedWebService webService = new ReferencedWebService();
webService.Url = "http://webservice.com/service.asmx";
webService.PreAuthenticate = true;
webService.Credentials = new System.Net.NetworkCredential("username", "password");
@krohrbaugh
krohrbaugh / gist:119709
Created May 29, 2009 01:09
Poor man's subdomain redirect using JavaScript
var hostarray = new Array();
hostarray["subdomain.somewhere.com"] = "subdomain.somewhere.com/application/home.html";
function redirect()
{
//Obtain the host name in lowercase format
var lhost = new String(location.host);
lhost = lhost.toLowerCase();
@krohrbaugh
krohrbaugh / shuffle_array.rb
Created April 21, 2010 15:05
Shuffling an array in Ruby, based on the Array#shuffle! implementation in ruby-1.9
=begin
This is the actual C-based implementation of Array#shuffle! in ruby-1.9:
/*
* call-seq:
* array.shuffle! -> array
*
* Shuffles elements in _self_ in place.
*/
export PATH="~/bin:/usr/local/bin:/usr/local/sbin/:/opt/local/bin:/opt/local/sbin:$PATH"
# prompt display data
function rvm_selected_ruby {
rb=$(~/.rvm/bin/rvm-prompt)
case "$rb" in
"system" )
return
;;
* )
@krohrbaugh
krohrbaugh / chatterbox
Created December 6, 2010 21:37
logrotate configuration for Chatterbox (Production)
/var/www/myapp/current/log/newrelic_agent.log {
weekly
size 5M
create 700 deploy deploy
rotate 2
}
/var/www/myapp/current/log/process_alert.log {
weekly
size 5M
@krohrbaugh
krohrbaugh / google_analytics_example.html
Created January 19, 2011 20:00
Google Analytics include code using protocol-relative URLs => http://bit.ly/fomkTv
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'YOUR_ID_HERE']);
_gaq.push(['_trackPageview']);
</script>
<script src="//www.google-analytics.com/ga.js" type="text/javascript" async></script>
@krohrbaugh
krohrbaugh / irb_require_gem.rb
Created May 5, 2011 05:29
Provide a mechanism for requiring local dev environment gems that aren't included in the project's Gemfile.
module IRBExtensions
# Load a gem into IRB regardless of Bundler trickery. This method leaves
# $LOAD_PATH altered, in order to allow #autoload to work properly.
#
# Inspired by:
# https://gist.github.com/955611
# https://gist.github.com/932231
#
# IRB.require_gem 'looksee'
# IRB.require_gem 'awesome_print', :as => 'ap'
@krohrbaugh
krohrbaugh / 1-environment_information
Created September 28, 2012 16:17
Details for rvm compile issue (OSX 10.7.5, Xcode 4.5, apple-gcc42)
$ rvm --version
rvm 1.16.6 (master) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/]
$ which gcc-4.2
/usr/local/bin/gcc-4.2
$ gcc-4.2 --version
i686-apple-darwin11-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
Copyright (C) 2007 Free Software Foundation, Inc.
@krohrbaugh
krohrbaugh / private.xml
Created March 18, 2013 04:23
My IOGEAR GCS1782 [http://www.iogear.com/product/GCS1782/] KVM's keyboard emulation prevents many media keys (e.g., volume controls, music playback controls, etc) from being recognized by Mac OS X. To get around this, I'm using KeyRemap4MacBook [http://pqrs.org/macosx/keyremap4macbook/] to remap the keys.
<?xml version="1.0"?>
<root>
<item>
<name>Das Keyboard for Mac (through KVM)</name>
<item>
<name>Enable Power/Sleep Button</name>
<appendix>F1 to Power</appendix>
<appendix>Fn+F1 to F1</appendix>
<identifier>private.enable_power_sleep_button</identifier>
@krohrbaugh
krohrbaugh / example.ps1
Created October 7, 2013 22:01
Windows Azure Active Directory: Add role to service principal
# Using the Windows Azure Active Directory Module for Windows PowerShell
#
# Connect to the tenant to modify
Connect-MsolService # => login
# Get Service Principal to add the role to
$servicePrincipal = Get-MsolServicePrincipal -ServicePrincipalName Principal.Name
# Get role object ID
# Alternatively, you can list all the roles (in order to get a different role name) using just `Get-MsolRole`