- see https://gist.github.com/machty/5723945 for the latest API (unlikely to change from now on)
- latest Ember build: https://machty.s3.amazonaws.com/ember/ember-async-routing-10.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Author: Pieter Noordhuis | |
# Description: Simple demo to showcase Redis PubSub with EventMachine | |
# | |
# Update 7 Oct 2010: | |
# - This example does *not* appear to work with Chrome >=6.0. Apparently, | |
# the WebSocket protocol implementation in the cramp gem does not work | |
# well with Chrome's (newer) WebSocket implementation. | |
# | |
# Requirements: | |
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Deploy and rollback on Heroku in staging and production | |
task :deploy_staging => ['deploy:set_staging_app', 'deploy:push', 'deploy:restart', 'deploy:tag'] | |
task :deploy_production => ['deploy:set_production_app', 'deploy:push', 'deploy:restart', 'deploy:tag'] | |
namespace :deploy do | |
PRODUCTION_APP = 'YOUR_PRODUCTION_APP_NAME_ON_HEROKU' | |
STAGING_APP = 'YOUR_STAGING_APP_NAME_ON_HEROKU' | |
task :staging_migrations => [:set_staging_app, :push, :off, :migrate, :restart, :on, :tag] | |
task :staging_rollback => [:set_staging_app, :off, :push_previous, :restart, :on] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var distance_of_time_in_words, time_ago_in_words; | |
time_ago_in_words = function(from_time, include_seconds) { | |
if (include_seconds != null) { | |
include_seconds; | |
} else { | |
include_seconds = false; | |
}; | |
return App.distance_of_time_in_words(from_time, Date.now(), include_seconds); | |
}; | |
distance_of_time_in_words = function(from_time, to_time, include_seconds) { |
Attention: the list was moved to
https://github.com/dypsilon/frontend-dev-bookmarks
This page is not maintained anymore, please update your bookmarks.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/locations/history.js | |
export default Ember.HistoryLocation.extend({ | |
pushState() { | |
this._super(...arguments); | |
window.scrollTo(0, 0); | |
} | |
}); | |
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:plain | |
var existingModal = document.querySelector("[data-controller='modal']"); | |
if (existingModal) { | |
document.body.removeChild(existingModal); | |
} | |
document.body.insertAdjacentHTML("beforeend", "#{j render partial: template.to_s, locals: local_assigns }"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This code is to be used with https://turbo.hotwire.dev. By default Turbo keeps visited pages in its cache | |
// so that when you visit one of those pages again, Turbo will fetch the copy from cache first and present that to the user, then | |
// it will fetch the updated page from the server and replace the preview. This makes for a much more responsive navigation | |
// between pages. We can improve this further with the code in this file. It enables automatic prefetching of a page when you | |
// hover with the mouse on a link or touch it on a mobile device. There is a delay between the mouseover event and the click | |
// event, so with this trick the page is already being fetched before the click happens, speeding up also the first | |
// view of a page not yet in cache. When the page has been prefetched it is then added to Turbo's cache so it's available for | |
// the next visit during the same session. Turbo's default behavior plus this trick make for much more responsive UIs (non SPA). | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule NestedWeb.FormLive do | |
use NestedWeb, :live_view | |
require Logger | |
defmodule Form do | |
use Ecto.Schema | |
import Ecto.Changeset | |
embedded_schema do | |
field :name, :string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Mix.Tasks.ConvertToVerifiedRoutes do | |
@shortdoc "Fix routes" | |
use Mix.Task | |
@regex ~r/(Routes\.)(.*)_(path|url)\(.*?\)/ | |
@web_module MyAppWeb | |
def run(_) do | |
Path.wildcard("lib/**/*.*ex") |
OlderNewer