Skip to content

Instantly share code, notes, and snippets.

Avatar

Nicolay Hvidsten nicohvi

View GitHub Profile
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>title</title>
<script type="text/javascript" src="assets/javascripts/jQuery.js"></script>
<style>
.big {
font-size: 42pt;
}
@nicohvi
nicohvi / gist:7248457
Created Oct 31, 2013
Modular javascript
View gist:7248457
var Order = function($el) {
// private variables
el = $el;
// public API
var Order = {
removeTarget: function() {
el.find('#order-target').remove();
View nodejitsu-output
info: Welcome to Nodejitsu nicohvi
info: jitsu v0.13.14, node v0.10.15
info: It worked if it ends with Nodejitsu ok
info: Executing command deploy
info: Analyzing application dependencies in coffee marvin.coffee
debug: { method: 'GET',
debug: uri: 'https://api.nodejitsu.com/apps/nicohvi/marvin',
debug: headers:
debug: { Authorization: '*****************************************************************',
debug: 'Content-Type': 'application/json',
View gist:25d5d7878a18729fd749
ReactTransition = React.addons.CSSTransitionGroup
Component = React.createClass
displayName: 'component'
render: ->
section className: 'component',
ReactTransition transitionName: 'fadeIn',
SubComponent()
@nicohvi
nicohvi / hof.js
Last active Aug 29, 2015
Functional programming
View hof.js
function whosTopDog(dogs, comparison) {
for (var i=0; i < dogs.length; i++) comparison(dogs[i]);
}
whosTopDog(['ice cube', '50 cent', 'snoop'], function(dog) {
if(dog === 'snoop dog') {
console.log(dog+ ' is top deg.');
}
else {
console.log(dog+ ' is a bitch.');
View shudder.feature
Given /^the person "(.*?)" should not be "(*.?)"$/
@nicohvi
nicohvi / sprockets.rb
Created Nov 7, 2014
Ruby script for compiling haml and coffeescript
View sprockets.rb
require 'haml'
require 'coffee-script'
@root = Dir.pwd
@coffee = "#{@root}/_coffee"
@haml = "#{@root}/_haml"
def compile_coffeescript
target, javascript = "#{@root}/public/application.js", '' # 1
Dir.glob("#{@coffee}/*.coffee") do |coffeescript| # 2
View sprockets.rb
require 'listen'
require 'haml'
require 'coffee-script'
require 'uglifier'
@root = Dir.pwd
@haml = "#{@root}/_haml"
@coffee = "#{@root}/_coffee"
def compile_haml(file)
View stack_machine.rb
require 'minitest/autorun'
require 'byebug'
def stack_machine(string)
result = []
numbers = []
string.split.each do |token|
if /(\d)/.match(token)
numbers << Integer(token)