Skip to content

Instantly share code, notes, and snippets.

View jacobheric's full-sized avatar

Jacob Heric jacobheric

View GitHub Profile
@jacobheric
jacobheric / gist:5292450
Created April 2, 2013 14:04
An example tying hammer.js gesture support into a meteor managed template element via the template.rendered event
Template.thing.rendered = function(template){
var element = this.find('.thingContainer');
var id = this.data._id;
if (element) {
Hammer(element).on("dragleft", dragLeft);
Hammer(element).on("dragright", dragRight);
}
}
@jacobheric
jacobheric / gist:5292407
Last active December 15, 2015 16:50
An example Meteor view template
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"/>
<title>Heric List</title>
</head>
<body>
<div id="outer">
{{> list}}
</div>
</body>
@jacobheric
jacobheric / gist:5292339
Last active December 15, 2015 16:49
A couple example meteor client collection subscriptions
// Subscribe to 'lists' collection on startup.
// Select a list once data has arrived.
var listsHandle = Meteor.subscribe('lists', function () {
//
//Check for our show guide token
if (Session.get('list_id')){
var l = Lists.findOne(Session.get('list_id'));
if (l && l.showGuide && l.showGuide == true){
Session.set('showGuide', true);
@jacobheric
jacobheric / gist:5289606
Last active December 15, 2015 16:29
an example Meteor model.js with minimal security
// collection contains a list of things
Things = new Meteor.Collection("things");
Lists = new Meteor.Collection("lists");
Things.allow({
insert: function() {
return true;
},
update: function() {
return true;
@jacobheric
jacobheric / gist:5289586
Last active December 15, 2015 16:29
example server side publication of collections in meteor
// Publish complete set of lists to all clients.
Meteor.publish('lists', function () {
return Lists.find();
});
// Publish all items for requested list_id.
Meteor.publish('things', function (id) {
return Things.find({list_id: id});
});
@jacobheric
jacobheric / hibernate-search-criteria-paging-total.java
Created March 13, 2011 16:15
A sample hibernate search using criteria, disjunction, projection and paging
public List<Recipe> search(RecipeCriteria recipeCriteria) {
Criteria c = this.getSessionFactory().getCurrentSession().createCriteria(Recipe.class);
//
//Property restrictions
if (recipeCriteria.getQuery() != null) {
Disjunction d = Restrictions.disjunction();
d.add(Restrictions.like("name", recipeCriteria.getQuery().trim(), MatchMode.ANYWHERE));
@jacobheric
jacobheric / extjs-example-grid-search-paging.js
Created March 13, 2011 16:02
An example Ext JS CRUD grid with search and paging
Ext.ns('youbrew', 'youbrew.recipe');
/**
* youbrew.recipe.Grid
* A recipe EditorGridPanel, clearly derived from the extjs examples.
*/
youbrew.recipe.Grid = Ext.extend(Ext.grid.EditorGridPanel, {
renderTo: 'recipe-grid',
iconCls: 'silk-grid',
frame: true,
title: 'YouBrew Recipe Grid',
@jacobheric
jacobheric / sample-extjs-app-cont.js
Created March 13, 2011 15:52
Sample extjs app continued, grid and form setup
var textField = new Ext.form.TextField();
// Grid-columns with meta-data from backend.
var recipeColumns = [
{header: "ID", width: 40, sortable: true, dataIndex: 'id'},
{header: "Name", width: 100, sortable: true, dataIndex: 'name', editor: textField},
{header: "Brew Notes", width: 180, sortable: true, dataIndex: 'brewNotes', editor: textField},
{header: "Taste Notes", width: 180, sortable: true, dataIndex: 'tasteNotes', editor: textField},
{
header: 'Yeast',
@jacobheric
jacobheric / spring-mvc-annotations-controller.java
Created March 13, 2011 14:54
An annotated spring mvc controller snippet offering restful json services
@Controller
@RequestMapping(value="/recipe")
public class RecipeController extends BaseController implements Serializable {
private static final long serialVersionUID = 1L;
private static final Logger log = LoggerFactory.getLogger(RecipeController.class);
@Autowired
private IRecipeService recipeService;
@jacobheric
jacobheric / sample-extjs-app.js
Created March 13, 2011 02:13
A sample extjs crud grid and form app (building on the extjs example offering)
Ext.ns("youbrew");
// Application instance for showing user-feedback messages.
var App = new Ext.App({});
// HttpProxy instance, utilizes parameter "api" object here constructing url manually.
var proxy = new Ext.data.HttpProxy({
api: {
read : {url: 'recipe', method: 'GET'},
create : {url: 'recipe', method: 'POST'},