Skip to content

Instantly share code, notes, and snippets.

@jacopotarantino
jacopotarantino / article-component.js
Created February 29, 2016 23:05
A UI component for the body text of an article. This is a test to see what would become challenging in rendering normal page content in a more interactive-content fashion.
/**
* Concerns:
* How to render inline images, links, smart content(eg. `[twitter: @jacopotarantino]`), etc...
* Do those sub-components actually need to be subcomponents or can we just `.innerHTML`?
* What about updating article content?
* Do articles ever really have events on/in them?
*/
import { analytics } from 'services'
import { UIComponent } from 'ui-component'
@jacopotarantino
jacopotarantino / slideshow-ad-update-pattern.js
Created February 29, 2016 20:38
A potential architecture for a full-screen
/**
Order of operations:
user clicks on button within a slideshow
button emits a 'click' event
slideshow catches button click event
slideshow handles the specified action (change the slide to the right)
slideshow emits a 'slide_changed' event
click gallery, acting as a controller/higher-level wrapper for the slideshow in this case catches the slide changed event
click gallery tells the advertisement to update
advertisement runs an update
@jacopotarantino
jacopotarantino / analytics.js
Last active March 1, 2016 21:32
ES6 analytics.js mock.
(global => {
'use strict'
// if analytics is already defined, we probably don't need this.
if (global.analytics) { return }
class Analytics {
/**
* Creates a new instance of the analytics service.
*/
@jacopotarantino
jacopotarantino / broken-image.html
Last active January 22, 2016 16:39
Make broken images not suck.
<script>
(() => {
'use strict'
let styles = `
.pretty-broken-image {
visibility: hidden;
position: relative;
}
@jacopotarantino
jacopotarantino / phone-formatter.js
Created January 5, 2016 20:41
Formats phone number inputs
(function () {
$('#format-me').on('keydown', function (event) {
var text = event.target.value
var regex = /^\(\d{3}\)\s\d{3}-\d{4}$/
// if it's valid do nothing
if (regex.test(text)) { return }
// strip the input down to numbers only
text = text.replace(/\D/g, '')
@jacopotarantino
jacopotarantino / search.sh
Created November 21, 2015 17:44
Looping over files to find a particular line in those files
#! /bin/bash
# @description outputs lines and the files they came from to an arbitrary file
# @argument input {String} - regex looking for files in local directory
# @argument output {Filename} - where to echo found lines to
# @argument searchstring {String} - what to match for
# @example - ./search.sh '*.csv' outputfile.csv portuguese
echo $1
for file in $1; do
echo "Examining $file"
@jacopotarantino
jacopotarantino / deploy-to-surge.sh
Created November 12, 2015 21:58
quick deploy an angular app to surge
#! /bin/bash
# test script to install and deploy a test application to surge.sh
# make sure node is up to date
brew update
brew upgrade node
# install node-based dependencies
npm install -g grunt-cli bower yo generator-karma generator-angular surge
@jacopotarantino
jacopotarantino / notes.md
Last active November 10, 2015 16:17
js notes
  • check out feross/standard for some javascript style advice and a plugin to autocorrect violations
  • never be afraid to write variables with long fuckall names. readability is more important than shorthand
  • always wrap code in an IIFE to prevent global namespace pollution
  • good job on the wordSubstituter method
  • bulkShortener: i'd prefer a map/forEach to a for loop
  • if this were in my codebase i'd make you write inline documentation but that's fine here
  • triple extra bonus points if you rewrote this in a more class-based manner like:
class Tweet {
@jacopotarantino
jacopotarantino / spec.md
Created November 6, 2015 15:07
ajax challenge

I need for you to build the front end to our new user management system. The first component in this system is a dashboard that lists all of our current users.

Criteria:

  • This site is going to be run as strictly static pages that interact with APIs so no backend is necessary.
  • The API isn't available yet so you'll need to fake some data. Use randomuser.me to get a set of users.
  • Use jQuery to facilitate browser abstraction.
  • Fetch a set of 3 male users and list them on the page.
  • Put their avatar on the left and their name, username, and email address on the right.
@jacopotarantino
jacopotarantino / notes.md
Created November 5, 2015 15:34
article notes
  • link to a definition with minaswan(good for SEO and readability)
  • be careful about conflating ruby and rails(it's basically the same thing in use but not techincally the same project so just be careful about phrasing)
  • 2nd to last paragraph: i would focus on how machines today are powerful enough that we can spare a few cycles here and there instead of on the scale of modern webapps.
  • i'd like to see an example of what rails makes super simple/what's opinionated about it
  • i'd also like to see numbers on speed but that might not be the focus of this article
  • https://c1.staticflickr.com/1/7/8013829_1eaef1f51f.jpg