Skip to content

Instantly share code, notes, and snippets.

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

Jennie JennieJi

🏠
Working from home
View GitHub Profile
@JennieJi
JennieJi / csvToArray.ts
Last active December 13, 2020 03:04
Simple csv to array demo
const COLUMN_DELIMITER = ',';
export function csvToArray(csv: string): string[][] {
const table = [] as string[][];
let row = [];
let cell = '';
let openQuote = false;
let i = 0;
const pushCell = () => {
function swap(arr, a, b) {
if (a === b) {
return;
}
const temp = arr[a];
arr[a] = arr[b];
arr[b] = temp;
}
let loops = [];
@JennieJi
JennieJi / controllers.application.js
Last active February 7, 2017 08:00
Unexpected observer behaviour
import Ember from 'ember';
export default Ember.Controller.extend({
now: null,
observerNow: null,
_observerNow: Ember.observer('now', function() {
this.set('observerNow', this.get('now'));
}),
tick() {
Ember.run.later(this, function() {
@JennieJi
JennieJi / controllers.application.js
Last active January 20, 2017 16:47
Wierd behavior with each
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
length: 6,
originalVal: '',
arrayVal: Ember.computed('originalVal', function() {
const origin = this.get('originalVal').toString();
const len = this.get('length');
let arr = new Array(len);
export function htmlEscape(content) {
[
{origin: '&', escaped: '&'},
{origin: '<', escaped: '&lt;'},
{origin: '>', escaped: '&gt;'}
].forEach(pair => content = content.replace(new RegExp(pair.origin, 'g'), pair.escaped));
return content;
}
$('.chart').each(function() {
var $this = $(this);
var lineWidth = 15,
indicatorHeight = 20,
scaleLength = indicatorHeight - lineWidth;
var canvasWidth = $this.width();
var rOutter = canvasWidth / 2 - scaleLength,
rInner = rOutter - lineWidth - 3;
var rotate = -90;