Skip to content

Instantly share code, notes, and snippets.

View Nevraeka's full-sized avatar

Erik Isaksen Nevraeka

View GitHub Profile
@Nevraeka
Nevraeka / gist:8695535
Created January 29, 2014 19:47
Sample Gruntfile for prototyping
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
concat: {
dest: {
files: {
'public/js/p3c.js': [
'app/assets/js/*.js',
'app/assets/js/services/*.js',
'app/assets/js/controllers/*.js',
@Nevraeka
Nevraeka / web-platform-module.js
Created February 3, 2014 20:45
Angular Web Component Integration - Psuedo Code Concept
angular.module('web-platform', ["$ComponentSvc","$PolyfillSvc"]).component('ngw-picture',
["$components", function($components) {
return {
scope: {},
link: function($scope, $customElement, $attrs) {
var srcSets = $customElement.find('ngw-src-set');
// checks name for syntax - returns error if syntax is incorrect
// uses name to generate
@Nevraeka
Nevraeka / JaFDK.markdown
Created September 3, 2014 15:47
A Pen by Erik Isaksen.
@Nevraeka
Nevraeka / gist:3baad1bacd2393f0e3b0
Last active August 29, 2015 14:13
A curated list of Web Component Podcasts, Screencasts, & Interviews with Web Component community members
@Nevraeka
Nevraeka / Character count
Created June 29, 2013 04:14
Some basic example code approaches and problem solving
def char_count(paragraph)
paragraph.split(%r{\s*}).count
end
def each_word_counts(paragraph)
details = {}
paragraph.split(/\s/).each { |word| details[word] = word.length }
details
end
def is_perfect_square?(x)
return false if x < 1
sqrt = Math::sqrt(x)
x == sqrt.floor**2
end
@Nevraeka
Nevraeka / Floyds Linked List Algorithm
Created July 1, 2013 05:52
Linked List detection experiment
#taken from Floyds Algorithm (http://en.wikipedia.org/wiki/Cycle_detection#Tortoise_and_hare)
def floyd(f, x0)
tortoise = f(x0)
hare = f(f(x0))
while tortoise != hare
tortoise = f(tortoise)
hare = f(f(hare))
end
mu = 0
def find_in(arr, obj)
return -1 if !arr.include?(obj)
arr.find_index obj
end
def quicksort a
(pivot = a.pop) ? quicksort(a.select{|i| i <= pivot}) + [pivot] + quicksort(a.select{|i| i > pivot}) : []
end