Skip to content

Instantly share code, notes, and snippets.

View walter's full-sized avatar

Walter McGinnis walter

View GitHub Profile
@walter
walter / mysql-dump-with-issue.sql
Created August 23, 2011 05:41
MySQL dump with issue
-- you'll need a users table with corresponding roles for ids 1-6
--
-- Table structure for table `roles`
--
DROP TABLE IF EXISTS `roles`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `roles` (
@walter
walter / gmaps4rails-issue-83-snippets
Created September 8, 2011 06:30
JavaScript and HTML snippets for Gmaps4Rails issue #83
// from head wrapped in script tag
Gmaps.still_image_extended_content_values_location_map_div = new Gmaps4RailsGoogle();
function load_still_image_extended_content_values_location_map_div() {
Gmaps.still_image_extended_content_values_location_map_div.map_options.center_latitude = -41.1796666666667;
Gmaps.still_image_extended_content_values_location_map_div.map_options.disableDoubleClickZoom = true;
Gmaps.still_image_extended_content_values_location_map_div.map_options.draggable = true;
Gmaps.still_image_extended_content_values_location_map_div.map_options.center_longitude = 174.958833333333;
Gmaps.still_image_extended_content_values_location_map_div.map_options.container_id = 'map_container_still_image_extended_content_values_location_map_div';
@walter
walter / render_item_form_partial.html
Created September 14, 2011 22:55
rendered html/javascript from a form partial
<h2>New Image</h2>
<form action="/en/site/images/create" enctype="multipart/form-data" method="post"><div style="margin:0;padding:0;display:inline"><input name="authenticity_token" type="hidden" value="uxGAMVOxtD8+B+cP+HFk7iB/7N0dnauybaHYI8dWCv4=" /></div>
<fieldset>
<p class="required"><em>* denotes a required field</em></p>
@walter
walter / selections.id.js
Created October 3, 2011 01:07
Snippet from media_selector.js that fails in Firefox on ajax call
// this gives selected result and the user's selected size
// and outputs end result of oembed request for html to embed the result at the selected size
this.get('#/selections/:id', function(context) {
$('#result-description-and-sizes').fadeOut();
$('#page-spinner').fadeIn();
// params['id'] decodes to normal url, but we need escaped version
var oembedUrl = this.params['id'];
$.get(oembedUrl)
@walter
walter / gist:1458566
Created December 11, 2011 05:23
Make error for Yaz on Mac OS X 10.7
libtool: compile: /usr/bin/llvm-gcc -DHAVE_CONFIG_H -I. -I../include -I../include -I/usr/include/libxml2 -I/usr/local/Cellar/icu4c/4.3.1/include -D YAZ_HAVE_ICU=1 -I../libstemmer_c/include -O3 -march=core2 -msse4.1 -w -pipe -D_THREAD_SAFE -c icu_chain.c -fno-common -DPIC -o .libs/libyaz_icu_la-icu_chain.o
In file included from /usr/include/libxml2/libxml/parser.h:798,
from /usr/include/libxml2/libxml/globals.h:18,
from /usr/include/libxml2/libxml/threads.h:35,
from /usr/include/libxml2/libxml/xmlmemory.h:218,
from /usr/include/libxml2/libxml/tree.h:1248,
from ../include/yaz/xmltypes.h:36,
from ../include/yaz/icu.h:38,
from ../include/yaz/icu_I18N.h:46,
from icu_chain.c:18:
@walter
walter / sortable-collection-view.js.coffee
Created January 15, 2013 05:06
Sortable CollectionView
Lm.PostsCollectionView = Em.CollectionView.extend
tagName: 'tbody'
didInsertElement: ->
# changes position property of fieldCategories accordingly
# and pushes changes to server with commit
@$().sortable
items: 'tr'
containment: @$()
stop: (evt, ui) ->
# TODO: would be nice to do this in a proper transaction
App.SomeModel = App.Model.extend
rawArrayAttributeValue: DS.attr('string')
arrayAttributet: (->
JSON.parse @get('rawArrayAttributeValue')
).property('rawArrayAttributeValue')
@walter
walter / example-modal.coffee
Last active December 12, 2015 01:58
Example modal code
# copied and modified from a working app, but there maybe typos in adaptation
# untested in this form
# router
App.Router.map (match) ->
@resource 'posts', ->
@route 'new'
@resource 'post', path: '/:post_id'
@walter
walter / blog-routes.coffee
Created February 7, 2013 02:50
Example routes for simple blog application
# router
App.Router.map (match) ->
@resource 'posts', ->
# index is implied for resources
@route 'new'
@resource 'post', path: '/:post_id', ->
# index is implied for resources
@route 'edit'
@walter
walter / blog-posts-form.handlebars
Created February 7, 2013 03:10
Example form template that can be used both by posts.new and post.edit
<div class="modal-header">
<div class="button close btn-dismiss" {{action cancel content}}>x</div>
<h2 class="app-icon-large">Post</h2>
</div>
<div class="modal-body">
<div class="control-group">
<label class="control-label" for="post-title">Title</label>
<div class="controls">
{{view Em.TextField elementId='post-title' valueBinding='content.title'}}