Skip to content

Instantly share code, notes, and snippets.

View acconrad's full-sized avatar
🤓
VR to the moon

Adam Conrad acconrad

🤓
VR to the moon
View GitHub Profile

Keybase proof

I hereby claim:

  • I am acconrad on github.
  • I am acconrad (https://keybase.io/acconrad) on keybase.
  • I have a public key ASAl3LMybroeC3NqsIXLB-mWaKMbrde_XaoDfzZLzlItuAo

To claim this, I am signing this object:

@acconrad
acconrad / upto-polyfill.js
Created January 7, 2016 19:44
How to create an Array sequence from one number to the next in JavaScript
// Works in IE9+, Chrome, Safari, Firefox, and Opera
//
// Examples:
// (5).upTo(10) => [5, 6, 7, 8, 9, 10]
// (-1).upTo(3) => [-1, 0, 1, 2, 3]
Number.prototype.upTo = function( upper ){
'use strict';
var lower = this;
if ( lower == undefined ) {
class TestClass
LIST_OF_METHODS = {
1 => -> { method_1 }
2 => -> { method_2 }
}
def select_method(number)
LIST_OF_METHODS[number].call
end
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
begin
@user_answer = @user.user_answers.where(:question_id => @question_id).first
if @user_answer
@user_answer.answer_id = @answer_id
@user_answer.save!
@message = 'Answer updated successfully!'
else
@user.user_answers.create(:question_id => params[:questionId], :answer_id => params[:answerId])
@message = 'Answer submitted successfully!'
end
@acconrad
acconrad / jquery-datalink.js
Created May 7, 2013 23:19
An older version of jquery-datalink
'use strict'
# App Module
angular.module('myApp', ['myFilters', 'myServices']).config ['$routeProvider', ($routeProvider) ->
$routeProvider.when('/users',
templateUrl: '<%= asset_path("leaderboard.html") %>'
controller: LeaderboardCtrl
)
]
@acconrad
acconrad / mq.css
Created October 8, 2012 10:35 — forked from chriscoyier/mq.css
@media only screen and (min-width: 320px) {
/* Small screen, non-retina */
}
@media
only screen and (-webkit-min-device-pixel-ratio: 2) and (min-width: 320px),
only screen and ( min--moz-device-pixel-ratio: 2) and (min-width: 320px),
only screen and ( -o-min-device-pixel-ratio: 2/1) and (min-width: 320px),
@acconrad
acconrad / init.js
Created August 31, 2012 18:13
Troublesome JS functions
function addDailyPlayer (element) {
if (logged_in) {
var $row = $(element).closest('li')
, $myTeam = $('#player_confirmation_table').children('tbody')
, playerSlotAvailableNew = 0
, useFlex = false
, $playerInfo
, $playerSlot
, playerId
, gameId
@acconrad
acconrad / gist:3350416
Created August 14, 2012 15:48
How to target mobile devices with CSS Media Queries
@media only screen and (-webkit-device-pixel-ratio: .75) {
/* CSS for Low-density screens goes here *
* Ex: HTC Evo, HTC Incredible, Nexus One */
}
@media only screen and (-webkit-device-pixel-ratio: 1) and (max-device-width: 768px) {
/* CSS for Medium-density screens goes here *
* Ex: Samsung Ace, Kindle Fire, Macbook Pro *
* max-device-width added so you don't target laptops and desktops */
}