Skip to content

Instantly share code, notes, and snippets.

var foo = 1;
function bar() {
if (!foo) {
var foo = 10;
}
alert(foo);
}
bar();
var a = 1;
class NewsController < ApplicationController
meta_data :news, [:index]
def index
puts "page = #{@page}"
render text: @page
end
end
+----------------------+-------+-------+---------+---------+-----+-------+
| Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
+----------------------+-------+-------+---------+---------+-----+-------+
| Controllers | 6209 | 4670 | 71 | 546 | 7 | 6 |
| Helpers | 362 | 308 | 0 | 46 | 0 | 4 |
| Models | 2850 | 1919 | 84 | 262 | 3 | 5 |
| Mailers | 164 | 141 | 3 | 18 | 6 | 5 |
| Javascripts | 15487 | 11331 | 1 | 1170 | 1170 | 7 |
| Libraries | 2536 | 1852 | 26 | 122 | 4 | 13 |
| Model specs | 38 | 29 | 0 | 0 | 0 | 0 |
@jurgens
jurgens / template
Last active August 29, 2015 14:10
widget embedding
<div class="slider-container">
<div class="slider-clip">
<ul id="ts-premium-container"></ul>
</div>
<ul class="slider-controls">
<li class="prev">
<a href="#prev">Previous</a>
</li>
<li class="next">
<a href="#next">Next</a>
@jurgens
jurgens / rake_stats
Created October 24, 2014 07:57
Test statistics
+----------------------+-------+-------+---------+---------+-----+-------+
| Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
+----------------------+-------+-------+---------+---------+-----+-------+
| Controllers | 1549 | 1256 | 54 | 215 | 3 | 3 |
| Helpers | 461 | 384 | 0 | 45 | 0 | 6 |
| Models | 1677 | 1295 | 44 | 133 | 3 | 7 |
| Mailers | 34 | 29 | 3 | 4 | 1 | 5 |
| Javascripts | 7858 | 5427 | 0 | 588 | 0 | 7 |
| Libraries | 1608 | 1378 | 14 | 86 | 6 | 14 |
| Controller specs | 238 | 191 | 0 | 0 | 0 | 0 |
Wondr.Views.Header = Backbone.Marionette.ItemView.extend
el: 'header'
update_state: (current) ->
@$('#primary li').removeClass('current')
@$("#primary li.#{current}").addClass('current') if current?
init: ->
$( '.account' ).makisu({
+----------+---------------+
| count(*) | DATE(created) |
+----------+---------------+
| 11 | 2014-01-01 |
| 8 | 2014-01-02 |
| 24 | 2014-01-03 |
| 13 | 2014-01-04 |
| 3 | 2014-01-05 |
| 25 | 2014-01-06 |
| 30 | 2014-01-07 |
@jurgens
jurgens / app_models_model.rb
Last active August 29, 2015 14:02
elasticsearch/tire setup
class Model < ActiveRecord::Base
include Tire::Model::Search
include Tire::Model::Callbacks
mapping do
indexes :id, :index => :not_analyzed
indexes :custom_id, :index => :not_analyzed
indexes :slug, :index => :not_analyzed
indexes :name, :analyzer => 'snowball', boost: 3
root@new:~# apt-get install postgresql postgresql-contrib
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
libossp-uuid16 libpq5 libxslt1.1 postgresql-9.1 postgresql-client-9.1 postgresql-client-common postgresql-common postgresql-contrib-9.1 ssl-cert
Suggested packages:
uuid oidentd ident-server locales-all postgresql-doc-9.1 libdbd-pg-perl openssl-blacklist
The following NEW packages will be installed:
libossp-uuid16 libpq5 libxslt1.1 postgresql postgresql-9.1 postgresql-client-9.1 postgresql-client-common postgresql-common postgresql-contrib postgresql-contrib-9.1 ssl-cert
@jurgens
jurgens / init_map.js.coffee
Created March 5, 2014 15:21
show single point on a google map
class InitMap
constructor: (element, data) ->
latlng = new google.maps.LatLng(data.lat, data.long)
options =
zoom: 12
center: latlng
mapTypeId: google.maps.MapTypeId.ROADMAP
map = new google.maps.Map(element, options)