Skip to content

Instantly share code, notes, and snippets.

View heyjinkim's full-sized avatar

Heyjin Kim heyjinkim

View GitHub Profile
@heyjinkim
heyjinkim / svg_bar_chart.handlebars
Last active December 19, 2015 16:08
SVG element in Handlebars template for a bar-chart.
<script type="text/x-handlebars" data-template-name="application">
{{bar-chart width=960 height=500}}
</script>
<script type="text/x-handlebars" id="components/bar-chart">
<g {{bindAttr transform=transformG}}>
<g class="x axis" {{bindAttr transform=transformX}}></g>
<g class="y axis"><text transform="rotate(-90)" y="6" dy=".71em" style="text-anchor:end;">Frequency</text></g>
<g class="rects"></g>
</g>
@heyjinkim
heyjinkim / ember_component_bar_chart.js
Last active December 19, 2015 16:08
Ember.Component: responsible for encapsulating templates of HTML content, combining templates with data to render as sections of a page's DOM, and registering and responding to user-initiated events.
App = Ember.Application.create();
App.BarChartComponent = Ember.Component.extend({
tagName: 'svg',
attributeBindings: 'width height'.w(),
margin: {top: 20, right: 20, bottom: 30, left: 40},
w: function(){
return this.get('width') - this.get('margin.left') - this.get('margin.right');
}.property('width'),
@heyjinkim
heyjinkim / range_select_node
Created July 26, 2013 23:19
Trying to fix 'Uncaught NotSupportedError' error with SVG elements in Ember template. Added "range.selectNode(range.startContainer);" on line 11.
htmlFunc = function(html, outerToo) {
// get a range for the current metamorph object
var range = rangeFor(this, outerToo);
// delete the contents of the range, which will be the
// nodes between the starting and ending placeholder.
range.deleteContents();
/* Heyjin added this line. *************************/
@heyjinkim
heyjinkim / heyjin.rb
Created August 1, 2013 05:12
Number Game in Ruby
print `clear`
puts "Welcome to the game. Enter your name:"
name = gets.chomp
max_guesses = 3
correct_number = rand(1..10)
(1..max_guesses).each do |i|
print "Guess a number between 1 and 10! --> "
guess = gets.chomp.to_i
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Ember Starter Kit</title>
<link rel="stylesheet" href="https://rawgithub.com/emberjs/starter-kit/v1.0.0/css/normalize.css">
<style>
html, body {
margin: 20px;
text-align: center;
@heyjinkim
heyjinkim / gist:562e460b40a7903a862f
Last active August 29, 2015 14:07
createElementNS to generate SVG in Htmlbars
// https://github.com/tildeio/htmlbars/blob/master/packages/morph/lib/dom-helper.js#L129-L131
if (contextualElement) {
this.detectNamespace(contextualElement);
}
// works if replace the above block with this:
if (tagName === 'svg'){
this.namespace = svgNamespace;
}
@heyjinkim
heyjinkim / ember-watson-2.0.sh
Created September 19, 2015 00:13
ember-watson-2.0.sh
# Using `Ember.HTMLBars.makeBoundHelper` is deprecated. Please refactor to using `Ember.Helper` or `Ember.Helper.helper`. [deprecation id: ember-htmlbars.make-bound-helper]
IFS=$'\n'
for pp in $(grep -R 'Handlebars.makeBoundHelper' * | awk -F':' '{print $1" "$2}')
do
filename=$(echo $pp | awk '{print $1}')
searchStr=$(echo $pp | awk '{print $2" "$3" "$4" "$5}')
newStr=$(echo $searchStr | sed 's/}}/ }}/g' | awk '{print $1" "$4" as |"$2"|}}"}')
echo "sed -i '' 's/Handlebars.makeBoundHelper/Helper.helper/g' $filename" >> ember-convert-helper-syntax.sh
done