Skip to content

Instantly share code, notes, and snippets.

View harrylove's full-sized avatar

Harry Love harrylove

View GitHub Profile
max, vol, memo = 0, 0, 0
[2, 5, 1, 3, 1, 2, 1, 7, 7, 6].each do |n|
if n > max
max = n
vol += memo
memo = 0
else
memo += max - n
end
end
@harrylove
harrylove / nginx.conf
Last active December 23, 2015 00:59
nginx conf file for Meteor on EC2
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
@harrylove
harrylove / README
Last active August 30, 2016 07:58 — forked from fightingtheboss/deploy.rb
Capistrano deploy script for Meteor on AWS running RedHat
This assumes you've already set up your instance with node, npm, forever, mongodb, configured ports, and have optionally added a web server like nginx to proxy access to meteor.
Local
1. Install Ruby
2. gem install capistrano
3. cd /your/meteor/project
4. capify .
5. edit config/deploy.rb as needed with below
AWS
@harrylove
harrylove / README.md
Last active December 17, 2015 14:09
Demonstration of reactive views in Meteor

You already know about reactive data sources. Views can be made reactive as well. Technically speaking, we make the view a reactive data source by storing it in the database and observing changes.

  1. Create a new app.
  2. Delete the default html, js, and css.
  3. Put the code below into a js file and run meteor.
  4. Then use the console to change either the View "html" property or the Number "val" property. (see code for examples)
  5. Try inserting and updating your own views and numbers.

N.B. The code is not an example of best practice, just a proof of concept. It relies on functions that are included in the Meteor Handlebars package. These functions could change or be removed in the future.

@harrylove
harrylove / template.html
Last active April 21, 2018 11:52
Nested template problem, deployed to http://nestedtemplate.meteor.com/
<head>
<title>conditional templates</title>
</head>
<body>
Open the console. Session.set('active') to 'foo' or 'bar'. Then set the foo contents with Session.set('fooContents') to 'foofoo' and 'foobar'. Set bar contents with Session.set('barContents') to 'barfoo' or 'barbar', respectively.
{{> main }}
</body>
@harrylove
harrylove / gist:3860060
Created October 9, 2012 17:02
Install Ruby Enterprise Edition from source on SmartOS
# Install any dependencies with pkgin
pkgin in gmake ruby18 readline ncurses gcc47 curl apr apr-util apache ap22-xsendfile postgresql91
# Install REE
env CFLAGS="-I/opt/local/include -O2 -fno-tree-dce -fno-optimize-sibling-calls" ./ruby-enterprise/installer
# Test for segfault
gem update --system
wpcf7_add_shortcode( 'text', 'wpcf7_text_shortcode_handler', true );
wpcf7_add_shortcode( 'text*', 'wpcf7_text_shortcode_handler', true );
wpcf7_add_shortcode( 'email', 'wpcf7_text_shortcode_handler', true );
wpcf7_add_shortcode( 'email*', 'wpcf7_text_shortcode_handler', true );
wpcf7_add_shortcode( 'tel', 'wpcf7_text_shortcode_handler', true );
wpcf7_add_shortcode( 'text', 'wpcf7_text_shortcode_handler', true );
wpcf7_add_shortcode( 'text*', 'wpcf7_text_shortcode_handler', true );
wpcf7_add_shortcode( 'email', 'wpcf7_text_shortcode_handler', true );
wpcf7_add_shortcode( 'email*', 'wpcf7_text_shortcode_handler', true );
@harrylove
harrylove / gist:1230566
Created September 20, 2011 22:11
A simple wrapper function in JavaScript - more fun with closures
var truth = function() { return true; };
var relativeTruth = function() { return false; };
var assert = function(func) {
return func() == true;
};
var wrapper = function(func) {
// perform setup work here
@harrylove
harrylove / gist:1230292
Created September 20, 2011 20:52
Fun with JavaScript closures
console.info('* TRUTH *');
var truth = function() { return true; };
console.info(truth); // function()
console.info(truth()); // true
console.info('* F *');
var origF = function(arg) { return arg; };
var f = origF;
console.info(f); // function()