Skip to content

Instantly share code, notes, and snippets.

View VirtuosiMedia's full-sized avatar

Virtuosi Media VirtuosiMedia

View GitHub Profile
def all
if current_user.has_projects?
@trial = current_user.trials.first
@project = @trial.project
else
@trial = Trial.new
@project = current_user.projects.first
end
@is_new = params[:new]
var Hyphenator = new Class ({
Implements: [Events, Options],
options: {
separator: '-',
trigger: 'keyup',
prepend: '',
allowed: /[^\w\d\s-]/g
},
//Create URL slug
var urlText = new Element('a', {
'href':'#',
'id':'fullUrlToggle',
'html':$('viewFullUrl').get('value')
});
$('urlLabel').appendText(' ').grab(urlText);
$('fullUrlToggle').addEvent('click', function(e){
e.stop();
def format_data
tasks = self.task_completions.select(
"task_completions.skipped,
task_completions.created_at,
task_completions.timestamp,
demographics.gender,
demographics.age,
demographics.location,
demographics.ethnicity,
demographics.income,
(function($) {
$.widget("ui.demographics_filter", {
_initialize: function(){
this.getFilters();
this._wire();
},
_wire: function(){
var self = this;
$('.btn-group').click(function(){
@VirtuosiMedia
VirtuosiMedia / User.php
Created September 8, 2012 21:43
An example file for working with users.
<?php
/**
* @author Benjamin Kuker
* @description A simple user class. Normally, this would interact with a database and form validation code, but for
* demonstration purposes, I'm simply throwing exceptions when errors occur.
*
* Also, please note: I rarely, if ever, use static methods or classes because they aren't easily testable or
* extensible and I almost always want to work with an object. If I were to need a static method, I would implement a
* function instead. See http://stackoverflow.com/questions/1185605/ for more. Because I probably wouldn't use it in
* real life, and in order to give you a more accurate picture of how I code, I've ommitted the static method.
@VirtuosiMedia
VirtuosiMedia / gist:3680424
Created September 8, 2012 22:33
Floating Square
.floatingSquare {
background: #FFF;
display: block;
height: 100px;
left: 45%;
opacity: 0.5;
position: absolute;
top: 45%;
width: 100px;
}
@VirtuosiMedia
VirtuosiMedia / Chess.php
Created September 10, 2012 03:42
Demo classes for moving chess pieces
<?php
/**
* @description An abstract class for all chess pieces
* @author Benjamin Kuker
*/
abstract class ChessPiece {
protected $color = null;
protected $constraints = array();
protected $currentPosition = null;
/**
* Utility class for dealing with SVG elements
* Copyright Virtuosi Media, Inc. 2012
* MIT License
*/
var SVG = new Class({
/**
* @param string - el - The type of SVG element
* @param object - options - The attributes and values for the SVG element, stored in a hash
@VirtuosiMedia
VirtuosiMedia / gist:7505760
Created November 16, 2013 21:46
This is a proof-of-concept for a JavaScript Autoloader. It works, but I haven't yet been able to figure out how to recover from the error without having to re-execute all of the app function. Ideally, it would deal with the error and then try that line again.
<!doctype html>
<html>
<head>
</head>
<body>
<script type="text/javascript">
var app = function(){
console.log('Initialize App');
var test = new Test();
var foo = new Foo();