Skip to content

Instantly share code, notes, and snippets.

View issa-tseng's full-sized avatar

issa marie tseng issa-tseng

  • seattle
View GitHub Profile
@issa-tseng
issa-tseng / scholarLink.user.js
Created March 27, 2012 00:51
Add scholar link to any Google bar
@issa-tseng
issa-tseng / color.coffee
Created April 27, 2012 21:36
color.coffee
# color.coffee - triple rainbow
# thanks wikipedia!
color =
rgbToHsl: (red, green, blue) ->
red /= 255
green /= 255
blue /= 255
max = Math.max(red, green, blue)
@issa-tseng
issa-tseng / diespringgreen.user.js
Created June 12, 2012 03:46
Nuke springgreen from Twitch
// ==UserScript==
// @version 1.0
// @match http://twitch.tv/*
// @match http://www.twitch.tv/*
// ==/UserScript==
(function()
{
var $chatList = jQuery('#chat_line_list');
$chatList.bind('DOMNodeInserted', function()
@issa-tseng
issa-tseng / skewtube.user.js
Created December 7, 2012 06:26
Make Youtube centered!
// ==UserScript==
// @version 1.1
// @match http://www.youtube.com/*
// @match https://www.youtube.com/*
// ==/UserScript==
// TO INSTALL:
// 1. download this file.
// 2. open the extensions settings pane in chrome.
@issa-tseng
issa-tseng / gist:5882546
Created June 28, 2013 04:57
goal html sanitizer.
goals.each(function(model)
{
var markup = model.get('description')
if (markup)
{
markup = markup.replace(/\n/g, '').replace(/ /g, ' ').replace(/ +/g, ' ');
var $markup = $(markup);
$wrapper = $('<div/>').append($markup)
@issa-tseng
issa-tseng / manipulation.ls
Last active January 2, 2016 06:19
I think this works?
# manipulation.ls -- functions for returning modified versions of trees.
{ compact, map } = require('prelude-ls').Obj
# node manipulation:
with-data = (data, node) --> node with data: data
with-child = (child, node) --> node with children: node.children with ((child.id): child)
with-children = (children, node) --> node with children: node.children with children
without-child = (child, node) --> node with children: compact(node.children with ((child.id): null))
var fs = require('fs');
var soda = require('soda-js');
var moment = require('moment');
var update = /* some configuration we load in from a local JSON file */;
// read in our csv
fs.readFile(update.file, function(error, data)
{
if (error) { console.error(error); return; }
// iterate through each row of the dataset
for (var j = 0; j < parsedData.length; j++)
{
// create a js key/value hash object
var datum = {};
// fetch the row we're processing
var row = parsedData[j];
// iterate through each column of the row
// create a soda producer based on our configuration
var producer = new soda.Producer(update.cname, update.credentials);
// perform the actual insert based on our parse and our configurations
producer.operation()
.withDataset(update.id)
.add(importData)
.on('success', function(result) { console.log('Successfully wrote ' + importData.length + ' rows from ' + update.file + ' to ' + update.id + '.'); })
.on('error', function(error) { console.error('Error writing ' + importData.length + ' rows from ' + update.file + ' to ' + update.id + '!'); });
var fs = require('fs');
var soda = require('soda-js');
var moment = require('moment');
var trim = function(str) { return str.replace(/^\s+|\s+$/g, ''); }
// following is from http://stackoverflow.com/questions/8493195/how-can-i-parse-a-csv-string-with-javascript
function csvToArray(text) {
var re_valid = /^\s*(?:'[^'\\]*(?:\\[\S\s][^'\\]*)*'|"[^"\\]*(?:\\[\S\s][^"\\]*)*"|[^,'"\s\\]*(?:\s+[^,'"\s\\]+)*)\s*(?:,\s*(?:'[^'\\]*(?:\\[\S\s][^'\\]*)*'|"[^"\\]*(?:\\[\S\s][^"\\]*)*"|[^,'"\s\\]*(?:\s+[^,'"\s\\]+)*)\s*)*$/;
var re_value = /(?!\s*$)\s*(?:'([^'\\]*(?:\\[\S\s][^'\\]*)*)'|"([^"\\]*(?:\\[\S\s][^"\\]*)*)"|([^,'"\s\\]*(?:\s+[^,'"\s\\]+)*))\s*(?:,|$)/g;