Skip to content

Instantly share code, notes, and snippets.

View denro's full-sized avatar
💭
🤔

Dennis Rogenius denro

💭
🤔
View GitHub Profile
@denro
denro / gist:39275eb435099992e635
Created July 8, 2015 09:15
Should to Expect Vim macro
0wiexpect(/should
hcE).to:s/==/eq/e
0j
func authenticateBearer(c *echo.Context) error {
// Look for an Authorization header
if ah := c.Request().Header.Get("Authorization"); ah != "" {
// Should be a bearer token
if len(ah) > 6 && ah[0:6] == "Bearer" {
// Parse rest of header and verify with the secret
if token, err := jwt.Parse(ah[7:], tokenSecret); err == nil && token.Valid {
c.Set("token", token)
return nil
@denro
denro / test
Created December 6, 2014 16:19
Nordnet API test
require 'openssl'
require 'base64'
require 'uri'
require 'json'
require 'net/http'
require 'byebug'
username = 'username'
password = 'password'
service = 'NEXTAPI'
# Formatter for just putting out the error message during runtime
# use with Rspec by --require <path_to_this_file> --formatter FailuresDuringRunFormatter
require 'spec/runner/formatter/progress_bar_formatter'
class FailuresDuringRunFormatter < Spec::Runner::Formatter::ProgressBarFormatter
def example_failed(example, counter, failure)
super #show the 'F' in progress
dump_failure(counter, failure)
end
end