Skip to content

Instantly share code, notes, and snippets.

View dalpo's full-sized avatar
💭
I'm still learning...

Andrea Dal Ponte dalpo

💭
I'm still learning...
View GitHub Profile
@dalpo
dalpo / bootstrap_wysihtml5_overrides.js
Created September 30, 2016 10:35
Bootstrap wysihtml5 text alignment implementation
!function($, wysi) {
"use strict";
var tpl = {
"font-styles": function(locale, options) {
var size = (options && options.size) ? ' btn-'+options.size : '';
return "<li class='dropdown'>" +
"<a class='btn btn-default dropdown-toggle" + size + "' data-toggle='dropdown' href='#' title='" + locale.font_styles.title + "'>" +
"<i class='glyphicon glyphicon-font'></i>&nbsp;<span class='current-font'>" + locale.font_styles.normal + "</span>&nbsp;<b class='caret'></b>" +
"</a>" +
Failures:
1) Admin::ColorPalettesController POST #create with NOT authenticated user should redirect to the login page
Failure/Error: post :create, params: { color_palette: valid_attributes }
ActionDispatch::IllegalStateError:
header already sent
# /home/dalpo/.rvm/gems/ruby-2.3.1/gems/actionpack-5.0.0.rc2/lib/action_dispatch/http/response.rb:44:in `[]='
# /home/dalpo/.rvm/gems/ruby-2.3.1/gems/actionpack-5.0.0.rc2/lib/action_dispatch/http/response.rb:180:in `set_header'
# /home/dalpo/.rvm/gems/ruby-2.3.1/gems/actionpack-5.0.0.rc2/lib/action_dispatch/http/response.rb:420:in `set_content_type'
@dalpo
dalpo / puma
Created April 28, 2016 14:50 — forked from niwo/puma
puma with rbenv on CentOS 6
#!/bin/sh
#
# puma - this script starts and stops the puma daemon
#
# chkconfig: - 85 15
# description: Description \
# goes here...
# processname: puma
# config: /etc/puma.conf
# pidfile: /home/stanislaw/apps/micro-apps/puma/puma.pid
@dalpo
dalpo / Readme.txt
Last active August 29, 2015 14:23 — forked from simonbru/Readme.txt
This is a Python script to extract GNOME/GTK's color scheme and apply it to Wine, so that the themes (approximately) match.
Instructions:
1. Set your Gnome theme as you would like it
2. Run with a command like "python wine_colors_from_gtk.py"
3. Restart any apps running in Wine. They should match the Gnome theme colors now.
Better description with screenshots here: http://www.endolith.com/wordpress/2008/08/03/wine-colors/
This is also stored on https://code.launchpad.net/~endolith/+junk/wine-color-scraper

Javascript

  • Indent using 2 spaces
  • Use single quotes, unless you are writing JSON
  • Declare one variable per var statement
  • Variables and properties should use lower camel case capitalization
  • Class names should be capitalized using upper camel case
  • Constants should be declared as regular variables or static class properties, using all uppercase letters
  • Use the triple equality operator
@dalpo
dalpo / blueimp-gallery-videojs.css.sass
Last active August 29, 2015 14:03
bluimp-gallery videojs integration
module PdfHelper
def wicked_pdf_stylesheet_link_tag(*sources)
sources.collect { |source|
asset = Rails.application.assets.find_asset("#{source}.css")
if asset.nil?
raise "could not find asset for #{source}.css"
else
"<style type='text/css'>#{asset.body}</style>"
end
}.join("\n").gsub(/url\(['"](.+)['"]\)(.+)/,%[url("#{wicked_pdf_image_location("\1")}")\2]).html_safe
@dalpo
dalpo / policy_helper.rb
Created April 2, 2014 09:52
Rails with Pundit policy helper
module PolicyHelper
def can?(action, subject)
policy(subject).try "#{action}?"
end
def policy_helper_arguments(*args, &block)
object = args[0]
if block_given?
@dalpo
dalpo / simple_form_validation.rb
Created January 20, 2014 11:29
SimpleForm validation fix
module SimpleForm
module Inputs
class Base
private
def valid_validator?(validator)
# conditional validators are no surprise to us, so just check the action:
action_validator_match?(validator)
end
= simple_form_for @post, html: { class: 'form-horizontal' }, defaults: { wrapper: :horizontal_form } do |f|
= f.error_notification
.form-inputs
= f.input :first_name
= f.input :last_name
= f.input :email
.form-actions
= f.button :submit