Skip to content

Instantly share code, notes, and snippets.

@shlomizadok
shlomizadok / gist:2146712
Created March 21, 2012 12:55
Can't connect to github - everyauth
var express = require('express')
, routes = require('./routes')
, everyauth = require('everyauth');
var app = module.exports = express.createServer();
everyauth.github
.appId('myID')
.appSecret('MySecret')
.scope('user')
@shlomizadok
shlomizadok / omniauth_callbacks_controller.rb
Created May 19, 2012 10:37
How to integrate Omniauth and API
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
def facebook
@user = User.find_for_facebook_oauth(request.env["omniauth.auth"], current_user)
if @user.persisted?
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Facebook"
sign_in_and_redirect @user, :event => :authentication
else
session["devise.facebook_data"] = request.env["omniauth.auth"]
redirect_to new_user_registration_url
@shlomizadok
shlomizadok / docspilt.rb
Created January 16, 2013 09:45
Extract svg with Docsplit. ** You need inkscape (http://inkscape.org/) installed on your machine I use it like that: ::Docsplit.extract_svg(current_path, :format => :svg, output: output_path)
module Docsplit
def self.extract_svg(pdfs, opts={})
pdfs = ensure_pdfs(pdfs)
SvgExtractor.new.extract(pdfs, opts)
end
class SvgExtractor
@shlomizadok
shlomizadok / _form.html.erb
Created February 6, 2013 09:32
Demonstrates how one can set own cypher for encrypting file with carrierwave_securefile
<%= form_for @book, :html => {:multipart => true} do |f| %>
<% if @book.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@book.errors.count, "error") %> prohibited this book from being saved:</h2>
<ul>
<% @book.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.10/lib/active_record/connection_adapters/postgresql_adapter.rb:1061:in `async_exec'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.10/lib/active_record/connection_adapters/postgresql_adapter.rb:1061:in `exec_no_cache'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.10/lib/active_record/connection_adapters/postgresql_adapter.rb:615:in `block in exec_query'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.10/lib/active_record/connection_adapters/abstract_adapter.rb:245:in `block in log'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.10/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.10/lib/active_record/connection_adapters/abstract_adapter.rb:240:in `log'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290/gems/newrelic_rpm-3.5.5.38/lib/new_relic/agent/instrumentation/active_record.rb:32:in `block in log_with_newrelic_instrumentati
@shlomizadok
shlomizadok / application.rb
Last active August 29, 2015 13:55
When need to consider data from SettingsLogic in CoffeeScript
# put this below in your application.rb
module AssetsInitializers
class Railtie < Rails::Railtie
initializer "assets_initializers.initialize_rails",
:group => :assets do |app|
require "#{Rails.root}/lib/settings.rb"
end
end
end
@shlomizadok
shlomizadok / 10-post_install_message.rb
Created November 11, 2014 22:26
Suggestion to fix #8008
# Puppet status codes say 0 for unchanged, 2 for changed succesfully
if [0,2].include? @kafo.exit_code
say " <%= color('Success!', :good) %>"
else
say " <%= color('Something went wrong!', :bad) %> Check the log for ERROR-level output"
end
# Foreman UI?
if @kafo.config.module_enabled? 'foreman'
say " * <%= color('Foreman', :info) %> is running at <%= color('#{param('foreman','foreman_url').value}', :info) %>"
@shlomizadok
shlomizadok / gist:4de1009e6fd33ec33c71
Last active August 29, 2015 14:20
How to run rails with ssl in development
@shlomizadok
shlomizadok / fog_vsphere.rb
Created August 26, 2015 08:34
connect to vmware from foreman console
foreman-rake console
f = Fog::Compute.new(:provider => "vsphere", :vsphere_username => "YOUR_USERNAME", :vsphere_password=> "YOUR_PASSWORD", :vsphere_server => "SERVER_IP", :vsphere_expected_pubkey_hash => "HASH_KEY_FROM_FOREMAN_e50d75d6039b177eb5ec59f79d147c")
f.datacenters
package controllers
import (
"beego_react/models"
"github.com/astaxie/beego"
"strconv"
)
type PostController struct {
beego.Controller