Skip to content

Instantly share code, notes, and snippets.

View jasonblanchard's full-sized avatar

Jason jasonblanchard

View GitHub Profile
var gui = require('nw.gui');
var menu = new gui.Menu({type:"menubar"});
// Only called on OS X
if (menu.createMacBuiltin !== undefined) {
menu.createMacBuiltin("Recorder");
}
menu.append(new gui.MenuItem({
@jasonblanchard
jasonblanchard / post.rb
Created October 14, 2014 00:55
lambdas in an ActiveRecord scope
class Post < ActiveRecord::Base
# We're passing in a lambda as the second argument to `scope`.
scope :recent, lambda { where(created_at: (Time.now - 1.hour)..Time.now) }
# This is important because if it's not passed in as a lambda,
# Time.now would be evaluated at app load time rather than execution time,
# which is almost certainly not what we mean here.
#
# Passing it in as a lambda ensures that Time.now is the time at which Post.recent is called
# in your app code.
class ArticlesController < ApplicationController
before_action :set_article, only: [:show, :edit, :update, :destroy]
def index
@articles = Article.all
@articles_category = Article.order(:category)
@users = User.all
end
def show
@mm = MiniMeet.find('5399f026dc8c101cd800014e')
first_count = @mm.participants.count
@mm.participants.each do |participant|
submission = @mm.get_user_submission(participant.id)
@mm.review_module.get_ranking_and_score(submission)
end
puts "\n\n\nBefore the loop, @mm.participants is: #{first_count}"
puts "After the loop, @mm.participants is: #{@mm.participants.count}\n\n\n"
var Person = function(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
Person.prototype.fullName = function() {
return this.firstName + " " + this.lastName;
}
var Worker = function(firstName, lastName, title) {
@jasonblanchard
jasonblanchard / gist:2fe19020141eb61cca67
Created July 13, 2014 17:32
download links from page with mechanize
require 'mechanize'
require 'open-uri'
url = 'http://33.33.33.11/nicoleandjason.us/links'
agent = Mechanize.new
page = agent.get(url)
page.links.each_with_index do |link, index|
id = rand(100) * index
proxy_vm:
name: "apprennet"
memory: 4048
cpus: 4
services:
redis:
docker_config:
image: dockerfile/redis
ports:
- 6379:6379
{:id=>"f62ebaea-2b94-48c6-a714-b3d65e97cd27", :status=>"available", :name=>nil, :status_message=>"", :session_id=>"2_MX4xMDI2MDE0Mn5-VHVlIEp1biAwMyAwNjozOTo0OCBQRFQgMjAxNH4wLjk5NDUyMjR-fg", :partner_id=>10260142, :created_at=>2014-06-03 09:48:11 -0400, :size=>35671, :duration=>30, :mode=>"automatic", :updated_at=>1401803322000, :url=>"http://tokbox.com.archive2.s3.amazonaws.com/10260142%2Ff62ebaea-2b94-48c6-a714-b3d65e97cd27%2Farchive.mp4?Expires=1401803994&AWSAccessKeyId=AKIAI6LQCPIXYVWCQV6Q&Signature=hWackDhYtNvG6Rkuml8AC0nhz9w%3D"}
<script>
var apiKey = '<%= Rails.application.config.tokbox_api_key %>';
var sessionId = '<%= session_id %>';
var token = '<%= token %>';
var session = OT.initSession(apiKey, sessionId);
session.on("streamCreated", function(event) {
session.subscribe(event.stream);
});
Apprennet.Views.MyThingView = Backbone.View.extend({
// This will initialize backbone/templates/sub_dir/my_thing.hbs into a template function
template: HandlebarsTemplates['backbone/templates/sub_dir/my_thing'],
render: function() {
// Call the template function here with an object that declares the template vars.
this.$el.html(template({name: "My Thing Name"}));
// So here, when compiled, the template will replace {{name}} with "My Thing Name".
}