Skip to content

Instantly share code, notes, and snippets.

View oskarrough's full-sized avatar
💭
██████

Oskar oskarrough

💭
██████
View GitHub Profile
@oskarrough
oskarrough / index.html
Created August 23, 2014 15:39
Youtube to Spotify YouTube to Spotify playlist converter // source http://jsbin.com/caben/28
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<meta name="description" content="YouTube to Spotify playlist converter" />
<meta charset="utf-8">
<title>Youtube to Spotify</title>
<link href='http://fonts.googleapis.com/css?family=Fira+Mono:400,700' rel='stylesheet' type='text/css'>
<style id="jsbin-css">
/* hsl(75, 53%, 53%) */
@oskarrough
oskarrough / list-top-level-npm-modules.sh
Last active August 29, 2015 14:17
How to update NPM with Homebrew
npm -g ls --depth=0
@oskarrough
oskarrough / excludes.txt
Created November 27, 2016 22:20
Nice rsync
node_modules
tmp
dist
bower_components
.tmp
@oskarrough
oskarrough / controllers.application.js
Last active December 26, 2016 23:12
modal-routing
import Ember from 'ember';
export default Ember.Controller.extend({
/*openModal: function(modal, opts) {
this.controllerFor(modal).set('model', opts);
return this.render(modal, {
into: 'application',
outlet: 'modal'
});
},

To deploy an ember-cli application all you have to do is build the project (npm run build) and place the contents of the dist folder on a web server. You could of course do this yourself with a webhost and SFTP but that's slow. Here's how you can use surge instead.

How to deploy ember with surge

Make sure surge.sh is installed: yarn global add surge. Also see https://surge.sh/help/getting-started-with-surge. You'll need a free account.

  1. Add "deploy": "ember build --environment=production; mv dist/index.html dist/200.html; surge dist" to your npm scripts in package.json
  2. npm run deploy

If you want a specific url, change the script ala ... surge dist my-domain.surge.sh.

@oskarrough
oskarrough / pretty-javascript.md
Last active April 16, 2017 14:35
Pretty JavaScript

Install prettier locally to your project:

yarn add prettier

Then, add a new script to package.json:

{
  "scripts": {
 "prettier": "prettier --write --use-tabs --single-quote --no-semi --no-bracket-spacing 'src/*/**.js'"

Run this to recursively delete all node_modules folders.

find . -name "node_modules" -type d -prune -exec rm -rf '{}' +

There is no undo. Please use https://github.com/sindresorhus/trash-cli instead of rm -rf if you want to be safe(r).

@oskarrough
oskarrough / index.html
Last active May 5, 2017 09:19
Native autocomplete for Radio4000 channels (source https://jsbin.com/daruqo)
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="native autocomplete with ajax">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Radio4000 autocomplete</title>
<style id="jsbin-css">
input {
padding: 0.5em;
@oskarrough
oskarrough / ember-critical-css.md
Last active May 29, 2017 07:20
Add this to any ember-cli project and run `npm run build` to get a production build with critical path, inlined CSS.

Here's how to (hopefully) improve the initial load performance of your ember-cli project.

  1. Add this gulpfile.js to any ember-cli project
  2. Run yarn add critical gulp --dev
  3. Change the build script in package.json to ember build -prod; gulp critical
  4. Run yarn build

Now, gulp will run the critical task once after each build. The critical task checks what CSS your app needs to render the initial route and puts it inline in your dist/index.html.

<div style=height:100% id=r4-loader><div style=background-color:#e6e6e4;top:0;left:0;right:0;bottom:0;position:fixed aria-label=Loading…><svg height=158 style=color:#888;fill:currentcolor;display:inline-block;max-width:100%;height:72px;position:absolute;top:0;left:0;right:0;bottom:0;margin:auto viewBox="0 0 369 158"width=369><g fill-rule=evenodd><path d="M352.606 44.05c-2.15-18.698-10.6-26.05-24.53-26.05C311.796 18 303 28.045 303 54.513c0 22.92 4.88 33.9 14.097 38.01 2.37 13.442 10.667 20.192 21.873 21.767 15.523 2.18 25.3-5.713 28.964-31.782 3.023-21.513-2.416-34.74-15.328-38.458zm0 0c.363 3.158.547 6.64.547 10.463 0 30.773-8.796 40.02-25.077 40.02-4.154 0-7.82-.6-10.98-2.01-.91-5.176-.944-11.346.075-18.595 3.295-23.443 16.257-32.83 31.78-30.648 1.278.18 2.497.436 3.656.77z"/><path d="M291.52 32.57c-4.616-19.75-14.395-27.276-28.855-26.518-18.844.987-28.31 15.136-26.43 51.01 1.545 29.483 7.413 44.122 17.376 49.822 3.845 7.714 10.166 11.895 17.982 13.133 16.105 2.55 30.037-8.75 35.216-41.445 4.063-25.657-2.777