Skip to content

Instantly share code, notes, and snippets.

View lxcodes's full-sized avatar

Alexander lxcodes

  • fh group
  • Erie, PA
View GitHub Profile
(function(jQuery) {
// All new jQuery goes here
})(jQuery.noConflict(true));
@lxcodes
lxcodes / gist:1010364
Created June 6, 2011 14:27
Set Cursor at the End of a ContentEditable
function setEndOfContenteditable(contentEditableElement)
{
var range,selection;
if(document.createRange)//Firefox, Chrome, Opera, Safari, IE 9+
{
range = document.createRange();//Create a range (a range is a like the selection but invisible)
range.selectNodeContents(contentEditableElement);//Select the entire contents of the element with the range
range.collapse(false);//collapse the range to the end point. false means collapse to end rather than the start
selection = window.getSelection();//get the selection object (allows you to change selection)
selection.removeAllRanges();//remove any selections already made
@lxcodes
lxcodes / haproxy_maintenance.conf
Created October 27, 2016 13:07 — forked from sts/haproxy_maintenance.conf
HAProxy Maintenance Page
#
# Proof of concept for a HAProxy maintenance mode
#
#
# Control the maintenance page during runtime using the stats socket:
#
# To put the whole site in maintenance mode (for all IPs):
# > add acl #0 0.0.0.0/0
#
# To exclude your own ip, so you are able to test things out:
@lxcodes
lxcodes / FormResponseController.ex
Last active June 30, 2016 20:47
Issues getting data assigned in changeset
defmodule FhForm.API.HTML.FormResponseController do
use FhForm.Web, :controller
alias FhForm.Form
alias FhForm.FormResponse
def create(conn, params) do
IO.inspect params
form = Repo.get_by(Form, url_iden: params["url_identifier"])
changeset =
@lxcodes
lxcodes / content_iterator.cfm
Last active December 18, 2015 08:59
Mura CMS Basic CFScript Content Iterator from Local Content Index
<cfscript>
// Grab local content index (feed) by name. I believe siteid is optional, but I have always included it.
var feed = application.feedManager.readByName('Banners', $.event("siteid"));
// Create a content iterator from the feed.
var banners = feed.getIterator();
// HTML to add to.
var html = "";
@lxcodes
lxcodes / dynamicFeed.cfm
Created May 17, 2013 14:59
Dynamic Feed -- Needs help with group conditions.
<cfscript>
// feed
local.dynamicFeed=$.getBean('feed');
local.dynamicFeed.setName('tempFolder');
local.dynamicFeed.setIsActive(1);
local.dynamicFeed.setIsFeature(1);
local.dynamicFeed.setSortBy('orderno'); // lastUpdate, releaseDate, displayStart, menuTitle, rating, comments, created, orderno, random
local.dynamicFeed.setMaxItems(1); // 0=unlimited
local.dynamicFeed.setNextN(50); // use the content's own settings
@lxcodes
lxcodes / dspCrumbListLinks.cfm
Created May 16, 2013 19:57
ColdFusion Ugliness.
validates :name, presence: true, length: { within: 1..31 }, uniqueness: { scope: :created_by, message: { code: 'non-unique', data: { ->{ find_unique('name') }} } }
def find_unique(name)
..uniqueness magical find...
end
{
"errors": {
"name": [
"is already taken"
]
}
}
class AppResponder < ActionController::Responder
def to_format
if get? && !resource
controller.response.status = :not_found
elsif has_errors?
controller.response.status = :unprocessable_entity
elsif post?
controller.response.status = :created
end