Skip to content

Instantly share code, notes, and snippets.

View kalisjoshua's full-sized avatar

Joshua T Kalis kalisjoshua

View GitHub Profile
// Async Before App Init
angular.module('app', [/*...*/])
.config(function () {
// register all routes and stuff
})
.run(function ($rootScope) {
$rootScope.$on('$stateChangeStart', function (AsyncValue) {
if (!AsyncValue.pageAvailable) {
// send back to home
}
@kalisjoshua
kalisjoshua / euler1.js
Created March 12, 2014 20:43
JavaScript Project Euler #1
/*
If we list all the natural numbers below 10 that are multiples of
3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
*/
var result;
result = Array.apply(0, new Array(1000))
@kalisjoshua
kalisjoshua / euler1.lua
Created March 12, 2014 20:50
Lua Project Euler #1
--[[
If we list all the natural numbers below 10 that are multiples of
3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
]]
local counter = 0
local limit = 1000
local sum = 0
@kalisjoshua
kalisjoshua / euler1.hs
Created March 12, 2014 20:52
Haskell Project Euler #1
{-
If we list all the natural numbers below 10 that are multiples of
3 or 5,we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
-}
main =
print (sum [x | x <- [1..999], mod x 5 == 0 || mod x 3 == 0])
@kalisjoshua
kalisjoshua / gist:500d5efabc7e848804af
Created June 8, 2014 14:14
IETF docs are ugly to look at and I am lazy so I don't like scrolling. This - bookmarklet (optional) - script makes the experience a little better with centered document body and larger text with left/right navigation through pages.
(function (doc) {
doc.body.style.fontSize = '115%';
doc.body.style.margin = '0 auto';
doc.body.style.maxWidth = '37em';
var count,
rPage = /\[\s*?page\s*?(\d+?)\s*?\]/i,
TOP = 'top-of-document';
function turn(delta) {
@kalisjoshua
kalisjoshua / SassMeister-input.scss
Created December 4, 2014 13:51
Generated by SassMeister.com.
// ----
// Sass (v3.4.7)
// Compass (v1.0.1)
// ----
@mixin size($size, $modulo: 5) {
@if $size % $modulo == 0 {
width: unquote('#{$size}%') !important;
}
}
// What does this code achieve?
function toArray(args) {
return Array.prototype.slice.call(args);
}
// When would you use it? Why does it need to be implemented this way? And what about the following code?
function log(args) {
Function.prototype.apply.call(console.log, console, args);
@kalisjoshua
kalisjoshua / grunt.js
Created August 3, 2012 17:53
Working w/ Grunt
/*jshint strict:false*/
/*global module*/
module.exports = function(grunt) {
grunt.registerHelper("wrapp", function (src, argList, args) {
return ";(function (%1) {\n%2\n}(%3));"
.replace("%1", argList || "")
.replace("%3", args || "")
.replace("%2", src);
});
@kalisjoshua
kalisjoshua / usercam.js
Created November 21, 2012 20:14
Usercam Bookmarklet (getUserMedia Video PIP)
(function (nav, win, doc) {
"use strict";
var lib = "usercam"
, anchor = [true, true] // === top, left
, pending
, pip;
nav.getUserMedia =
(nav.getUserMedia || nav.webkitGetUserMedia || nav.mozGetUserMedia || nav.msGetUserMedia);
@kalisjoshua
kalisjoshua / para_soft.md
Created November 26, 2012 21:54
Markdown soft break paragraph example

The path of the righteous man is beset on all sides by the iniquities of the selfish and the tyranny of evil men. Blessed is he who, in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother's keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy My brothers. And you will know My name is the Lord, when I lay My vengeance upon thee. <--- end of first paragraph - soft break --> Now that we know who you are, I know who I am. I'm not a mistake! It all makes sense! In a comic, you know how you can tell who the arch-villain's going to be? He's the exact opposite of the hero. And most times they're friends, like you and me! I should've known way back when... You know why, David? Because of the