Skip to content

Instantly share code, notes, and snippets.

@saravanak
saravanak / move_templates.sh
Last active April 11, 2020 03:40
Use component colocation Since Ember 3.13.
#!/bin/bash
# to be executed in the root directory of an Ember project.
# What: After working on an Ember codebase with pod structure, I found it intuitive to use co-located components.
# Since Ember 3.13, we have support for component co-location.
# This script moves all component templates to their respective component locations.
# YMMV:
@saravanak
saravanak / adapters.application.js
Last active May 17, 2018 05:56 — forked from kjhangiani/adapters.application.js
ember polymorphic sideload
import Ember from 'ember';
import DS from 'ember-data';
export default DS.JSONAPIAdapter.extend({
});
@saravanak
saravanak / checkouts_controller_decorator.rb
Last active October 9, 2018 18:31
The updated checkouts decorator for working around spree/issue/8569
# app/controllers/spree/api/v1/checkouts_controller_decorator.rb
Spree::Api::V1::CheckoutsController.class_eval do
def update
authorize! :update, @order, order_token
if @order.update_from_params(params, permitted_checkout_attributes, request.headers.env)
if current_api_user.has_spree_role?('admin') && user_id.present?
@order.associate_user!(Spree.user_class.find(user_id))
end
@saravanak
saravanak / general.jison
Last active January 7, 2016 01:45
Parsing an example language
/* description: Parses a simple Template spec*/
/* lexical grammar */
%lex
%%
\s+ /* skip whitespace */
[a-zA-Z0-9_]+\b return 'WORD';
"<" return '<';
">" return '>';
#http://wiki.yangleo.me/2013/10/29/write-UltiSnips-snippets.html
# this snippet creates a step definition out of a feature definiton
# only inconvinience is that this one displays the args list as a new line.
# not sure how to deal with this anyhow
snippet step "create step from feature description"
`!p num_replaced = re.sub(r'\d+', '(\d+)', snip.v.text)
quote_replaced = re.sub(r'".*"','"([^"]*)"', num_replaced)
snip.rv = re.sub(r'^\s*(Then|Given)\s*(.*)',r'\1(/^\2$/) do ', quote_replaced)`|${0:arg1}|
@saravanak
saravanak / blog_trend.html.erb
Created July 2, 2015 10:25
Partial for displaying the blog trend in Old Weaver site
<table>
<% summary = year_by_month_summary %>
<% size = calculate_size(summary) %>
<tr>
<td>&nbsp; </td>
<% (1..12).to_a.each do |month|%>
<td> <%= Date::ABBR_MONTHNAMES[month] %></td>
<%end%>
</tr>
@saravanak
saravanak / gemfile.lock
Created June 10, 2015 02:08
gemfile.lock -middleman-navtree issue
GEM
remote: http://rubygems.org/
specs:
activesupport (4.1.10)
i18n (~> 0.6, >= 0.6.9)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.1)
tzinfo (~> 1.1)
addressable (2.3.8)
@saravanak
saravanak / README.md
Last active August 29, 2015 14:05 — forked from mbostock/.block
Pie chart demo forked from mbostok

This pie chart is constructed from a CSV file storing the populations of various age groups. The chart employs a number of D3 features: