Skip to content

Instantly share code, notes, and snippets.

View jszpila's full-sized avatar
🏠
Working from home

Jan Szpila jszpila

🏠
Working from home
View GitHub Profile
export function changeCounter(dollarAmount, coinTypes) {
let coins = {},
coin = null,
remainder = 0,
numOfCoins = 0;
if (areRealCoinTypes(coinTypes)) { // NOT DEFINED!
for (let i = 0, x = coinTypes.length; i < x; i++) {
coin = coinTypes[i];
// Wrote this in jsbin to cut down on time monkeying around. This of course could be
// implemented as an ES6 or CommonJS module or a jQuery plugin or attached to Math's prototype
// but I thougth this approach presented the least friction.
// To see it in action: http://jsbin.com/vehewog/edit?js,console
// Sums even numbers in fibonacci sequence up to provided limit
// input: number to calculate up to
// output: sum of even numbers up to limit
// TODO: generalize by adding param to sum even, odd, or all (rename to subFibbSeqNums)
function sumEvenFibbSeqNums (limit) {
@jszpila
jszpila / keybase.md
Created January 11, 2018 18:49
keybase thang

Keybase proof

I hereby claim:

  • I am jszpila on github.
  • I am jszpila (https://keybase.io/jszpila) on keybase.
  • I have a public key whose fingerprint is 3359 1A51 0537 167A D2AC A491 7F8F CB27 834D 25AC

To claim this, I am signing this object:

test
@jszpila
jszpila / mac-setup
Last active October 23, 2023 19:44
Script to install my Mac dev tools and more.
#!/bin/sh
##################################################################################################
#
# JSzpila's Mac Set-up Script
#
# Big chunks borrowed from @brandonb927 (https://gist.github.com/brandonb927/3195465)
#
# TODO:
# - install: copyclip, notifier pro, witch, pixelmator
@jszpila
jszpila / OOPFunWithJSandCyberdyne.js
Last active August 29, 2015 14:02
JS Namespacing/OOP With Inheritance
if (Cyberdyne == null || typeof(Cyberdyne) != "object") {
var Cyberdyne = {
Terminator: function (options) {
this.friendly = options.friendly;
this.iff = function() {
if (this.friendly) {
console.log("Come with me if you want to live.");
} else {
console.log("I will not stop - EVER - until you are dead.");
@jszpila
jszpila / EmberModelGetJSON
Created February 26, 2013 21:24
Method for returning the contents of a local json file from a method of an Ember.js model/object.
App.MyModel.reopenClass({
myMethod: function() {
return $.getJSON('/path/to/json/data.json');
}
});
@jszpila
jszpila / jQueryDeferredAJAXArray
Last active December 12, 2015 01:49
Deferred AJAX requests for objects in an array using jQuery, assuming you want to populate a list using Handlebars templates for each list item.
function populateItemList(items) {
var output = '',
item = null,
template = null,
defers = [],
defer = null;
for (var i = 0, j = items.length; i < j; i++) {
item = items[i];
@jszpila
jszpila / gist:1879485
Created February 21, 2012 22:31
Platform/browser detection with platform.js to supplement Modernizr
// Determine browser, OS, context (desktop or mobile), and device (if applicable)
var classes = new Array();
classes.push(platform.name.toLowerCase());
classes.push(platform.os.toLowerCase().split(' ')[0]);
// Only mobile devices have a product property (I think)
if (platform.product == null) {
classes.push('desktop');
} else {
@jszpila
jszpila / gist:1706422
Last active September 30, 2015 02:27
Relative paths in LESS. Maybe I was just doing it wrong, but I found using relative paths in LESS to not be intuitive at all. So I had to hack this little bit of literally interpreted string-injection monkey-business up because the interpreter kept mapping the location under the /css/ directory if I specified it any other way.
@imgPath: "../img/";
background: #FFF url(~"@{imgPath}bg/myBackgroundImg.png") no-repeat bottom left;