Skip to content

Instantly share code, notes, and snippets.

View magicmarkker's full-sized avatar

Mark Hunt magicmarkker

  • Philadelphia, PA
View GitHub Profile
@magicmarkker
magicmarkker / gist:309bcee507dd7b770768
Created December 16, 2014 15:41
modify cpus and mem
config.vm.network :forwarded_port, guest: 3000, host: 3000
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
config.vm.provider :virtualbox do |vm|
vm.customize ["modifyvm", :id, "--name", project]
vm.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
host = RbConfig::CONFIG['host_os']
module Auditable
extend ActiveSupport::Concern
# @TODO: Figure out a way around this?
# This causes the session to not exist in rspec
included do
if Rails.env != "test"
audited except: [:heartbeat, :try], allow_mass_assignment: true
end
end
def map_style(field, args={})
args.reverse_merge!(font: "Helvetica", color: "#000000", size: "18px", style: "normal")
(agenda, name, type) = field.split("_")
if self.agenda_styles.nil? or self.agenda_styles[name.to_sym].nil?
self.send("#{field}=", args[type.to_sym])
else
self.send("#{field}=", self.agenda_styles[name.to_sym][type.to_sym])
end
+----+-----------+-----------------------+-----------+----------------+----------------------------------------+------------+--------+---------------+------------+------------+------------+----------+
| id | client_id | name | parent_id | efolders_count | description | toolkit_id | shared | pdf_encrypted | created_at | updated_at | importpath | ancestry |
+----+-----------+-----------------------+-----------+----------------+----------------------------------------+------------+--------+---------------+------------+------------+------------+----------+
| 46 | 1 | Board Meeting Minutes | NULL | 3 | Description for board meeting minutes. | NULL | 0 | 0 | NULL | NULL | NULL | NULL |
| 47 | 1 | Committee Folders | NULL | 3 | Description for committee folders. | NULL | 0 | 0 | NULL | NULL | NULL | NULL |
| 48 | 1 |
class Efolder < ActiveRecord::Base
include Scopeable::Clientable
has_many :vfiles, as: :vfileable, dependent: :destroy
has_and_belongs_to_many :users, join_table: "efolders_users", foreign_key: "efolder_id"
has_and_belongs_to_many :committees
has_ancestry
validates :name, presence: true
before_save :share_me
# routes.rb
resources :committees, as: :workrooms, path: :workrooms do
resources :meetings, concerns: :bookable
end
# Generates
# workroom_meeting_book GET /workrooms/:workroom_id/meetings/:meeting_id/books/:id(
polymorphic_path([@workroom, @meeting, @book])
# But since @workroom is really a Committee model
@magicmarkker
magicmarkker / gist:4676258
Last active December 11, 2015 23:19
HelpDesk Ticket # lookup
javascript:(function(){var%20v=%221.8.0%22;if(window.jQuery===undefined%20||%20window.jQuery.fn.jquery%20%3C%20v){var%20done=false;var%20script=document.createElement(%22script%22);script.src=%22http://ajax.googleapis.com/ajax/libs/jquery/%22+v+%22/jquery.min.js%22;script.onload=script.onreadystatechange=function(){if(!done%20%26%26(!this.readyState%20||%20this.readyState==%22loaded%22%20||%20this.readyState==%22complete%22)){done=true;initMyBookmarklet();}};document.getElementsByTagName(%22head%22)[0].appendChild(script);}else{initMyBookmarklet();}function%20initMyBookmarklet(){var%20base_url='http://hd.dev.boardeffect.com';if(!$('%23lookup_container').length){$('head').append('%3Clink%20rel=%22stylesheet%22%20href=%22'+base_url+'/assets/bookmark.css%22%20type=%22text/css%22%20/%3E');$(%22%3Cdiv/%3E%22,{id:%22lookup_container%22,class:%22well%22,html:$(%22%3Cform/%3E%22,{id:%22lookup%22})}).appendTo(%22body%22);$('%3Ca%20/%3E',{href:%22%23%22,html:%22x%22,class:'close'}).prependTo('%23lookup_container%20');$
@magicmarkker
magicmarkker / gist:4674021
Last active December 11, 2015 23:08
Sass snippet to create a css banner on (currently) left side of a block element
=banner
float: none
position: relative
width: 20%
font-size: 1.2em
font-weight: normal
padding: 6px 10px 6px 30px
margin: 0px 10px 10px -30px
color: #626262
background-color: darken(#f5f5f5, 10%)
@magicmarkker
magicmarkker / insert.js
Created November 12, 2012 19:30
Insert at caret
jQuery.fn.extend({
insertAtCaret: function(myValue) {
return this.each(function(i) {
var endPos, scrollTop, sel, startPos;
if (document.selection) {
this.focus();
sel = document.selection.createRange();
sel.text = myValue;
return this.focus();
@magicmarkker
magicmarkker / isMobile.js
Created November 12, 2012 19:29
isMobile
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i) ? true : false;
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i) ? true : false;
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i) ? true : false;
},