Skip to content

Instantly share code, notes, and snippets.

View codeimpossible's full-sized avatar
🍕
P I Z Z A

Jared Barboza codeimpossible

🍕
P I Z Z A
View GitHub Profile
@codeimpossible
codeimpossible / test_worker.js
Created October 4, 2012 03:42
BDD style unit tests for node-worker
describe('Worker', function(){
var helpers = require('./test_helpers');
var loadModule = require('./module-loader').loadModule;
var mocks = require('mocks');
var assert = require("assert");
var module, fsMock, mockRequest, mockResponse, Worker;
Function.prototype.after = function(ms) {
var current = this;
@codeimpossible
codeimpossible / simple.template.js
Created October 8, 2012 15:44
very simple templating system in javascript
var template = function(template, model) {
for(var p in model) {
if( model.hasOwnProperty(p) ) {
var re = new RegExp( "#{" + p + "}", "ig" );
template = template.replace(re, model[p]);
}
}
return template;
};
@codeimpossible
codeimpossible / JobsController.cs
Created October 9, 2012 00:42
JobsController from Proggr
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Proggr.Controllers.Filters;
using Proggr.Controllers.Responses;
namespace Proggr.Controllers
{
@codeimpossible
codeimpossible / peta_poco.cs
Created October 17, 2012 01:00
PetaPoco Example
[PetaPoco.TableName("People")]
[PetaPoco.PrimaryKey("Id")]
public class Person
{
public int Id { get; set; }
// .. some other fields
}
public ActionResult Create( Person person )
{
var DISQUSWIDGETS, disqus_domain, disqus_shortname;
typeof DISQUSWIDGETS == "undefined" && (DISQUSWIDGETS = function () {
var c = {}, m = document.getElementsByTagName("HEAD")[0] || document.body,
n = 0,
h = {}, k = {
identifier: 1,
url: 2,
slug: 3
};
c.domain = "disqus.com";
@codeimpossible
codeimpossible / jquery.js
Created January 3, 2013 16:34
I love jquery
// function to mark a field invalid in one of our backbone viewws (uses backbone.validation)
function markFieldInvalid (view, attr, error) {
view.getFieldByName(attr)
.addClass('invalid')
.parents('.control-group:first')
.addClass('error')
.find('.help-inline, .help-block')
.text(error);
};
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using FragEngine.Entities;
using FragEngine.IO;
using Microsoft.Xna.Framework;
namespace ThunderDome
(function($) {
$('.validation_error').each(function( index ) {
var $item = $(this);
var $control = $item.closest('tr').find('.EditingFormControlNestedControl').first();
$item.attr('id', control.id);
this.id = control.id;
});
})(jQuery);
var hitBy = WeaponManager.CheckIfHit( this );
if( hitBy != null )
{
Hud.KillStreak = 0;
var damageAfterShields = Shields.AbsorbDamage( hitBy.Damage );
// huh, this is a bug. Looks like you won't take damage if you have less shields than weapon damage
if( damageAfterShields == hitBy.Damage )
{
@codeimpossible
codeimpossible / autofart.js
Created May 9, 2013 17:08
give the gift of flatulence
// use this on any page with fartscroll -> http://theonion.github.io/fartscroll.js/
setInterval((function() {
var rangeUpper = 100;
$("body").fartscroll(100);
return function() {
var randomnumber = Math.floor( Math.random() * rangeUpper ),
mod = 1;
if( $(document).height() - $(window).scrollTop() - $(window).height() <= 0 ) {
mod = -1;
}