Skip to content

Instantly share code, notes, and snippets.

# 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
require 'rspec'
require 'aws-sdk-core'
require 'awesome_print'
require 'pry-byebug'
ks = [:creation_date, :name]
class AwsResponse < Struct.new(*ks)
end
@svs
svs / gist:7fc59be7b4b0cc68b699
Last active August 1, 2019 10:39
Too Many `a`s (with apologies to Dr Seuss)
(Original here http://www.poetryfoundation.org/poem/171612)
Did I ever tell you that Programmer McCave
Had twenty-three variables and he named them all `a`
Well, he did. And that wasn't a smart thing to do.
You see, when he wants wants to add `a` to 2
He doesn't get a number oh no no no
All twenty-three `a`s cause a buffer overflow
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'
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',
<!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