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
<link rel="import" href="../topeka-elements/category-icons.html"> | |
<link rel="import" href="../core-icon/core-icon.html"> | |
<polymer-element name="my-element"> | |
<template> | |
<style> | |
:host { | |
position: absolute; | |
width: 100%; |
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
jwk_map = %{ "kty" => "oct", "k" => :base64url.encode("secret")} | |
jws_map = %{ "alg" => "HS256" } | |
jwt_map = %{ "test" => true } | |
signature = JOSE.JWT.sign(jwk_map, jws_map, jwt_map) | |
signature_compacted = JOSE.JWS.compact(signature) | |
{_, signature_map} = JOSE.JWS.expand(signature_compacted) | |
payload = JOSE.JWT.from(:base64url.decode(Map.get(signature_map, "payload"))) | |
# one-liner version: |
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
<?xml version="1.0" encoding="ISO-8859-1"?> | |
<?xml-stylesheet type="text/xsl" href="cdcatalog.xsl"?> | |
<!-- Edited by XMLSpy® --> | |
<catalog> | |
<cd> | |
<title>Empire Burlesque</title> | |
<artist>Bob Dylan</artist> | |
<country>USA</country> | |
<company>Columbia</company> | |
<price>10.90</price> |
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
# products: | |
# - _id | |
# - name | |
# - kraken_id | |
# - parent_id | |
class Product | |
include Mongoid::Document | |
include Mongoid::Kraken | |
field :name, :type => String | |
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
resources :categories | |
## equivalent to: | |
get '/categories(.:format)' => 'categories#index', :as => :categories | |
post '/categories(.:format)' => 'categories#create' | |
get '/categories/new(.:format)' => 'categories#new', :as => :new_category | |
get '/categories/:id/edit(.:format)' => 'categories#edit', :as => :edit_category | |
get '/categories/:id(.:format)' => 'categories#show', :as => :category | |
put '/categories/:id(.:format)' => 'categories#update' |
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
resources :categories, :constraints => { :id => /.+?/ } | |
## equivalent to: | |
get '/categories(.:format)' => 'categories#index', :as => :categories | |
post '/categories(.:format)' => 'categories#create' | |
get '/categories/new(.:format)' => 'categories#new', :as => :new_category | |
get '/categories/*id/edit(.:format)' => 'categories#edit', :as => :edit_category | |
get '/categories/*id(.:format)' => 'categories#show', :as => :category | |
put '/categories/*id(.:format)' => 'categories#update' |
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
# paste into a rails console | |
# usage: 99.bottles.of_beer.on_the_wall.sing! | |
# alternate: 24.bottles.of_water.on_my_desk.sing! | |
class Bottle < ::ActiveSupport::BasicObject | |
attr_accessor :value, :type, :where | |
def initialize(value, type = nil, where = nil) #:nodoc: | |
@value, @type, @where = value, type, where | |
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
<!-- jQuery library for embedding gists in blog posts, etc. --> | |
<div id="1352696" class="gist"></div> | |
<!-- or --> | |
<div id="gist-1352696" class="gist"></div> | |
<script src="http://gist.pagodabox.com/jquery.gist.js"></script> |
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> | |
<head> | |
<script class="jsbin" src="http://code.jquery.com/jquery-1.7.1.min.js"></script> | |
<meta charset=utf-8 /> | |
<title>JS Bin</title> | |
<!--[if IE]> | |
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> | |
<![endif]--> | |
<script src="https://raw.github.com/brandonaaron/jquery-mousewheel/master/jquery.mousewheel.js"></script> |
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 'digest/md5' | |
def bson_id | |
[ | |
'%08x' % Time.now.utc.to_i, # 4 bytes | |
Digest::MD5.hexdigest(`hostname`.strip)[0..5], # 3 bytes | |
'%04x' % $$, # 2 bytes | |
'%06x' % rand(0..('f' * 6).to_i(16)) # 3 bytes | |
] # 12 bytes total | |
end |
OlderNewer