Skip to content

Instantly share code, notes, and snippets.

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

Oskar oskarrough

💭
██████
View GitHub Profile
@oskarrough
oskarrough / chrome-remote-deugging-windows-10-android.md
Last active July 12, 2020 19:21
Chrome Remote Debugging from Windows 10 to Android

My Windows 10 wouldn't recognize my phone. After using adb it now works. Here's how.

  • Connect your Android phone via USB
  • When it asks what to connect as, choose "Camera (PTP)"
  • Open Google Chrome and the webpage you want to test
  • Open Chrome Developer Tools and find the "Remote Devices" tab

Now, your phone might or might not appear in this tab.
On my OS X and Fedora, it did. On Windows I had to get Android Debug Bridge ("ADB"):

@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;

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 / 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'"

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 / 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.

@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'
});
},

Here's how you can get server-side rendering with Ember + FastBoot and deploy it with now.sh.

It requires an ember-cli application that doesn't fail when you run ember fastboot --serve-assets. Also that you have now.sh installed.

How to deploy ember with fastboot using now.sh

  1. ember install ember-cli-fastboot
  2. Add a server.js (example)
  3. ember build -p
  4. cp server.js dist/server.js