Skip to content

Instantly share code, notes, and snippets.

View pagebrooks's full-sized avatar
👽

Page Brooks pagebrooks

👽
View GitHub Profile
@pagebrooks
pagebrooks / BoxStarter
Last active September 23, 2015 03:45
Boxstarter Script
$Boxstarter.RebootOk=$true # Allow reboots?
$Boxstarter.NoPassword=$false # Is this a machine with no login password?
$Boxstarter.AutoLogin=$true # Save my password securely and auto-login after a reboot
Install-WindowsUpdate -AcceptEula
Update-ExecutionPolicy RemoteSigned
Set-WindowsExplorerOptions -EnableShowFileExtensions -EnableShowFullPathInTitleBar
Disable-InternetExplorerESC
Enable-RemoteDesktop
@pagebrooks
pagebrooks / remote.md
Last active December 24, 2015 07:49
Remotely Manage Windows Services

Remotely Start and Stop Services

Make sure you have the latest version of Subinacl.exe (there is an older version that has a bug where it will not apply the security descriptor).

Documentation for Subinacl.exe is here: http://www.robvanderwoude.com/subinacl.php

If you are not using a domain user, you can create a local user on both servers that have the same user name and password. As long as the local user names and passwords match on both machines, you can remotely manage the services.

<select id="state" name="state">
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
<option value="DC">District of Columbia</option>
@pagebrooks
pagebrooks / sed-replace.sh
Last active December 23, 2015 03:59
sed one-liner that will inject value into configuration file.
# Find a string that starts with bind-address= and replace anything after the = with 0.0.0.0
# For example, in the my.cnf file, this would replace:
# bind-address = 127.0.0.1
# with
# bind-address = 0.0.0.0
sed -i 's/^\(bind\-address\s*=\s*\).*$/\10\.0\.0\.0/' /etc/mysql/my.cnf
@pagebrooks
pagebrooks / WatiNHelper.cs
Last active June 26, 2017 07:53
This helper class adds Eval so that you can obtain the result of a JavaScript function. This functionality is not native to WatiN. Forked from: http://blog.ashmind.com/2007/09/05/evaluating-javascript-in-watin
// Forked from: http://blog.ashmind.com/2007/09/05/evaluating-javascript-in-watin/
// This helper class adds Eval so that you can obtain the result of a JavaScript
// function. This functionality is not native to WatiN.
/*
* Usage:
* var browser = new IE();
* var foo = browser.NativeDocument.Eval<bool>("isFoo()");
*/

Procedure for Mongodb Logrotate

The default install for Mongodb does not configure log rotation.

In /etc/logrotate.d/mongod

/var/log/mongodb/*.log {
    daily
    rotate 30
    compress

dateext

Procedure for upgrading a standalone MongoDB

  • Upgrade applications to use the latest Mongo Driver and then test applications to make sure they work using the latest version of driver with old database version.

  • Shutdown Mongod: > db.shutdownServer()

  • Verify that the service actually stopped using: $ sudo service mongodb status

  • Create a backup copy of all databases $ sudo cp –vrp /media/data/mongodb /media/data/mongodb-backup

@pagebrooks
pagebrooks / couchdb-install
Last active December 13, 2015 17:18
I guide for installing CouchDB 1.2.1 on Ubuntu 12.04
Resources
http://onabai.wordpress.com/2012/05/10/installing-couchdb-1-2-in-ubuntu-12-04/
http://depth-first.com/articles/2010/01/28/pubcouch-install-couchdb-on-ubuntu-karmic-from-source/
http://wiki.apache.org/couchdb/Installing_on_Ubuntu
http://guide.couchdb.org/draft/source.html
http://grokbase.com/t/couchdb/user/114m97mzd0/installations-problem-with-couchdb
http://cvee.github.com/blog/2011/11/28/configuring-couchdb-on-ubuntu/
@pagebrooks
pagebrooks / ToSelectList.cs
Created December 7, 2012 00:50
ASP.NET MVC Html Helper for generating a select list from a dictionary
public static List<SelectListItem> ToSelectList(this Dictionary<string, string> items, string defaultItem, bool insertBlankItem = false)
{
string[] defaultItems = new[] { defaultItem };
if (!string.IsNullOrWhiteSpace(defaultItem))
{
defaultItems = defaultItem.Split(',');
}
var i = items.Select(pair => new SelectListItem
{
@pagebrooks
pagebrooks / JsonNetResult.cs
Created December 7, 2012 00:28
Angular Compatible Date Formatting with JSON.NET
public class JsonNetResult : JsonResult
{
private readonly static JsonSerializerSettings Settings;
private readonly static IsoDateTimeConverter _dateTimeConverter;
static JsonNetResult()
{
_dateTimeConverter = new IsoDateTimeConverter();
// Default for IsoDateTimeConverter is yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFFK
_dateTimeConverter.DateTimeFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFK";