Skip to content

Instantly share code, notes, and snippets.

@Jiert
Jiert / app.js
Created August 20, 2015 21:30
Image Loading with Underscore
initialize: function(){
_.bindAll(this, 'render', 'onImgLoad');
this.mainImg = new Image();
this.mainImg.src = this.model.get('img');
this.userImg = new Image();
this.userImg.src = this.model.get('admin').img;
this.mainImg.onload = this.onImgLoad;
@Jiert
Jiert / bad.js
Last active August 29, 2015 14:21
Beautiful
importSchedule.startHourOptions = this._buildOptions(_.chain(_.range(0, 24)).map(function(hour){
return {text: '00'.substring(0, '00'.length - hour.toString().length) + hour.toString(), value: hour};
}).value(), importSchedule.start_hour);
@Jiert
Jiert / coinify.js
Last active August 29, 2015 14:20
Coinify, find the lowest number of coins it would take to make X amount of cents
function coinify(cents){
var count = parseInt(cents / 50),
leftOver = cents % 50,
coins = [25, 10, 5, 1],
iterator = 0;
while (leftOver > 0){
count += parseInt( leftOver / coins[iterator] );
leftOver = leftOver % coins[iterator];
iterator ++;
@Jiert
Jiert / JavaScript-Tabs.js
Last active November 29, 2023 11:40
Creating Tabs with Vanilla JavaScript
<!DOCTYPE html>
<html lang="en">
<head>
<title>Tabs</title>
<style>
.nav .active a { color: red; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }
</style>
</head>
@Jiert
Jiert / Wat.js
Last active December 15, 2015 14:29
I found this in a code base
'00'.length