Skip to content

Instantly share code, notes, and snippets.

View buddylindsey's full-sized avatar
🚜
Homesteading

Buddy Lindsey, Jr. buddylindsey

🚜
Homesteading
View GitHub Profile
class MainController < NSWindowController
def awakeFromNib
end
def newWindow(sender)
someData = "Blob"
nw = MainWindowController.alloc.init
@buddylindsey
buddylindsey / YAML Example - Problem
Created February 8, 2011 23:33
Loading YAML from a file Problem
require 'yaml'
# setup an object to serialize with yaml
class Square
attr_accessor :width, :height, :bonus, :me
def initialize width, height
@width = width
@height = height
@bonus = ['yo',{:msg => 'YAML 4TW', :alert => 'I am an alert'}]
@me = self
@buddylindsey
buddylindsey / gist:978005
Created May 18, 2011 04:42
Basic JQuery Ajax
$("#EnglishName").blur(function () {
$.ajax({
url: "/Search/AjaxAddSearch",
dataType: "json",
data: {
showTitle: $("#EnglishName").val()
},
success: function (data) {
$(".possibleShows").css("visibility", "visible")
.html("<pre>"+ data +"</pre>")
@buddylindsey
buddylindsey / gist:978015
Created May 18, 2011 04:55
Rails Side of jQuery AJAX
class GenresController < ApplicationController
def all
snippet = params[:genre]
@genres = Genre.where("name LIKE '%#{snippet}%'")
respond_to do |format|
format.json do
render :json => @genres.map(&:name)
end
@buddylindsey
buddylindsey / gist:1266242
Created October 6, 2011 01:27
IronRuby + .NET
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
@buddylindsey
buddylindsey / gist:1306692
Created October 23, 2011 00:41
Fun Quick and Dirty Read from Text file Insert Into DB
require 'sqlite3'
db = SQLite3::Database.new "db.sqlite3"
File.open('foods.csv', 'r') do |infile|
counter = 2
while(line = infile.gets)
food = line.split(',')[0]
db.execute("insert into pantry_foodtype values (#{counter},#{counter},\"#{food}\",\"#{food}\", 5)")
counter += 1
@buddylindsey
buddylindsey / gist:1410596
Created November 30, 2011 20:09
Max-Heap
#include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std;
int heapSize = 0;
int leftChild(int index)
{
@buddylindsey
buddylindsey / gist:1410890
Created November 30, 2011 21:19 — forked from zerokarmaleft/gist:1410689
Max-Heap
#include <iostream>
#include <stdlib.h>
#include <limits.h>
#include <fstream>
#include <string>
#include <sstream>
using namespace std;
ofstream outfile;
@buddylindsey
buddylindsey / gist:1421074
Created December 2, 2011 00:49
Jquery Mobile Random
<body onload="onBodyLoad()">
<div data-role="page" id="home">
<div data-role="header">
<h1>My Title</h1>
</div><!-- /header -->
<div data-role="content">
<p class="sup">Hello world</p>
<p><a href="#contracts" data-role="button">Contracts</a></p>
</div><!-- /content -->
@buddylindsey
buddylindsey / gist:1421617
Created December 2, 2011 03:35
jQuery Content from li
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$(".touch").click(function(){
alert($(this).html());
});
});
</script>