Skip to content

Instantly share code, notes, and snippets.

View regedarek's full-sized avatar
🏠
Working from home

Darek Finster regedarek

🏠
Working from home
View GitHub Profile
@regedarek
regedarek / accounts.rb
Last active August 29, 2015 14:05
Example Versioning App in Sinatra
# app/routes/v2/accounts.rb
module Oauth2Provider
module Routes
module V2
class Accounts < Base
get '/accounts' do
content_type :json
'version 2'
end
end

This will allow you to use devise's TokenAuthenticatable strategy while passing your :auth_token in using HTTP Authorization headers instead of params.

You can check it out using

curl -H "Authorization: Token token=XXXXXX, option=1" -vv http://railsapp.dev/api/v1/endpoint.json

It should properly authenticate using the token as well as set request.env['token.options'] to {"options" => "1"}.

class Leg
include ActiveModel::Validations
include ActiveModel::Naming
include ActiveModel::Conversion
include Virtus
attribute :start_day, Integer
attribute :end_day, Integer
end
require 'delegate'
module Presenter
def presenter
presenter = "#{self.class.name}Presenter".constantize
presenter.new(self)
end
# Example of usage:
#
.right
= image 'nav_divider', class: 'r'
= link_to '#' do
= icon 'nav_settings', 54
-# %span= truncate current_user.name, length: 10
= image 'nav_divider', class: 'r'
= link_to cardiologist_conversations_path do
= icon 'nav_conversations', 54
- unless current_user.mailbox.inbox(unread: true).empty?
*Tunnelblick: OS X 10.9.1; Tunnelblick 3.4beta20 (build 3727); prior version 3.4beta18 (build 3704); Admin user
"Sanitized" configuration file for /Library/Application Support/Tunnelblick/Shared/redcom.tblk:
##############################################
# Sample client-side OpenVPN 2.0 config file #
# for connecting to multi-client server. #
# #
# This configuration can be used by multiple #
# clients, however each client should have #
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
brew doctor
brew tap homebrew/dupes
brew install zsh
brew install tmux
brew install reattach-to-user-namespace
#include "ruby.h"
#include "edflib.h"
static VALUE EdfConverter;
char *path;
/* edf file description */
struct edf_hdr_struct hdr;
/* a handle (identifier) used to distinguish the different files */
int hdl;
/*
*****************************************************************************
*
* Copyright (c) 2009, 2010, 2011 Teunis van Beelen
* All rights reserved.
*
* email: teuniz@gmail.com
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
class Importer
CONN = ActiveRecord::Base.connection
F = "00F"
I = "00I"
def extract_to_database(collection) # collection is a file
add = true
tmp = []
type = F
inserts = []