This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Given a table stat with primary key "slug" with data | |
# [{slug: 'foo', stats: {}}, {slug:'bar', stats:{}}] | |
updated_stats = { | |
'foo' => {a: 1, b: 2}, | |
'bar' => {a: 3, b: 4} | |
} | |
# I can do this | |
updated_stats.each{|k,v| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# why not? | |
def power(n) | |
2 ** n | |
end | |
# if you must do it the brute force way | |
def power(n) | |
return 1 if n == 0 | |
(1..[0,n-1].max).reduce(2) { |acc, n| acc * 2 } | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rspec' | |
require 'aws-sdk-core' | |
require 'awesome_print' | |
require 'pry-byebug' | |
ks = [:creation_date, :name] | |
class AwsResponse < Struct.new(*ks) | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
doctype html | |
html.no-touch[lang="en"] | |
head | |
meta[charset="utf-8"] | |
title | |
| Mobile first web app theme | first | |
meta[name="description" content="mobile first, app, web app, responsive, admin dashboard, flat, flat ui"] | |
meta[name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"] | |
= stylesheet_link_tag 'application', media: 'all' | |
= javascript_include_tag 'application' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var rBusApp = angular.module('rBusApp', ['restangular','ui.router']); | |
rBusApp.config(["$stateProvider", "$urlRouterProvider", function($stateProvider, $urlRouterProvider) { | |
$urlRouterProvider.otherwise('/'); | |
$stateProvider. | |
state('index', | |
{url: '/', templateUrl: "landing.html", controller: 'landingController'} | |
). | |
state('routes', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html><html class="no-touch" lang="en"><head><meta charset="utf-8" /><title>Mobile first web app theme | first</title><meta content="mobile first, app, web app, responsive, admin dashboard, flat, flat ui" name="description" /><meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport" /><link rel="stylesheet" media="all" href="/assets/bootstrap.css?body=1" /> | |
<link rel="stylesheet" media="all" href="/assets/font-awesome.min.css?body=1" /> | |
<link rel="stylesheet" media="all" href="/assets/font.css?body=1" /> | |
<link rel="stylesheet" media="all" href="/assets/plugin.css?body=1" /> | |
<link rel="stylesheet" media="all" href="/assets/style.css?body=1" /> | |
<link rel="stylesheet" media="all" href="/assets/landing.css?body=1" /> | |
<link rel="stylesheet" media="all" href="/assets/app.css?body=1" /> | |
<link rel="stylesheet" media="all" href="/assets/application.css?body=1" /><script src="/assets/jquery.js?body=1"></script> | |
<script src="/assets/angular.js?body=1"></script> | |
<script src="/assets/an |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#controllers/application.rb | |
... | |
class Hash | |
def diff(other) | |
keys = self.keys | |
keys.each.select{|k| self[k] != other[k]} | |
end | |
end | |
#config/init.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; example rails like console for compojure showing params, etc. for each request | |
(ns bus.core | |
(:use compojure.core | |
ring.adapter.jetty | |
... | |
... | |
(:use ring.middleware.params)) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git diff | |
diff --git a/ruby-mode.el b/ruby-mode.el | |
index b556e95..838d811 100644 | |
--- a/ruby-mode.el | |
+++ b/ruby-mode.el | |
@@ -1169,7 +1169,7 @@ balanced expression is found." | |
2 font-lock-type-face) | |
;; symbols | |
'("\\(^\\|[^:]\\)\\(:\\([-+~]@?\\|[/%&|^`]\\|\\*\\*?\\|<\\(<\\|=>?\\)?\\|>[>=]?\\|===?\\|=~\\|\\[\\]=?\\|\\(\\w\\|_\\)+\\([!?=]\\|\\b_*\\)\\|#{[^}\n\\\\]*\\(\ | |
- 2 font-lock-reference-face) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LoanHistory | |
include DataMapper::Resource | |
property :loan_id, Integer, :key => true | |
property :date, Date, :key => true # the day that this record applies to | |
property :created_at, DateTime # automatic, nice for benchmarking runs | |
# some properties for similarly named methods of a loan: | |
property :scheduled_outstanding_total, Decimal, :nullable => false |
OlderNewer