Skip to content

Instantly share code, notes, and snippets.

View jpbyrne's full-sized avatar

Jon Byrne jpbyrne

  • Dublin, Ireland
View GitHub Profile
@jpbyrne
jpbyrne / ball.js
Created October 25, 2012 21:44
A simple Breakout clone created using JavaScript
function Ball(x, y, radius, color) {
this.x = x;
this.y = y;
this.dx = 10;
this.dy = 10;
this.dxRange = this.dx * 2;
this.radius = radius;
@jpbyrne
jpbyrne / disableSelection.js
Created November 15, 2012 16:02
This method is used to prevent the selection of HTML page elements.
function disableSelection(target){
if (typeof target.onselectstart!="undefined") // if IE
target.onselectstart=function(){return false}
else if (typeof target.style.MozUserSelect!="undefined") // if Firefox
target.style.MozUserSelect="none";
else // others
target.onmousedown=function(){return false;
}
}
function init() {
video = document.getElementById('video');
video.volume = 0;
var progressSpan = document.getElementById('progress-span');
var progressSlider = document.getElementById('progress-slider');
progressSlider.max = video.duration;
progressSlider.onchange = function() {
video.currentTime = progressSlider.value;
var ctx;
var count = 0;
var x;
var y;
var img = new Image();
img.src = "sprite_sheet.png";
img.onload = draw;
function draw() {
requestAnimationFrame(draw);
$(document).ready(function() {
var theMP3;
var currentSong = 0;
var tracks = ["1","2","3","4","5"];
var id3s=[];
$jScroller.add("#scroller_container","#scroller","left",2);
$jScroller.cache.init = true; // Turn off default Event
$jScroller.config.refresh = 100;
$( "#progressbar" ).progressbar({
value: 0
@jpbyrne
jpbyrne / gist:cf0e678165863cfd616b
Last active August 29, 2015 14:23
Calculate TableView Height
func calculateTableViewHeight(cellHeight: CGFloat, numberOfRows: Int) -> CGFloat {
var tableViewHeight: CGFloat = 0.0
tableViewHeight = cellHeight * numberOfRows
return tableViewHeight
}
@jpbyrne
jpbyrne / gist:507907140b2d6abc5654
Last active August 29, 2015 14:23
Updating TableView Height Constraint
@IBOutlet weak var tableView: UITableView!
@IBOutlet weak var tableViewHeightConstraint: NSLayoutConstraint!
var tableViewCell: UITableViewCell = tableView.cellForRowAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))
var cellHeight: CGFloat = tableViewCell?.frame.height
var dataSource: [AnyObject]?
tableViewHeightConstraint.constant = calculateTableViewHeight(cellHeight, dataSource.count)
@jpbyrne
jpbyrne / .block
Last active March 22, 2017 14:05
fresh block
license: mit
@jpbyrne
jpbyrne / .block
Last active March 23, 2017 14:29
bar block
license: mit
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.