Skip to content

Instantly share code, notes, and snippets.

View scottoffen's full-sized avatar
💭
Live in SLC

Scott Offen scottoffen

💭
Live in SLC
View GitHub Profile
@scottoffen
scottoffen / TestParticleMan.groovy
Last active January 1, 2016 06:29
Groovy test case for the song Particle Man by TMBG!
import groovy.util.GroovyTestCase;
class TestMan extends GroovyTestCase
{
def particleMan = new Man(Man.Type.Particle);
def triangleMan = new Man(Man.Type.Triangle);
def universeMan = new Man(Man.Type.Universe);
def personMan = new Man(Man.Type.Person);
void testParticleMan ()
@scottoffen
scottoffen / timezones-snippet.html
Last active August 29, 2015 13:57
HTML Select Timezone or MySQL
<!--
mysql query to generate option list
SELECT CONCAT('<option value="', `Name`, '">', `Name`, '</option>') FROM mysql.time_zone_name;
if mysql.time_zone_name has no records go here: http://dev.mysql.com/downloads/timezones.html
to convert date/time between timezones do something like this:
SELECT startdate, CONVERT_TZ(startdate, 'utc', (SELECT timezone FROM accounts WHERE id=1)) FROM auctions;
This query takes two values, one on daylight savings and one off daylight savings, and converts them to a daylight savings impacted time zone:
@scottoffen
scottoffen / create-mysql-db.sql
Last active February 1, 2016 20:35
Create New MySQL Database (with user)
-- Using GRANT for creating new users has been deprecated and will be removed in the future
-- as of 5.7.1
-- Create a new user
create user '[username]'@'[host]' identified by '[password]';
-- Create a new database/user
create database [schema];
-- Grant user access to database
@scottoffen
scottoffen / backup-restore-mysql.sql
Created April 12, 2014 22:51
Backup and Restore MySQL Databases
mysqldump -u [username] -p [schema] > filename_yyyy.mm.dd.sql
mysql -u [username] -p [schema] < filename_yyyy.mm.dd.sql
-- You will be prompted to provide the password each time
@scottoffen
scottoffen / export-mysql-schema.sql
Created April 12, 2014 23:40
Export MySQL Schema
-- You will be prompted for a password as necessary
mysqldump -u [username] -p [schema] --no-data > schema.sql
@scottoffen
scottoffen / ContentType.cs
Last active November 23, 2022 04:11
C# ContentType Enum full source code
using System;
using System.Reflection;
namespace Grapevine
{
public enum ContentType
{
[Metadata(Value = "application/x-authorware-bin", IsBinary = true)]
AAB,
@scottoffen
scottoffen / parsemime.pl
Last active August 29, 2015 14:00
Perl parses the Apache mime.types file for use in ContentTypes.cs (https://gist.github.com/scottoffen/11197961)
#!/usr/bin/perl
use strict;
use warnings;
# input file taken from:
# http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
my %extensions;
my $input = "./mimetypes.txt";
my $output = "./contenttypes.txt";
@scottoffen
scottoffen / parsemergemime.pl
Created April 23, 2014 16:59
Perl parse and merge Apache mime.types and a list from StackOverflow to genereate ContentType.cs (https://gist.github.com/scottoffen/11197961)
#!/usr/bin/perl
use strict;
use warnings;
#----------------------------------------------------------------------------------#
# Run from the command line. This will first parse the Apache mime.types file from #
# here (http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types), #
# and then the dictionary portion only of this (http://stackoverflow.com/a/7161265)#
# StackOverflow answer (starting on the fifth line down), saved as mime.dict. All #
# files are expected to be in the same directory. #
@scottoffen
scottoffen / StringExtensions.cs
Last active August 29, 2015 14:00
My favorite C# string extension methods!
using System;
using System.Text.RegularExpressions;
namespace YourNamespace
{
public static class StringExtensions
{
public static string Capitalize(this String s)
{
if (!String.IsNullOrEmpty(s))
@scottoffen
scottoffen / ExtendedRestServer.cs
Created May 1, 2014 17:53
Grapevine.RestServer Extensions for JSON Request/Responses
using System;
using System.IO;
using System.Net;
using System.Text;
using Grapevine;
using Newtonsoft.Json.Linq;
namespace YourNameSpace
{
class ExtendedRestServer