Skip to content

Instantly share code, notes, and snippets.

@xypaul
xypaul / Definition of component
Created April 9, 2015 05:26
Radio buttons - Ember
// Yes there is no template
App.RadioButtonComponent = Ember.Component.extend({
tagName: 'input',
type: 'radio',
value: null,
attributeBindings: [ 'checked', 'name', 'type', 'value' ],
checked: function () {
return JSON.parse(JSON.stringify(this.get('value'))) == JSON.parse(JSON.stringify(this.get('groupValue')));
}.property('value', 'groupValue').readOnly(),
@xypaul
xypaul / .zshrc
Last active August 29, 2015 14:09 — forked from SlexAxton/.zshrc
gifify() {
if [[ -n "$1" ]]; then
if [[ $2 == '--good' ]]; then
ffmpeg -i $1 -r 10 -vcodec png out-static-%05d.png
time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.png GIF:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile - > $1.gif
rm out-static*.png
else
ffmpeg -i $1 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > $1.gif
fi
else
@xypaul
xypaul / code.json
Last active January 6, 2016 01:59
language-code.json
{
"af": "Afrikaans",
"af-ZA": "Afrikaans (Suid-Afrika)",
"am": "አማርኛ",
"am-ET": "አማርኛ (ኢትዮጵያ)",
"ar": "العربية",
"ar-AE": "العربية (الإمارات العربية المتحدة)",
"ar-BH": "العربية (البحرين)",
"ar-DZ": "العربية (الجزائر)",
"ar-EG": "العربية (مصر)",
import Ember from "ember";
var get = Ember.get;
var copy = Ember.copy;
var removeObserver = Ember.removeObserver;
var addObserver = Ember.addObserver;
var DocumentTitleMixin = Ember.Mixin.create({
titleTokensDidChange: function () {
@xypaul
xypaul / tinymce-ember.js
Created May 14, 2014 06:32
TinyMCE 4 Ember Component
App.TinymceEditorComponent = Ember.Component.extend({
// Warning!!! only use tinyMCE not tinymce !!!
editor: null,
data: {},
watchData: true,
didInsertElement: function(){
var _this = this;
// The magic config - http://www.tinymce.com/wiki.php/Configuration
var config = {};
@xypaul
xypaul / ember-view.js
Created May 12, 2014 20:56
Ember - didInsertElement - afterRenderEvent - Ultimate solution
Ember.View.reopen({
didInsertElement : function(){
this._super();
Ember.run.scheduleOnce('afterRender', this, this.afterRenderEvent);
},
afterRenderEvent : function(){
// implement this hook in your own subclasses and run your jQuery logic there
}
});
@xypaul
xypaul / jsbin.dibug.css
Created May 8, 2014 16:26
Fill container TinyMCE
html,body {
height: 100%;
background: blue;
}
.fill-div {
height: 100%;
width: 100%
}
@xypaul
xypaul / template.hbs
Created May 8, 2014 01:50
Vis.js Graph as Ember Component
<!-- Setting up component -->
<script type="text/x-handlebars" id="components/vis-editor"></script>
<!-- Example of using component -->
<script type="text/x-handlebars" id="application">
{{viz-editor data=data selected=selected editing=editing}}
</script>
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Rename tree and get underlying data to push to server." />
<script src="http://d3js.org/d3.v3.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<script>

This example pulls together various examples of work with trees in D3.js.

The panning functionality can certainly be improved in my opinion and I would be thrilled to see better solutions contributed.

One can do all manner of housekeeping or server related calls on the drop event to manage a remote tree dataset for example.

Dragging can be performed on any node other than root (flare). Dropping can be done on any node.

Panning can either be done by dragging an empty part of the SVG around or dragging a node towards an edge.