This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Here is a simple jQuery plugin to make a table header fixed on top of a div when this is scrolled. | |
Using the code from twitter bootstrap documentation page, this code is customized for table header. | |
Create the table with the table-fixed-header class and a thead tag: | |
<table class="table table-striped table-fixed-header" id="mytable"> | |
<thead class="header"> | |
<tr> | |
<th>Email Address</th> | |
<th>First Name</th> | |
<th>Last Name</th> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'axlsx' | |
title = "Some report" | |
selected_columns = %w(one two three four five) | |
Axlsx::Package.new do |package| | |
package.workbook do |workbook| | |
# Disabling this will improve performance for very large documents | |
workbook.use_autowidth = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < ActiveRecord::Base | |
acts_as_authentic # I use authlogic | |
scope :with_role, lambda { |role| {:conditions => "roles_mask & #{1 << ROLES.index(role.to_s)} > 0"} } | |
ROLES = %w[admin manager client coordinator employee volunteer] | |
ROLE_DESCRIPTIONS = { | |
:admin => "Administers the entire site", | |
:manager => "Manages the entire site", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
view_assigns = {widgets: Widget.all} | |
av = ActionView::Base.new(ActionController::Base.view_paths, view_assigns) | |
av.class_eval do | |
# include any needed helpers (for the view) | |
include ApplicationHelper | |
end | |
# normal render statement | |
content = av.render template: 'widgets/index.xlsx.axlsx' | |
# do something with content, such as: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'abstract_controller' | |
require 'action_controller' | |
require 'action_view' | |
require 'active_record' | |
# require any helpers | |
require './app/helpers/application_helper' | |
# active record only if data is here | |
require './app/models/widget' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import DS from 'ember-data'; | |
export default DS.ActiveModelAdapter.extend({ | |
namespace: 'api/v4', | |
coalesceFindRequests: true | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#upload changed/new files to rails with capistrano | |
function capdu { | |
if [ -z "$1" ] | |
then | |
FILES=`gst --porcelain | grep '^ M\|^\?\?' | ruby -e 'puts ARGF.map {|l| l.split()[1]}.join(",")' | xargs echo` | |
else | |
FILES=`gst --porcelain | grep '^ M\|^\?\?' | grep $1 | ruby -e 'puts ARGF.map {|l| l.split()[1]}.join(",")' | xargs echo` | |
fi | |
if [ -z "$FILES" ] | |
then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#newsbottom { | |
position: absolute; | |
bottom: 10px; | |
left: 15px; | |
right: 15px; | |
padding: 0; | |
/* black with white text */ | |
background: rgba(0,0,0,0.3); | |
color: white; | |
/* or white with black text */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# First: | |
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done | |
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.* | |
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following: | |
#go to /usr/local/lib and delete any node and node_modules | |
cd /usr/local/lib | |
sudo rm -rf node* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from "ember"; | |
// This is an error. It should be 'ember-simple-auth/authenticators/base' | |
// Left to link to a github comment | |
import Base from 'ember-simple-auth/authorizers/base'; | |
export default Base.extend({ | |
tokenEndpoint: '/api/user_sessions', | |
authenticate: function(credentials) { | |
var _this = this; | |
return new Ember.RSVP.Promise(function(resolve, reject) { |