Skip to content

Instantly share code, notes, and snippets.

@mikermcneil
mikermcneil / custom-express-middleware.md
Created August 17, 2013 04:44
Using custom express middleware in Sails.js circa v0.9.3

Custom middleware is a legacy option, since most times you just want to use policies.

HOWEVER! There are times you want to use sails for quick/dirty things you would normally use express for (but you already have sails around, w/e). More pertinently, if you want middleware to run before the static files from your assets folder are served, policies won't let you do that.

Here's an example of using the BasicAuth middleware for everything:
// Put this in `config/express.js`
@rwjblue
rwjblue / readme.md
Last active May 13, 2016 18:10
Guide to using drip with JRuby

#Overview drip is an awesome command line tool that can be used to dramatically lower perceived JVM startup time. It does this by preloading an entirely new JVM process\instance and allowing you to simply use the preloaded environment. This has extraordinary results with jruby.

We reduced time to run rake environment from 13 seconds to a mere 3.5 seconds. This is actually at or near MRI 1.9.3p327 (with falcon patch) speeds!

Adding a few addition jruby options will reduce startup time even further (down to 1.69 seconds).

#Install Drip Install drip if you haven't already (see https://github.com/flatland/drip)

@ProLoser
ProLoser / alerts.html
Last active October 9, 2019 18:38
AngularJS Bootstrap implemented without any additional code
<h1>Alert</h1>
<p>Bootstrap JS</p>
<div class="alert fade in">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>Holy guacamole!</strong> Best check yo self, you're not looking too good.
</div>
<p></p><a ng-click="alert=true">Open Alert (AngularJS)</a></p>
<div class="alert fade" ng-class="{in:alert}">
<button type="button" class="close" ng-click="alert=false">×</button>
@headius
headius / gist:4343186
Created December 20, 2012 05:42
Running a startup flag-timing tool for JRuby users, to find the best flags on their system.
system ~/projects/jruby/blah $ jruby ../../startup_bench/lib/tune.rb 1 'touch Gemfile.lock && rm Gemfile.lock && jruby -S bundle install --quiet --local'
Beginning tuning for `touch Gemfile.lock && rm Gemfile.lock && jruby -S bundle install --quiet --local`
Trying 90 combinations of flags
--------------------------------------------------------------------------------
Last: -J-server
Average time: 8.529s
Overall average: 8.529s
Estimated completion time: 2012-12-19 23:46:27 -0600
--------------------------------------------------------------------------------
Last: -J-client
@headius
headius / gist:4156388
Created November 27, 2012 19:20
Drip experiments in JRuby
# BASELINE STARTUP TIMES WITHOUT DRIP
system ~/projects/jruby $ jruby -v
jruby 1.7.1.dev (1.9.3p327) 2012-11-26 810defe on Java HotSpot(TM) 64-Bit Server VM 1.7.0_09-b05 [darwin-x86_64]
system ~/projects/jruby $ time jruby -e 1
real 0m1.238s
user 0m1.985s
sys 0m0.091s
@trek
trek / gist:4154434
Created November 27, 2012 14:18
original notes
https://twitter.com/dagda1/status/231016636847648769
https://twitter.com/garybernhardt/status/227881347346219008/
http://ianstormtaylor.com/rendering-views-in-backbonejs-isnt-always-simple/
backbone: what you'd normally use jquery plugins for, but with an inverted rendering process (js -> DOM instead of DOM -> js)
"islands of richness", jquery data callbacks main pattern.
other frameworks are building out from jQuery's central pattern of DOM selection and event callbacks.
fantastic pattern for adding behavior to documents, but we aren't writing documents.
@tomdale
tomdale / gist:3981133
Last active November 26, 2019 21:19
Ember.js Router API v2

WARNING

This gist is outdated! For the most up-to-date information, please see http://emberjs.com/guides/routing/!

It All Starts With Templates

An Ember application starts with its main template. Put your header, footer, and any other decorative content in application.handlebars.

<header>
@headius
headius / gist:3758342
Created September 20, 2012 21:02
Startup times for base and loading ActiveRecord on JDK7 an JDK8 with various flags
Java 7 does not currently have tiered compilation on by default, and we do not enable invokedynamic.
Default settings (no indy, no tiered)
system ~/projects/jruby $ (pickjdk 4 ; time jruby -e 1)
New JDK: jdk1.7.0_07.jdk
real 0m1.255s
user 0m1.953s
sys 0m0.084s
@rlivsey
rlivsey / nav_section_mixin.coffee
Created August 9, 2012 10:54
Dynamic navigation with Ember.js
App.NavSectionMixin = Ember.Mixin.create({
enter: (router, context) ->
router.set("sectionNavigationController.current", @get("section"))
@_super(router, context)
exit: (router, context) ->
router.set("sectionNavigationController.current", null)
@_super(router, context)
})
@sundbp
sundbp / notes
Created August 2, 2012 11:30
Notes for binding_of_caller jruby support
- Perhaps can get to it without any java code: https://gist.github.com/1680784
- Interpreter only flags: https://github.com/quix/boc/blob/master/jext/boc/BocService.java
Code sections that are relevant:
- Kernel#binding: return RubyBinding.newBinding(context.runtime, context.currentBinding());
- ThreadContext:
- 1223 public Binding currentBinding(IRubyObject self) {
- 1224 Frame frame = getCurrentFrame();
- 1225 return new Binding(self, frame, frame.getVisibility(), getRubyClass(), getCurrentScope(), backtrace[backtraceIndex].clone());