Skip to content

Instantly share code, notes, and snippets.

View JeremyMorgan's full-sized avatar

Jeremy Morgan JeremyMorgan

View GitHub Profile
function Robot(robot) {}
// well, we need to do something...
// whenever our robot is idle, this method gets called.
Robot.prototype.onIdle = function(ev) {
var robot;
robot = ev.robot;
robot.ahead(150);
robot.rotateCannon(360);
robot.back(100);
@JeremyMorgan
JeremyMorgan / Open a browser from a C# form
Created January 14, 2013 16:23
This is a way to pop up a web page from a C# Form, either WPF or Winform. It opens a browser to a specific page, perfect for "help" pages or other pages you want to open up with a button.
// start a new process
Process myProcess = new Process();
try
{
// set shell execution
myProcess.StartInfo.UseShellExecute = true;
// set the url
myProcess.StartInfo.FileName = "http://www.mycompany.com/help.htm";
myProcess.Start();
@JeremyMorgan
JeremyMorgan / Calendargrab.js
Created January 18, 2013 22:53
Grab public data from Google Calendar
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script>
google.load("gdata", "1");
google.setOnLoadCallback(getMyFeed);
var myService;
var feedUrl = "[Feed URL ]";
@JeremyMorgan
JeremyMorgan / head.html
Last active December 13, 2015 20:28
Some Liquid tags for adding in Opengraph data in your meta tags for Octopress
{% if page.title %}<meta property="og:title" content="{{ page.title }}" /><meta itemprop="name" content="{{ page.title }}" />{% endif %}
{% if page.author %}<meta name="author" content="{{ site.author }}" />
<meta property="article:author" content="https://plus.google.com/+JeremyMorgan" />
<meta property="og:type" content="article" />{% endif %}
{% if page.date %}<meta property="article:published_time" content="{{ page.date }}" />{% endif %}
{% capture category %}{% if page.categories %}{{ page.categories }}{% endif %}{% endcapture %}
{% if page.categories %}<meta property="article:section" content="{{ page.categories }}" />{% endif %}
{% capture description %}{% if page.description %}{{ page.description }}{% else %}{{ content | raw_content }}{% endif %}{% endcapture %}
<meta name="description" content="{{ description | strip_html | condense_spaces | truncate:150 }}" />
<meta property="og:description" content="{{ description | strip_html | condense_spaces | truncate:150 }}" />
@JeremyMorgan
JeremyMorgan / database.class.php
Last active December 14, 2015 17:09
Simple PDO Database Class
<?php
/**
* File: database.class.php
* Super simple PDO class
*
* Author: Jeremy Morgan
*
* This is just a start. No error handling or parameterization yet
*/
@JeremyMorgan
JeremyMorgan / OpenGraphHeader.htm
Last active January 16, 2022 21:24
Template for Open Graph Tags. Adding these to your pages will help you display information better on Google+, Facebook and Twitter. Just replace the values with their own.
<meta itemprop="name" content="[ TITLE ]" />
<meta itemprop="image" content="[ LISTING IMAGE ]" />
<meta itemprop="description" content="[ ARTICLE DESCRIPTION ]" />
<meta name="description" content="[ ARTICLE DESCRIPTION ]" />
<meta name="author" content="[ AUTHOR FULL NAME ]" />
<meta property="article:author" content="[ GOOGLE+ AUTHOR URL ]" />
<meta property="article:published_time" content="[ PUBLISHED TIMESTAMP ]" />
<meta property="article:section" content="[ CATEGORY ]" />
@JeremyMorgan
JeremyMorgan / getdomain.php
Created June 10, 2013 20:08
PHP Function to return a friendly domain name from a URL
/**
* Function to return friendly domain name (example.com) from a full URL
* @param string $url
* @return string
*/
function getDomain($url){
// remove the protocol
$url = str_replace((array("http://", "https://")), "", $url);
@JeremyMorgan
JeremyMorgan / states.sql
Last active October 3, 2023 12:55
An SQL Query to insert 50 U.S. States into a database.Make sure your auto increment is set in MySQL, and Identity_insert is set in MS-SQL.
CREATE TABLE [state](
[stateID] [int] IDENTITY(1,1) NOT NULL,
[stateCode] [nchar](2) NOT NULL,
[stateName] [nvarchar](128) NOT NULL,
CONSTRAINT [PK_state] PRIMARY KEY CLUSTERED
( [stateID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY])
ON [PRIMARY]
@JeremyMorgan
JeremyMorgan / fizzbuzz.cs
Last active December 19, 2015 11:49
FizzBuzz Problem in command line C#
using System;
using System.Text;
class FizzBuzz
{
static void Main()
{
for (int i = 1; i < 100; i++)
{
@JeremyMorgan
JeremyMorgan / fizzbuzz.cpp
Created July 8, 2013 18:31
FizzBuzz in C++
#include<iostream>
#include<stdio.h>
int main (void)
{
int i;
for (i = 1; i <= 100; i++)
{
if (!(i % 15))
std::cout << "FizzBuzz \n";