Skip to content

Instantly share code, notes, and snippets.

@ecarnevale
ecarnevale / prepare-commit-msg.sh
Created Oct 3, 2019 — forked from wingleung/prepare-commit-msg.sh
Automatically prepend JIRA issue key to commit message
View prepare-commit-msg.sh
#!/bin/sh
#
# Automatically adds Jira key to commit message
#
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop)
fi
BRANCH_NAME=$(git symbolic-ref --short HEAD)
@ecarnevale
ecarnevale / api_client.empty.exs
Created May 16, 2017
Code snippets for a blog post on ExVCR
View api_client.empty.exs
# test/support/api_client.exs
defmodule ExVCR.Adapter.HackneyTest do
use ExUnit.Case, async: false
use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney
setup_all do
HTTPoison.start
end
View Alamofire Example.swift
import Alamofire
let urlString = "http://example.org/Webserver.WcfService.Service"
let headers: HTTPHeaders = [
"Accept" : "text/xml",
"Content-Type" : "text/xml; charset=UTF-8",
"SOAPAction": "http://tempuri.org/Service/GetInfo" //this is important and the value depends on your WSDL, but with our experiments, without this header nothing works
]
let parameters: Parameters = [
"UserName": "username",
View gist:c79273714fbe9ba5abfd
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => ENV['SMTP_HOST'],
:port => 587,
:authentication => :plain,
:user_name => ENV['SMTP_USERNAME'],
:password => ENV['SMTP_PASSWORD'],
:domain => ENV['SMTP_DOMAIN'],
:enable_starttls_auto => true
}
View user.rb
class User < ActiveRecord::Base
devise :trackable, :validatable, :database_authenticatable, :rememberable,
:omniauthable, :omniauth_providers => [:google_oauth2]
attr_accessible :email, :password, :password_confirmation, :remember_me, :name, :provider, :uid
def self.find_by_authentication_token(access_token)
client = OAuth2::Client.new(ENV['GOOGLE_OAUTH2_ID'],ENV['GOOGLE_OAUTH2_SECRET'])
begin
response = client.request(:get, 'https://www.googleapis.com/oauth2/v2/tokeninfo', :params => {
View application_controller.rb
class ApplicationController < ActionController::Base
# protect_from_forgery
before_filter :authenticate_user_from_token!
before_filter :authenticate_user! #for classic Devise authentication
def authenticate_user_from_token!
access_token = params[:access_token].presence
if access_token
user = User.find_by_authentication_token(access_token.to_s)
View keybase.md

Keybase proof

I hereby claim:

  • I am ecarnevale on github.
  • I am ec (https://keybase.io/ec) on keybase.
  • I have a public key whose fingerprint is CFF1 4DEF 6ADF A722 5190 D9AD 7CFC 2DB6 12FD 1FF5

To claim this, I am signing this object:

View keybase.md

Keybase proof

I hereby claim:

  • I am ec on github.
  • I am ec (https://keybase.io/ec) on keybase.
  • I have a public key whose fingerprint is CFF1 4DEF 6ADF A722 5190 D9AD 7CFC 2DB6 12FD 1FF5

To claim this, I am signing this object:

@ecarnevale
ecarnevale / fullscreen-24.diff
Created Mar 29, 2012 — forked from the-kenny/fullscreen-24.diff
Add ns-toggle-fullscreen to Emacs 24
View fullscreen-24.diff
diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el
index 084b62f..b7ed1a2 100644
--- a/lisp/term/ns-win.el
+++ b/lisp/term/ns-win.el
@@ -1267,6 +1267,10 @@ the operating system.")
(add-to-list 'window-system-initialization-alist '(ns . ns-initialize-window-system))
+(declare-function ns-toggle-fullscreen-internal "nsfns.m" ())
+(defun ns-toggle-fullscreen ()
@ecarnevale
ecarnevale / gist:2108860
Created Mar 19, 2012 — forked from marcel/gist:2100703
giftube – Generates an animated gif from a YouTube url.
View gist:2108860
#!/usr/bin/env ruby
# giftube – Generates an animated gif from a YouTube url.
#
# Usage:
#
# giftube [youtube url] [minute:second] [duration]
#
# ex.
#