Skip to content

Instantly share code, notes, and snippets.

View perfettiful's full-sized avatar
🎯
Focusing

Nathan Perfetti perfettiful

🎯
Focusing
View GitHub Profile
shinyUI(fluidPage(
titlePanel("Sentiment Analysis"), #Title
textOutput("currentTime"), #Here, I show a real time clock
h4("Tweets:"), #Sidebar title
sidebarLayout(
sidebarPanel(
dataTableOutput('tweets_table') #Here I show the users and the sentiment
),
mainPanel(
plotOutput("distPlot"), #Here I will show the bars graph
@perfettiful
perfettiful / vim-cheat-sheet.md
Created February 19, 2016 06:38 — forked from ummahusla/vim-cheat-sheet.md
Vim Cheat Sheet

Modes

Vim has two modes insertion mode and command mode. The editor begins in command mode, where the cursor movement and text deletion and pasting occur. Insertion mode begins upon entering an insertion or change command. [ESC] returns the editor to command mode (where you can quit, for example by typing :q!). Most commands execute as soon as you type them except for "colon" commands which execute when you press the ruturn key.

Quitting

  • :x Exit, saving changes
  • :q Exit as long as there have been no changes
  • ZZ Exit and save changes if any have been made
  • :q! Exit and ignore any changes

Inserting Text

@perfettiful
perfettiful / beezid_scraper.py
Created April 6, 2016 01:21 — forked from CuriousGnu/beezid_scraper.py
Beezid.com - Auction Scraper
import pycurl
import json
import time
from StringIO import StringIO
i = 0
bnums = []
while True :
print(str(i))
@perfettiful
perfettiful / loading_plot.R
Created April 7, 2016 01:17 — forked from thigm85/loading_plot.R
Sample code to plot PCs coefficients associated with variables in the dataset. See http://tgmstat.wordpress.com/2013/11/28/computing-and-visualizing-pca-in-r/ for more info.
require(ggplot2)
theta <- seq(0,2*pi,length.out = 100)
circle <- data.frame(x = cos(theta), y = sin(theta))
p <- ggplot(circle,aes(x,y)) + geom_path()
loadings <- data.frame(ir.pca$rotation,
.names = row.names(ir.pca$rotation))
p + geom_text(data=loadings,
mapping=aes(x = PC1, y = PC2, label = .names, colour = .names)) +
@perfettiful
perfettiful / JSXTransformer.min.js
Created April 9, 2016 04:53 — forked from johan/JSXTransformer.min.js
Week Calendar of Life
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.JSXTransformer=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(_dereq_,module,exports){"use strict";var ReactTools=_dereq_("../main");var inlineSourceMap=_dereq_("./inline-source-map");var headEl;var dummyAnchor;var inlineScriptCount=0;var supportsAccessors=Obj
I stumbled across this workflow while doing a piece I shared in /r/dataisbeautiful. Other people may have come across it as well, but I thought I'd post it here just in case it's new to some. It's useful when you're doing a piece that has multiple, custom visualizations per page, and the existing D3-charting libraries aren't working for you.
Basically it works like this:
Data Loading
Host your data in Google Spreadsheets since that makes it easier to manage and update it. Use a separate sheet for each data set.
Use Tabletop to extract the data. You can use its callbacks to load separate sheets parallel to improve load time (example here).
Data Transformation
Since the data is often put in a similar form for each chart, I created a special mini-library for transforming the data. I used Underscore.js (of course) to get the data in a good form for D3.js.
The code above might look a little weird since I'm doing some magic to get each data element to refer back to its parent object. That's to support a Voronoi lay
<h3 id="click-me">CLICK ME!</h3>
<script type="text/javascript">
// This "document.ready" code isn't necessary in this example... but is useful to become familiar with.
// "document.ready" makes sure that our JavaScript doesn't get run until the HTML document is finished loading.
$(document).ready(function() {
// Here we use jQuery to select the header with "click-me" as its ID.
// Notice I have the click, #click-me, and then the function
<div id="drink-options"></div>
<script type="text/javascript">
// Array holds all of the drinks available
var drinkList = [
"Coffee: $5",
"Espresso: $7",
"Cappuccino: $6",
"Latte: $4",
// Keyboard move controls
$(document).keyup(function(e) {
switch (e.which) {
// Move Buttons (Keyboard Down)
case 40:
captainPlanet.animate({ top: "+=200px" }, "normal");
break;
// Move Buttons (Keyboard Right)
// Gets Link for Theme Song
var audioElement = document.createElement("audio");
audioElement.setAttribute("src", "Assets/captainplanet24.mp3");
// Theme Button
$("#musicControls").on("click", ".theme-button", function() {
audioElement.play();
}).on("click", ".pause-button", function() {
audioElement.pause();
});