Skip to content

Instantly share code, notes, and snippets.

View nicolasembleton's full-sized avatar
🏠
Working from home

Nicolas Embleton nicolasembleton

🏠
Working from home
View GitHub Profile
App.NewsObject = Em.Object.extend({
id: 0,
title: "Title",
shortDescription: "shortDesc",
longDescription: "longDesc",
image: "image",
content: "article content",
date: "1970-01-01",
url : ""
});
<script type="text/x-handlebars" data-template-name="home-top-news">
<!-- The main element + the other 3 -->
{{#each content}}
<div style="float:left;display:inline-block;margin-left:15px;margin-bottom:15px;">
<img {{bindAttr src="image"}} id="img-{{unbound id}}" />
<h2 id="h2-{{unbound id}}">{{title}}</h2>
<h3><a href="#" id="id-{{unbound id}}">{{shortDescription}}</a></h3>
</div>
{{/each}}
</script>
App.homeTopNewsController = Ember.ArrayController.create({
content: [],
load: function() {
},
// Callback from SOAP callee
parse: function(data) {
},
// Returns 1st element for Top News
@nicolasembleton
nicolasembleton / iosSlider issue with Ember.js generated output
Created August 15, 2012 01:07
Ember.js Handlebar.js generated output
<div id="ember475" class="ember-view slider" style="position: relative; overflow: hidden; cursor: -webkit-grab; -webkit-perspective: 1000px; -webkit-backface-visibility: hidden; width: 2650px; -webkit-transform: matrix(1, 0, 0, 1, 0, 0); ">
<!-- The main element + the other 3 -->
<script id="metamorph-19-start" type="text/x-placeholder" style="width: 0px; float: left; "></script><script id="metamorph-20-start" type="text/x-placeholder" style="width: 0px; float: left; "></script>
<div class="draggable post slide21" id="post21" style="width: 235px; float: left; ">
<cat style="display:none;"><script id="metamorph-30-start" type="text/x-placeholder"></script><script id="metamorph-30-end" type="text/x-placeholder"></script></cat>
<img id="img-21" src="apple-touch-icon-114x114-precomposed.png" name="Title21" onclick="javascript:openHash('#id-21')">
<p><a href="#id-21" onclick="javascript:alert('#id-21')" style="z-index:1000;">Title21</a></p>
<h3><a id=
@nicolasembleton
nicolasembleton / caret-position.jquery.js
Created June 30, 2013 16:43
jQuery plugin to detect caret position within a text input. And method to get the current word at caret position.
/**
* jQuery Plugin to get cursor position
*/
(function ($) {
$.fn.getCursorPosition = function () {
var input = this.get(0);
if (!input) return; // No (input) element found
if ('selectionStart' in input) {
// Standard-compliant browsers
return input.selectionStart;
@nicolasembleton
nicolasembleton / user.sublime-keymap
Last active April 8, 2018 02:02 — forked from cbednarski/gist:4555141
Update Sublime Text 2+ Key Mapping to circle tabs in their window order
[
{ "keys": ["ctrl+shift+t"], "command": "open_terminal_project_folder" },
{ "keys": ["ctrl+tab"], "command": "next_view" },
{ "keys": ["ctrl+shift+tab"], "command": "prev_view" }
]
var baseUrl = 'https://api.parse.com/1',
appId = 'XXXXXXXXXXXXXXX',
apiKey = 'XXXXXXXXXXXXXX'; // make sure to use the REST API Key
var _register = function(params, lambda, lambdaerror) {
var method = 'POST',
url = baseUrl + '/installations',
payload = (params) ? JSON.stringify(params) : '';
_helper(url, method, payload, function(data, status) {
m = function () {
emit(this.ID, 1);
}
r = function (k, vals) {
return Array.sum(vals);
}
db.Vehicle.mapReduce(m, r, {out: {inline: 1}, query: {value: {$gt: 1}}})
@nicolasembleton
nicolasembleton / gist:5d756227a72465cb11cc
Created April 8, 2015 06:46
[REGEX] Convert JSON to CSV
^\s+\{\s+"field1" : "([^"]+)",\s+"field2" : "([^,]+)",\s+"field3" : "([^"]+)",\s+"field4" : "([^"]+)",\s+"field5" : (\d+)\s+\},?\s?
/*
fileExistSync - Check if a file exist in NodeJS
Twitter: @FGRibreau / fgribreau.com
Usage:
var fileExistSync = require('./fileExistSync');
var exist = fileExistSync('/var/folders/zm/jmjb49l172g6g/T/65b199');
Support for Nodev0.6