tor

How to Master the Elevator Pitch & Leave a Great First Impression

Want to master the elevator pitch and leave a great first impression? Use this easy formula to help communicate what you do in a concise pitch!




tor

Is Zero UI The Key Factor For The Future Of Interfaces?

Zero UI is about removing everything that comes between users and their devices, about making the interaction easier, seamless, more direct. Does it sound to you like a concept from a science-fiction...




tor

Vibrant Flat Vector Planets Illustration - Free Download Pack

The galaxy is a mesmerizing place, even better throught the eyes of visual design artists around our globe, we're delighted to release another freebie for our design community. This flat vector...




tor

Which Graphics Editor To Choose For The Novice

Photos and other images are used in different fields, so those who know how to work with high-resolution mockups are in demand as professionals. It is useful to be able to take photos, draw, edit...




tor

How To Restore Hard Drive From A Time Machine + Other Ways

Have you chosen Mac for its reliable system? They really have a lot of advantages and are of the best quality. Mac users don’t face serious problems with hard drives often. But the reality is such...




tor

6 Ways To Step Up Your Instagram Stories Game

Instagram Stories are an integral part of the platform. Though Instagram copied Snapchat’s concept a few years ago, over 500 million accounts use the Stories feature on a daily basis. Some users...




tor

✚ Tornado Lines – Useful or Not? (The Process 088)

It looks like a tornado. It's messy. It's circular. It almost looks intentionally confusing. But how bad is it really?

Tags: ,




tor

Markdown Comes Alive! Part 1, Basic Editor

In my last post, I covered what LiveView is at a high level. In this series, we’re going to dive deeper and implement a LiveView powered Markdown editor called Frampton. This series assumes you have some familiarity with Phoenix and Elixir, including having them set up locally. Check out Elizabeth’s three-part series on getting started with Phoenix for a refresher.

This series has a companion repository published on GitHub. Get started by cloning it down and switching to the starter branch. You can see the completed application on master. Our goal today is to make a Markdown editor, which allows a user to enter Markdown text on a page and see it rendered as HTML next to it in real-time. We’ll make use of LiveView for the interaction and the Earmark package for rendering Markdown. The starter branch provides some styles and installs LiveView.

Rendering Markdown

Let’s set aside the LiveView portion and start with our data structures and the functions that operate on them. To begin, a Post will have a body, which holds the rendered HTML string, and title. A string of markdown can be turned into HTML by calling Post.render(post, markdown). I think that just about covers it!

First, let’s define our struct in lib/frampton/post.ex:

defmodule Frampton.Post do
  defstruct body: "", title: ""

  def render(%__MODULE{} = post, markdown) do
    # Fill me in!
  end
end

Now the failing test (in test/frampton/post_test.exs):

describe "render/2" do
  test "returns our post with the body set" do
    markdown = "# Hello world!"                                                                                                                 
    assert Post.render(%Post{}, markdown) == {:ok, %Post{body: "<h1>Hello World</h1>
"}}
  end
end

Our render method will just be a wrapper around Earmark.as_html!/2 that puts the result into the body of the post. Add {:earmark, "~> 1.4.3"} to your deps in mix.exs, run mix deps.get and fill out render function:

def render(%__MODULE{} = post, markdown) do
  html = Earmark.as_html!(markdown)
  {:ok, Map.put(post, :body, html)}
end

Our test should now pass, and we can render posts! [Note: we’re using the as_html! method, which prints error messages instead of passing them back to the user. A smarter version of this would handle any errors and show them to the user. I leave that as an exercise for the reader…] Time to play around with this in an IEx prompt (run iex -S mix in your terminal):

iex(1)> alias Frampton.Post
Frampton.Post
iex(2)> post = %Post{}
%Frampton.Post{body: "", title: ""}
iex(3)> {:ok, updated_post} = Post.render(post, "# Hello world!")
{:ok, %Frampton.Post{body: "<h1>Hello world!</h1>
", title: ""}}
iex(4)> updated_post
%Frampton.Post{body: "<h1>Hello world!</h1>
", title: ""}

Great! That’s exactly what we’d expect. You can find the final code for this in the render_post branch.

LiveView Editor

Now for the fun part: Editing this live!

First, we’ll need a route for the editor to live at: /editor sounds good to me. LiveViews can be rendered from a controller, or directly in the router. We don’t have any initial state, so let's go straight from a router.

First, let's put up a minimal test. In test/frampton_web/live/editor_live_test.exs:

defmodule FramptonWeb.EditorLiveTest do
  use FramptonWeb.ConnCase
  import Phoenix.LiveViewTest

  test "the editor renders" do
    conn = get(build_conn(), "/editor")
    assert html_response(conn, 200) =~ "data-test="editor""
  end
end

This test doesn’t do much yet, but notice that it isn’t live view specific. Our first render is just the same as any other controller test we’d write. The page’s content is there right from the beginning, without the need to parse JavaScript or make API calls back to the server. Nice.

To make that test pass, add a route to lib/frampton_web/router.ex. First, we import the LiveView code, then we render our Editor:

import Phoenix.LiveView.Router
# … Code skipped ...
# Inside of `scope "/"`:
live "/editor", EditorLive

Now place a minimal EditorLive module, in lib/frampton_web/live/editor_live.ex:

defmodule FramptonWeb.EditorLive do
  use Phoenix.LiveView

  def render(assigns) do
    ~L"""
      <div data-test=”editor”>
        <h1>Hello world!</h1>
      </div>
      """
  end

  def mount(_params, _session, socket) do
    {:ok, socket}
  end
end

And we have a passing test suite! The ~L sigil designates that LiveView should track changes to the content inside. We could keep all of our markup in this render/1 method, but let’s break it out into its own template for demonstration purposes.

Move the contents of render into lib/frampton_web/templates/editor/show.html.leex, and replace EditorLive.render/1 with this one liner: def render(assigns), do: FramptonWeb.EditorView.render("show.html", assigns). And finally, make an EditorView module in lib/frampton_web/views/editor_view.ex:

defmodule FramptonWeb.EditorView do
  use FramptonWeb, :view
  import Phoenix.LiveView
end

Our test should now be passing, and we’ve got a nicely separated out template, view and “live” server. We can keep markup in the template, helper functions in the view, and reactive code on the server. Now let’s move forward to actually render some posts!

Handling User Input

We’ve got four tasks to accomplish before we are done:

  1. Take markdown input from the textarea
  2. Send that input to the LiveServer
  3. Turn that raw markdown into HTML
  4. Return the rendered HTML to the page.

Event binding

To start with, we need to annotate our textarea with an event binding. This tells the liveview.js framework to forward DOM events to the server, using our liveview channel. Open up lib/frampton_web/templates/editor/show.html.leex and annotate our textarea:

<textarea phx-keyup="render_post"></textarea>

This names the event (render_post) and sends it on each keyup. Let’s crack open our web inspector and look at the web socket traffic. Using Chrome, open the developer tools, navigate to the network tab and click WS. In development you’ll see two socket connections: one is Phoenix LiveReload, which polls your filesystem and reloads pages appropriately. The second one is our LiveView connection. If you let it sit for a while, you’ll see that it's emitting a “heartbeat” call. If your server is running, you’ll see that it responds with an “ok” message. This lets LiveView clients know when they've lost connection to the server and respond appropriately.

Now, type some text and watch as it sends down each keystroke. However, you’ll also notice that the server responds with a “phx_error” message and wipes out our entered text. That's because our server doesn’t know how to handle the event yet and is throwing an error. Let's fix that next.

Event handling

We’ll catch the event in our EditorLive module. The LiveView behavior defines a handle_event/3 callback that we need to implement. Open up lib/frampton_web/live/editor_live.ex and key in a basic implementation that lets us catch events:

def handle_event("render_post", params, socket) do
  IO.inspect(params)

  {:noreply, socket}
end

The first argument is the name we gave to our event in the template, the second is the data from that event, and finally the socket we’re currently talking through. Give it a try, typing in a few characters. Look at your running server and you should see a stream of events that look something like this:

There’s our keystrokes! Next, let’s pull out that value and use it to render HTML.

Rendering Markdown

Lets adjust our handle_event to pattern match out the value of the textarea:

def handle_event("render_post", %{"value" => raw}, socket) do

Now that we’ve got the raw markdown string, turning it into HTML is easy thanks to the work we did earlier in our Post module. Fill out the body of the function like this:

{:ok, post} = Post.render(%Post{}, raw)
IO.inspect(post)

If you type into the textarea you should see output that looks something like this:

Perfect! Lastly, it’s time to send that rendered html back to the page.

Returning HTML to the page

In a LiveView template, we can identify bits of dynamic data that will change over time. When they change, LiveView will compare what has changed and send over a diff. In our case, the dynamic content is the post body.

Open up show.html.leex again and modify it like so:

<div class="rendered-output">
  <%= @post.body %>
</div>

Refresh the page and see:

Whoops!

The @post variable will only be available after we put it into the socket’s assigns. Let’s initialize it with a blank post. Open editor_live.ex and modify our mount/3 function:

def mount(_params, _session, socket) do
  post = %Post{}
  {:ok, assign(socket, post: post)}
end

In the future, we could retrieve this from some kind of storage, but for now, let's just create a new one each time the page refreshes. Finally, we need to update the Post struct with user input. Update our event handler like this:

def handle_event("render_post", %{"value" => raw}, %{assigns: %{post: post}} = socket) do
  {:ok, post} = Post.render(post, raw)
  {:noreply, assign(socket, post: post)
end

Let's load up http://localhost:4000/editor and see it in action.

Nope, that's not quite right! Phoenix won’t render this as HTML because it’s unsafe user input. We can get around this (very good and useful) security feature by wrapping our content in a raw/1 call. We don’t have a database and user processes are isolated from each other by Elixir. The worst thing a malicious user could do would be crash their own session, which doesn’t bother me one bit.

Check the edit_posts branch for the final version.

Conclusion

That’s a good place to stop for today. We’ve accomplished a lot! We’ve got a dynamically rendering editor that takes user input, processes it and updates the page. And we haven’t written any JavaScript, which means we don’t have to maintain or update any JavaScript. Our server code is built on the rock-solid foundation of the BEAM virtual machine, giving us a great deal of confidence in its reliability and resilience.

In the next post, we’ll tackle making a shared editor, allowing multiple users to edit the same post. This project will highlight Elixir’s concurrency capabilities and demonstrate how LiveView builds on them to enable some incredible user experiences.



  • Code
  • Back-end Engineering

tor

Illustrator Tutorial: How to Create an iPhone Icon

Welcome back to another Adobe Illustrator based tutorial, in which we're going to take a close look behind the process of creating a simple iPhone icon, using nothing more than some basic geometric shapes that we're going to adjust here and there. 1. Set Up a New Project File As with any new project, we’re […]

The post Illustrator Tutorial: How to Create an iPhone Icon appeared first on Bittbox.




tor

Illustrator Tutorial: How to Create a Simple Computer Icon

In today’s tutorial, we're going to take a close look behind the process of creating a simple computer icon, and see how easy it is to build one of our one using nothing more than some basic geometric shapes. 1. Set Up a New Project File As with any new project, we’re going to kick […]

The post Illustrator Tutorial: How to Create a Simple Computer Icon appeared first on Bittbox.




tor

Illustrator Tutorial: How to Create a Folder Icon

In today’s tutorial, we’re going to take an in-depth look behind the process of creating a folder icon, and see how easy it is to build one from scratch using nothing more than a couple of basic geometric shapes, which we’re going to adjust here and there. So, assuming you already have Illustrator up and […]

The post Illustrator Tutorial: How to Create a Folder Icon appeared first on Bittbox.




tor

Illustrator Tutorial: How to Create a Watch Icon

Welcome back to another Illustrator based tutorial, in which we’re going to learn how to create a simple watch icon, using nothing more than a couple of basic geometric shapes and tools. So, assuming you already have the software running in the background, bring it up and let’s jump straight into it! 1. Set Up […]

The post Illustrator Tutorial: How to Create a Watch Icon appeared first on Bittbox.




tor

Illustrator Tutorial: How to Create an Icognito Icon

Welcome back to another Illustrator based tutorial, in which we’re going to take a close look behind the process of creating an incognito icon, using nothing more than a couple of simple shapes and tools. So, assuming you already have the software running in the background, bring it up and let’s jump straight into it! […]

The post Illustrator Tutorial: How to Create an Icognito Icon appeared first on Bittbox.




tor

Illustrator Tutorial: How to Create an Ice Cream icon

In today’s tutorial, we’re going to take a quick look at the process of creating an Ice Cream icon, and learn how easy it is to build one from scratch using nothing more than a couple of basic geometric shapes that we’re going to adjust here and there. So, assuming you already have the software […]

The post Illustrator Tutorial: How to Create an Ice Cream icon appeared first on Bittbox.




tor

Illustrator Tutorial: How to Create a Notification Bell Icon

n today’s tutorial, we’re going to take a quick look behind the process of creating a notification bell icon, and see how easy it is to do so using nothing more than a couple of basic geometric shapes and tools. So, assuming you already have the software up and running, let’s jump straight into it! […]

The post Illustrator Tutorial: How to Create a Notification Bell Icon appeared first on Bittbox.




tor

Illustrator Tutorial: How to Create a Recycle Bin Notification Icon

Welcome back to another Illustrator based tutorial, in which we’re going to learn how to create a recycle bin notification icon, using nothing more than a couple of basic geometric shapes that we’re going to adjust here and there. So, assuming you already have the software running in the background, bring it up and let’s […]

The post Illustrator Tutorial: How to Create a Recycle Bin Notification Icon appeared first on Bittbox.




tor

A simple random bit on var selector

Isobar’s Rob Larsen suggests that there is often a need to build CSS selectors dynamically when building applications. ”This is typically some existing pattern paired with a loop counter or something pulled from a data attribute,” he writes on his blog. His choice is to create a variable called ”selector” and ”to craft the selector Read the rest...




tor

Google Ranking Factors 2020: Facts and Myths

Google’s ranking algorithm continues to get more and more complex, and the Ranking Factors 2020: Facts and Myths infographic from Link-Assistant tries to break through some of the misinformation that’s out there.

It seems a little while ago that Google hinted at having 200+ ranking factors. Though in fact, it happened in the year of 2009, and we are heading to 2020 now.

Google has drastically evolved over the past ten years. Today, neural matching — an AI-based method — processes about 30% of all searches, and Google can recognize concepts behind keywords. They have introduced RankBrain, mobile-first indexing, and HTTPS. As we need to adapt to changes and find ways to get atop of SERPs, the topic of ranking factors remains as fresh as ever.

So let's have a look at what ranking factors to consider in 2020, and what ranking myths to leave behind.

I have mixed feelings about this infographics design:

Good:

  • It’s a concise summary of very complex information that’s laid out in the more detailed, full article.

  • The infographic is a handy reference sheet and great for use in social media as promotion for the article.

  • Clean arrangement that’s easy to read from top-to-bottom

Bad:

  • Almost all text.

  • Not that there’s much data that could have been visualized with charts, but some visual design elements would have made the infographic easier to read and more enticing to readers.

  • Text URL to the article! When the infographic gets shared, how are readers supposed to find the article when it’s not linked??? Put it in the footer on the infographic!




tor

History of Design in Michigan

While most known for automotive, Michigan has a rich history in design. As a designer myself, I wanted to learn more about Michigan’s design roots. Not knowing what to expect, I found Michigan is home to many historic designers, several innovative design-forward companies, and top design schools. Automotive is a source of Michigan pride, but […]

The post History of Design in Michigan appeared first on Psychology of Web Design | 3.7 Blog.




tor

Cinematic Street Photography by Victor Cambet

Cinematic Street Photography by Victor Cambet

AoiroStudioMay 07, 2020

Victor Cambet is a freelance graphic designer and an amazing photographer currently based in Montreal, QC. What initially caught my eyes on Victor's work is his perspective of how he sees things through his camera lenses. It's pure, raw, and cinematic street photography. That's one of the reasons why we decided to feature his work on ABDZ. Being a personal fan of Victor's, I have always enjoyed his shots from my hometown of Montreal (and still do). I have lived in this city for more than 30 years and it's quite a pleasant sentiment. Definitely check out his Instagram, you will get to follow the 'behind-the-scenes' stories and you will notice how Victor is passionate and patient with his photography. Make sure to give him some love.

La rue est un film où chaque inconnu en devient le personnage principal.

About Victor Cambet

Victor is a freelance graphic designer currently based in my hometown of Montreal, Qc in Canada. You should definitely follow Victor and check out his store.

View this post on Instagram

La rue est un film...

A post shared by Victor Cambet (@victorcambet) on

View this post on Instagram

L’homme au chapeau.

A post shared by Victor Cambet (@victorcambet) on

View this post on Instagram

De l’ombre à la lumière.

A post shared by Victor Cambet (@victorcambet) on

View this post on Instagram

Un regard.

A post shared by Victor Cambet (@victorcambet) on

View this post on Instagram

Une silhouette dans la nuit.

A post shared by Victor Cambet (@victorcambet) on

View this post on Instagram

À découvert.

A post shared by Victor Cambet (@victorcambet) on


tor

How to Create an Amazon Affiliate Store (Step by Step)

Do you want to add an Amazon affiliate store with WordPress? Amazon is the world’s largest online store that helps thousands of merchants to sell products online across the world. They have an official affiliate system that allows affiliate marketers like you to recommend Amazon products to your website’s audience and earn an affiliate commission. […]

The post How to Create an Amazon Affiliate Store (Step by Step) appeared first on IsItWP - Free WordPress Theme Detector.



  • WordPress Tutorials
  • amazon affiliate store
  • amazon affiliate store with wordpress
  • create an amazon affiliate store
  • create an amazon affiliate store with wordpress
  • how to create an amazon affiliate store

tor

10 On-Page SEO Factors You Should Consider [2019]

When you want to succeed in the organic search engine results today, you have to focus on your website and learn what you should do to optimize it. There are many factors that can help you with that, form the technical, off-page, and on-page. All these factors and parts of a website require updating and […]

Original post: 10 On-Page SEO Factors You Should Consider [2019]

The post 10 On-Page SEO Factors You Should Consider [2019] appeared first on Daily Blog Tips.




tor

A [big] new challenge—the story behind the Creative Calling book cover

When it was time to think about the cover – the whole design package – for my NEW BOOK, Creative Calling, I knew I wanted it to be something different. After all…see if you follow me here… it’s just wrong to make a book about creativity with just any old trend, cliche book cover.  Instead, the package needed to embody the ideas within. So when we approached this design challenge of a hard bound book – it had to be meaningful, beautiful, AND stand out in a sea of other books on the shelf.  No small task… And consider this:  you know that this isn’t just a nice story about the book cover.  This is a metaphor for any creative challenge.  Like every episode of podcast is full of practical advice….this is the real life story of ups and downs on this process…on how we struggled to overcame the challenge front of us… with costs, design options, time, publisher feedback, and other real-life constraints.  In short of EVERY CREATIVE PROCESS.  I’ve included 2 live-recorded phone calls with the designers on the project, Lou and Vasco, so you get their take on the creation process, challenges, the concepts behind what we set out to […]

The post A [big] new challenge—the story behind the Creative Calling book cover appeared first on Chase Jarvis Photography.




tor

Imagine What’s Possible – On Stage /w Humans of New York Creator Brandon Stanton

My book Creative Calling is out! Thanks for all your love, support, and help getting it out into the world. We kicked off celebrations in Seattle with over 700 people in attendance to talk about Creativity with my good buddy, Humans of New York creator, Brandon Stanton. I recorded the session for you. Hope you enjoy! FOLLOW HUMANS OF NEW YORK: instagram | twitter | website Listen to the Podcast Subscribe   This podcast is brought to you by CreativeLive. CreativeLive is the world’s largest hub for online creative education in photo/video, art/design, music/audio, craft/maker, money/life and the ability to make a living in any of those disciplines. They are high quality, highly curated classes taught by the world’s top experts — Pulitzer, Oscar, Grammy Award winners, New York Times best selling authors and the best entrepreneurs of our times.

The post Imagine What’s Possible – On Stage /w Humans of New York Creator Brandon Stanton appeared first on Chase Jarvis Photography.




tor

Markdown Comes Alive! Part 1, Basic Editor

In my last post, I covered what LiveView is at a high level. In this series, we’re going to dive deeper and implement a LiveView powered Markdown editor called Frampton. This series assumes you have some familiarity with Phoenix and Elixir, including having them set up locally. Check out Elizabeth’s three-part series on getting started with Phoenix for a refresher.

This series has a companion repository published on GitHub. Get started by cloning it down and switching to the starter branch. You can see the completed application on master. Our goal today is to make a Markdown editor, which allows a user to enter Markdown text on a page and see it rendered as HTML next to it in real-time. We’ll make use of LiveView for the interaction and the Earmark package for rendering Markdown. The starter branch provides some styles and installs LiveView.

Rendering Markdown

Let’s set aside the LiveView portion and start with our data structures and the functions that operate on them. To begin, a Post will have a body, which holds the rendered HTML string, and title. A string of markdown can be turned into HTML by calling Post.render(post, markdown). I think that just about covers it!

First, let’s define our struct in lib/frampton/post.ex:

defmodule Frampton.Post do
  defstruct body: "", title: ""

  def render(%__MODULE{} = post, markdown) do
    # Fill me in!
  end
end

Now the failing test (in test/frampton/post_test.exs):

describe "render/2" do
  test "returns our post with the body set" do
    markdown = "# Hello world!"                                                                                                                 
    assert Post.render(%Post{}, markdown) == {:ok, %Post{body: "<h1>Hello World</h1>
"}}
  end
end

Our render method will just be a wrapper around Earmark.as_html!/2 that puts the result into the body of the post. Add {:earmark, "~> 1.4.3"} to your deps in mix.exs, run mix deps.get and fill out render function:

def render(%__MODULE{} = post, markdown) do
  html = Earmark.as_html!(markdown)
  {:ok, Map.put(post, :body, html)}
end

Our test should now pass, and we can render posts! [Note: we’re using the as_html! method, which prints error messages instead of passing them back to the user. A smarter version of this would handle any errors and show them to the user. I leave that as an exercise for the reader…] Time to play around with this in an IEx prompt (run iex -S mix in your terminal):

iex(1)> alias Frampton.Post
Frampton.Post
iex(2)> post = %Post{}
%Frampton.Post{body: "", title: ""}
iex(3)> {:ok, updated_post} = Post.render(post, "# Hello world!")
{:ok, %Frampton.Post{body: "<h1>Hello world!</h1>
", title: ""}}
iex(4)> updated_post
%Frampton.Post{body: "<h1>Hello world!</h1>
", title: ""}

Great! That’s exactly what we’d expect. You can find the final code for this in the render_post branch.

LiveView Editor

Now for the fun part: Editing this live!

First, we’ll need a route for the editor to live at: /editor sounds good to me. LiveViews can be rendered from a controller, or directly in the router. We don’t have any initial state, so let's go straight from a router.

First, let's put up a minimal test. In test/frampton_web/live/editor_live_test.exs:

defmodule FramptonWeb.EditorLiveTest do
  use FramptonWeb.ConnCase
  import Phoenix.LiveViewTest

  test "the editor renders" do
    conn = get(build_conn(), "/editor")
    assert html_response(conn, 200) =~ "data-test="editor""
  end
end

This test doesn’t do much yet, but notice that it isn’t live view specific. Our first render is just the same as any other controller test we’d write. The page’s content is there right from the beginning, without the need to parse JavaScript or make API calls back to the server. Nice.

To make that test pass, add a route to lib/frampton_web/router.ex. First, we import the LiveView code, then we render our Editor:

import Phoenix.LiveView.Router
# … Code skipped ...
# Inside of `scope "/"`:
live "/editor", EditorLive

Now place a minimal EditorLive module, in lib/frampton_web/live/editor_live.ex:

defmodule FramptonWeb.EditorLive do
  use Phoenix.LiveView

  def render(assigns) do
    ~L"""
      <div data-test=”editor”>
        <h1>Hello world!</h1>
      </div>
      """
  end

  def mount(_params, _session, socket) do
    {:ok, socket}
  end
end

And we have a passing test suite! The ~L sigil designates that LiveView should track changes to the content inside. We could keep all of our markup in this render/1 method, but let’s break it out into its own template for demonstration purposes.

Move the contents of render into lib/frampton_web/templates/editor/show.html.leex, and replace EditorLive.render/1 with this one liner: def render(assigns), do: FramptonWeb.EditorView.render("show.html", assigns). And finally, make an EditorView module in lib/frampton_web/views/editor_view.ex:

defmodule FramptonWeb.EditorView do
  use FramptonWeb, :view
  import Phoenix.LiveView
end

Our test should now be passing, and we’ve got a nicely separated out template, view and “live” server. We can keep markup in the template, helper functions in the view, and reactive code on the server. Now let’s move forward to actually render some posts!

Handling User Input

We’ve got four tasks to accomplish before we are done:

  1. Take markdown input from the textarea
  2. Send that input to the LiveServer
  3. Turn that raw markdown into HTML
  4. Return the rendered HTML to the page.

Event binding

To start with, we need to annotate our textarea with an event binding. This tells the liveview.js framework to forward DOM events to the server, using our liveview channel. Open up lib/frampton_web/templates/editor/show.html.leex and annotate our textarea:

<textarea phx-keyup="render_post"></textarea>

This names the event (render_post) and sends it on each keyup. Let’s crack open our web inspector and look at the web socket traffic. Using Chrome, open the developer tools, navigate to the network tab and click WS. In development you’ll see two socket connections: one is Phoenix LiveReload, which polls your filesystem and reloads pages appropriately. The second one is our LiveView connection. If you let it sit for a while, you’ll see that it's emitting a “heartbeat” call. If your server is running, you’ll see that it responds with an “ok” message. This lets LiveView clients know when they've lost connection to the server and respond appropriately.

Now, type some text and watch as it sends down each keystroke. However, you’ll also notice that the server responds with a “phx_error” message and wipes out our entered text. That's because our server doesn’t know how to handle the event yet and is throwing an error. Let's fix that next.

Event handling

We’ll catch the event in our EditorLive module. The LiveView behavior defines a handle_event/3 callback that we need to implement. Open up lib/frampton_web/live/editor_live.ex and key in a basic implementation that lets us catch events:

def handle_event("render_post", params, socket) do
  IO.inspect(params)

  {:noreply, socket}
end

The first argument is the name we gave to our event in the template, the second is the data from that event, and finally the socket we’re currently talking through. Give it a try, typing in a few characters. Look at your running server and you should see a stream of events that look something like this:

There’s our keystrokes! Next, let’s pull out that value and use it to render HTML.

Rendering Markdown

Lets adjust our handle_event to pattern match out the value of the textarea:

def handle_event("render_post", %{"value" => raw}, socket) do

Now that we’ve got the raw markdown string, turning it into HTML is easy thanks to the work we did earlier in our Post module. Fill out the body of the function like this:

{:ok, post} = Post.render(%Post{}, raw)
IO.inspect(post)

If you type into the textarea you should see output that looks something like this:

Perfect! Lastly, it’s time to send that rendered html back to the page.

Returning HTML to the page

In a LiveView template, we can identify bits of dynamic data that will change over time. When they change, LiveView will compare what has changed and send over a diff. In our case, the dynamic content is the post body.

Open up show.html.leex again and modify it like so:

<div class="rendered-output">
  <%= @post.body %>
</div>

Refresh the page and see:

Whoops!

The @post variable will only be available after we put it into the socket’s assigns. Let’s initialize it with a blank post. Open editor_live.ex and modify our mount/3 function:

def mount(_params, _session, socket) do
  post = %Post{}
  {:ok, assign(socket, post: post)}
end

In the future, we could retrieve this from some kind of storage, but for now, let's just create a new one each time the page refreshes. Finally, we need to update the Post struct with user input. Update our event handler like this:

def handle_event("render_post", %{"value" => raw}, %{assigns: %{post: post}} = socket) do
  {:ok, post} = Post.render(post, raw)
  {:noreply, assign(socket, post: post)
end

Let's load up http://localhost:4000/editor and see it in action.

Nope, that's not quite right! Phoenix won’t render this as HTML because it’s unsafe user input. We can get around this (very good and useful) security feature by wrapping our content in a raw/1 call. We don’t have a database and user processes are isolated from each other by Elixir. The worst thing a malicious user could do would be crash their own session, which doesn’t bother me one bit.

Check the edit_posts branch for the final version.

Conclusion

That’s a good place to stop for today. We’ve accomplished a lot! We’ve got a dynamically rendering editor that takes user input, processes it and updates the page. And we haven’t written any JavaScript, which means we don’t have to maintain or update any JavaScript. Our server code is built on the rock-solid foundation of the BEAM virtual machine, giving us a great deal of confidence in its reliability and resilience.

In the next post, we’ll tackle making a shared editor, allowing multiple users to edit the same post. This project will highlight Elixir’s concurrency capabilities and demonstrate how LiveView builds on them to enable some incredible user experiences.



  • Code
  • Back-end Engineering

tor

Freebie: 264 Vector Audio DJ Pack Icons

Icons packs are among the most desirable freebies around. There are several out there, going from a wide array of topics from user interfaces to personal finance. But sometimes you can find some rather unusual but clever additions to the icons universe. This Vector Audio DJ Pack is a nice example, brought to you exclusively …

Freebie: 264 Vector Audio DJ Pack Icons Read More »




tor

240 Basic Icons Vector Freebie

Flat design is everywhere. Nowadays aesthetics is a lot more simple. No more glossy buttons or gradients background, or what a about the shiny table effect every client asked for?.It is all gone now. In favor of a more “undesigned” look a back to basics trend. Following that idea the guys at your favorite resources …

240 Basic Icons Vector Freebie Read More »




tor

Almost invariant subspaces of the shift operator on vector-valued Hardy spaces. (arXiv:2005.02243v2 [math.FA] UPDATED)

In this article, we characterize nearly invariant subspaces of finite defect for the backward shift operator acting on the vector-valued Hardy space which is a vectorial generalization of a result of Chalendar-Gallardo-Partington (C-G-P). Using this characterization of nearly invariant subspace under the backward shift we completely describe the almost invariant subspaces for the shift and its adjoint acting on the vector valued Hardy space.




tor

Solving an inverse problem for the Sturm-Liouville operator with a singular potential by Yurko's method. (arXiv:2004.14721v2 [math.SP] UPDATED)

An inverse spectral problem for the Sturm-Liouville operator with a singular potential from the class $W_2^{-1}$ is solved by the method of spectral mappings. We prove the uniqueness theorem, develop a constructive algorithm for solution, and obtain necessary and sufficient conditions of solvability for the inverse problem in the self-adjoint and the non-self-adjoint cases




tor

Equivalence of classical and quantum completeness for real principal type operators on the circle. (arXiv:2004.07547v3 [math.AP] UPDATED)

In this article, we prove that the completeness of the Hamilton flow and essential self-dajointness are equivalent for real principal type operators on the circle. Moreover, we study spectral properties of these operators.




tor

Tori Can't Collapse to an Interval. (arXiv:2004.01505v3 [math.DG] UPDATED)

Here we prove that under a lower sectional curvature bound, a sequence of manifolds diffeomorphic to the standard $m$-dimensional torus cannot converge in the Gromov-Hausdorff sense to a closed interval.




tor

Surface Effects in Superconductors with Corners. (arXiv:2003.00521v2 [math-ph] UPDATED)

We review some recent results on the phenomenon of surface superconductivity in the framework of Ginzburg-Landau theory for extreme type-II materials. In particular, we focus on the response of the superconductor to a strong longitudinal magnetic field in the regime where superconductivity survives only along the boundary of the wire. We derive the energy and density asymptotics for samples with smooth cross section, up to curvature-dependent terms. Furthermore, we discuss the corrections in presence of corners at the boundary of the sample.




tor

A stochastic approach to the synchronization of coupled oscillators. (arXiv:2002.04472v2 [nlin.AO] UPDATED)

This paper deals with an optimal control problem associated to the Kuramoto model describing the dynamical behavior of a network of coupled oscillators. Our aim is to design a suitable control function allowing us to steer the system to a synchronized configuration in which all the oscillators are aligned on the same phase. This control is computed via the minimization of a given cost functional associated with the dynamics considered. For this minimization, we propose a novel approach based on the combination of a standard Gradient Descent (GD) methodology with the recently-developed Random Batch Method (RBM) for the efficient numerical approximation of collective dynamics. Our simulations show that the employment of RBM improves the performances of the GD algorithm, reducing the computational complexity of the minimization process and allowing for a more efficient control calculation.




tor

Convolutions on the complex torus. (arXiv:1908.11815v3 [math.RA] UPDATED)

"Quasi-elliptic" functions can be given a ring structure in two different ways, using either ordinary multiplication, or convolution. The map between the corresponding standard bases is calculated and given by Eisenstein series. A related structure has appeared recently in the computation of Feynman integrals. The two approaches are related by a sequence of polynomials with interlacing zeroes.




tor

Gluing curves of genus 1 and 2 along their 2-torsion. (arXiv:2005.03587v1 [math.AG])

Let $X$ (resp. $Y$) be a curve of genus 1 (resp. 2) over a base field $k$ whose characteristic does not equal 2. We give criteria for the existence of a curve $Z$ over $k$ whose Jacobian is up to twist (2,2,2)-isogenous to the products of the Jacobians of $X$ and $Y$. Moreover, we give algorithms to construct the curve $Z$ once equations for $X$ and $Y$ are given. The first of these involves the use of hyperplane sections of the Kummer variety of $Y$ whose desingularization is isomorphic to $X$, whereas the second is based on interpolation methods involving numerical results over $mathbb{C}$ that are proved to be correct over general fields a posteriori. As an application, we find a twist of a Jacobian over $mathbb{Q}$ that admits a rational 70-torsion point.




tor

Off-diagonal estimates for bi-commutators. (arXiv:2005.03548v1 [math.CA])

We study the bi-commutators $[T_1, [b, T_2]]$ of pointwise multiplication and Calder'on-Zygmund operators, and characterize their $L^{p_1}L^{p_2} o L^{q_1}L^{q_2}$ boundedness for several off-diagonal regimes of the mixed-norm integrability exponents $(p_1,p_2) eq(q_1,q_2)$. The strategy is based on a bi-parameter version of the recent approximate weak factorization method.




tor

Asymptotic behavior of Wronskian polynomials that are factorized via $p$-cores and $p$-quotients. (arXiv:2005.03516v1 [math.CA])

In this paper we consider Wronskian polynomials labeled by partitions that can be factorized via the combinatorial concepts of $p$-cores and $p$-quotients. We obtain the asymptotic behavior for these polynomials when the $p$-quotient is fixed while the size of the $p$-core grows to infinity. For this purpose, we associate the $p$-core with its characteristic vector and let all entries of this vector simultaneously tend to infinity. This result generalizes the Wronskian Hermite setting which is recovered when $p=2$.




tor

Continuity properties of the shearlet transform and the shearlet synthesis operator on the Lizorkin type spaces. (arXiv:2005.03505v1 [math.FA])

We develop a distributional framework for the shearlet transform $mathcal{S}_{psi}colonmathcal{S}_0(mathbb{R}^2) omathcal{S}(mathbb{S})$ and the shearlet synthesis operator $mathcal{S}^t_{psi}colonmathcal{S}(mathbb{S}) omathcal{S}_0(mathbb{R}^2)$, where $mathcal{S}_0(mathbb{R}^2)$ is the Lizorkin test function space and $mathcal{S}(mathbb{S})$ is the space of highly localized test functions on the standard shearlet group $mathbb{S}$. These spaces and their duals $mathcal{S}_0^prime (mathbb R^2),, mathcal{S}^prime (mathbb{S})$ are called Lizorkin type spaces of test functions and distributions. We analyze the continuity properties of these transforms when the admissible vector $psi$ belongs to $mathcal{S}_0(mathbb{R}^2)$. Then, we define the shearlet transform and the shearlet synthesis operator of Lizorkin type distributions as transpose mappings of the shearlet synthesis operator and the shearlet transform, respectively. They yield continuous mappings from $mathcal{S}_0^prime (mathbb R^2)$ to $mathcal{S}^prime (mathbb{S})$ and from $mathcal{S}^prime (mathbb S)$ to $mathcal{S}_0^prime (mathbb{R}^2)$. Furthermore, we show the consistency of our definition with the shearlet transform defined by direct evaluation of a distribution on the shearlets. The same can be done for the shearlet synthesis operator. Finally, we give a reconstruction formula for Lizorkin type distributions, from which follows that the action of such generalized functions can be written as an absolutely convergent integral over the standard shearlet group.




tor

Toric Sasaki-Einstein metrics with conical singularities. (arXiv:2005.03502v1 [math.DG])

We show that any toric K"ahler cone with smooth compact cross-section admits a family of Calabi-Yau cone metrics with conical singularities along its toric divisors. The family is parametrized by the Reeb cone and the angles are given explicitly in terms of the Reeb vector field. The result is optimal, in the sense that any toric Calabi-Yau cone metric with conical singularities along the toric divisor (and smooth elsewhere) belongs to this family. We also provide examples and interpret our results in terms of Sasaki-Einstein metrics.




tor

Derivatives of normal Jacobi operator on real hypersurfaces in the complex quadric. (arXiv:2005.03483v1 [math.DG])

In cite{S 2017}, Suh gave a non-existence theorem for Hopf real hypersurfaces in the complex quadric with parallel normal Jacobi operator. Motivated by this result, in this paper, we introduce some generalized conditions named $mathcal C$-parallel or Reeb parallel normal Jacobi operators. By using such weaker parallelisms of normal Jacobi operator, first we can assert a non-existence theorem of Hopf real hypersurfaces with $mathcal C$-parallel normal Jacobi operator in the complex quadric $Q^{m}$, $m geq 3$. Next, we prove that a Hopf real hypersurface has Reeb parallel normal Jacobi operator if and only if it has an $mathfrak A$-isotropic singular normal vector field.




tor

Semiglobal non-oscillatory big bang singular spacetimes for the Einstein-scalar field system. (arXiv:2005.03395v1 [math-ph])

We construct semiglobal singular spacetimes for the Einstein equations coupled to a massless scalar field. Consistent with the heuristic analysis of Belinskii, Khalatnikov, Lifshitz or BKL for this system, there are no oscillations due to the scalar field. (This is much simpler than the oscillatory BKL heuristics for the Einstein vacuum equations.) Prior results are due to Andersson and Rendall in the real analytic case, and Rodnianski and Speck in the smooth near-spatially-flat-FLRW case. Similar to Andersson and Rendall we give asymptotic data at the singularity, which we refer to as final data, but our construction is not limited to real analytic solutions. This paper is a test application of tools (a graded Lie algebra formulation of the Einstein equations and a filtration) intended for the more subtle vacuum case. We use homological algebra tools to construct a formal series solution, then symmetric hyperbolic energy estimates to construct a true solution well-approximated by truncations of the formal one. We conjecture that the image of the map from final data to initial data is an open set of anisotropic initial data.




tor

Type space functors and interpretations in positive logic. (arXiv:2005.03376v1 [math.LO])

We construct a 2-equivalence $mathfrak{CohTheory}^ ext{op} simeq mathfrak{TypeSpaceFunc}$. Here $mathfrak{CohTheory}$ is the 2-category of positive theories and $mathfrak{TypeSpaceFunc}$ is the 2-category of type space functors. We give a precise definition of interpretations for positive logic, which will be the 1-cells in $mathfrak{CohTheory}$. The 2-cells are definable homomorphisms. The 2-equivalence restricts to a duality of categories, making precise the philosophy that a theory is `the same' as the collection of its type spaces (i.e. its type space functor).

In characterising those functors that arise as type space functors, we find that they are specific instances of (coherent) hyperdoctrines. This connects two different schools of thought on the logical structure of a theory.

The key ingredient, the Deligne completeness theorem, arises from topos theory, where positive theories have been studied under the name of coherent theories.




tor

Converging outer approximations to global attractors using semidefinite programming. (arXiv:2005.03346v1 [math.OC])

This paper develops a method for obtaining guaranteed outer approximations for global attractors of continuous and discrete time nonlinear dynamical systems. The method is based on a hierarchy of semidefinite programming problems of increasing size with guaranteed convergence to the global attractor. The approach taken follows an established line of reasoning, where we first characterize the global attractor via an infinite dimensional linear programming problem (LP) in the space of Borel measures. The dual to this LP is in the space of continuous functions and its feasible solutions provide guaranteed outer approximations to the global attractor. For systems with polynomial dynamics, a hierarchy of finite-dimensional sum-of-squares tightenings of the dual LP provides a sequence of outer approximations to the global attractor with guaranteed convergence in the sense of volume discrepancy tending to zero. The method is very simple to use and based purely on convex optimization. Numerical examples with the code available online demonstrate the method.




tor

Evaluating the phase dynamics of coupled oscillators via time-variant topological features. (arXiv:2005.03343v1 [physics.data-an])

The characterization of phase dynamics in coupled oscillators offers insights into fundamental phenomena in complex systems. To describe the collective dynamics in the oscillatory system, order parameters are often used but are insufficient for identifying more specific behaviors. We therefore propose a topological approach that constructs quantitative features describing the phase evolution of oscillators. Here, the phase data are mapped into a high-dimensional space at each time point, and topological features describing the shape of the data are subsequently extracted from the mapped points. We extend these features to time-variant topological features by considering the evolution time, which serves as an additional dimension in the topological-feature space. The resulting time-variant features provide crucial insights into the time evolution of phase dynamics. We combine these features with the machine learning kernel method to characterize the multicluster synchronized dynamics at a very early stage of the evolution. Furthermore, we demonstrate the usefulness of our method for qualitatively explaining chimera states, which are states of stably coexisting coherent and incoherent groups in systems of identical phase oscillators. The experimental results show that our method is generally better than those using order parameters, especially if only data on the early-stage dynamics are available.




tor

Pointwise densities of homogeneous Cantor measure and critical values. (arXiv:2005.03269v1 [math.DS])

Let $Nge 2$ and $ hoin(0,1/N^2]$. The homogenous Cantor set $E$ is the self-similar set generated by the iterated function system

[

left{f_i(x)= ho x+frac{i(1- ho)}{N-1}: i=0,1,ldots, N-1 ight}.

]

Let $s=dim_H E$ be the Hausdorff dimension of $E$, and let $mu=mathcal H^s|_E$ be the $s$-dimensional Hausdorff measure restricted to $E$. In this paper we describe, for each $xin E$, the pointwise lower $s$-density $Theta_*^s(mu,x)$ and upper $s$-density $Theta^{*s}(mu, x)$ of $mu$ at $x$. This extends some early results of Feng et al. (2000). Furthermore, we determine two critical values $a_c$ and $b_c$ for the sets

[

E_*(a)=left{xin E: Theta_*^s(mu, x)ge a ight}quad extrm{and}quad E^*(b)=left{xin E: Theta^{*s}(mu, x)le b ight}

] respectively, such that $dim_H E_*(a)>0$ if and only if $a<a_c$, and that $dim_H E^*(b)>0$ if and only if $b>b_c$. We emphasize that both values $a_c$ and $b_c$ are related to the Thue-Morse type sequences, and our strategy to find them relies on ideas from open dynamics and techniques from combinatorics on words.




tor

The Quantum Twistor Bundle. (arXiv:2005.03268v1 [math.QA])

We investigate the quantum twistor bundle constructed as a $U(1)$-quotient of the quantum instanton bundle of Bonechi, Ciccoli and Tarlini. It is an example of a locally trivial noncommutative bundle fulfilling conditions of the framework recently proposed by Brzezi'nski and Szyma'nski. In particular, we give a detailed description of the corresponding $C^*$-algebra of 'continuous functions' on its noncommutative total space. Furthermore, we analyse a different construction of a quantum instanton bundle due to Landi, Pagani and Reina, find a basis of its polynomial algebra and discover an intriguing and unexpected feature of its enveloping $C^*$-algebra.




tor

An Issue Raised in 1978 by a Then-Future Editor-in-Chief of the Journal "Order": Does the Endomorphism Poset of a Finite Connected Poset Tell Us That the Poset Is Connected?. (arXiv:2005.03255v1 [math.CO])

In 1978, Dwight Duffus---editor-in-chief of the journal "Order" from 2010 to 2018 and chair of the Mathematics Department at Emory University from 1991 to 2005---wrote that "it is not obvious that $P$ is connected and $P^P$ isomorphic to $Q^Q$ implies that $Q$ is connected," where $P$ and $Q$ are finite non-empty posets. We show that, indeed, under these hypotheses $Q$ is connected and $Pcong Q$.




tor

Sharp p-bounds for maximal operators on finite graphs. (arXiv:2005.03146v1 [math.CA])

Let $G=(V,E)$ be a finite graph and $M_G$ be the centered Hardy-Littlewood maximal operator defined there. We found the optimal value $C_{G,p}$ such that the inequality $$Var_{p}(M_{G}f)le C_{G,p}Var_{p}(f)$$ holds for every every $f:V o mathbb{R},$ where $Var_p$ stands for the $p$-variation, when: (i)$G=K_n$ (complete graph) and $pin [frac{ln(4)}{ln(6)},infty)$ or $G=K_4$ and $pin (0,infty)$;(ii) $G=S_n$(star graph) and $1ge pge frac{1}{2}$; $pin (0,frac{1}{2})$ and $nge C(p)<infty$ or $G=S_3$ and $pin (1,infty).$ We also found the optimal value $L_{G,2}$ such that the inequality $$|M_{G}f|_2le L_{G,2}|f|_2$$ holds for every $f:V o mathbb{R}$, when: (i)$G=K_n$ and $nge 3$;(ii)$G=S_n$ and $nge 3.$




tor

Automata Tutor v3. (arXiv:2005.01419v2 [cs.FL] UPDATED)

Computer science class enrollments have rapidly risen in the past decade. With current class sizes, standard approaches to grading and providing personalized feedback are no longer possible and new techniques become both feasible and necessary. In this paper, we present the third version of Automata Tutor, a tool for helping teachers and students in large courses on automata and formal languages. The second version of Automata Tutor supported automatic grading and feedback for finite-automata constructions and has already been used by thousands of users in dozens of countries. This new version of Automata Tutor supports automated grading and feedback generation for a greatly extended variety of new problems, including problems that ask students to create regular expressions, context-free grammars, pushdown automata and Turing machines corresponding to a given description, and problems about converting between equivalent models - e.g., from regular expressions to nondeterministic finite automata. Moreover, for several problems, this new version also enables teachers and students to automatically generate new problem instances. We also present the results of a survey run on a class of 950 students, which shows very positive results about the usability and usefulness of the tool.




tor

Decoding EEG Rhythms During Action Observation, Motor Imagery, and Execution for Standing and Sitting. (arXiv:2004.04107v2 [cs.HC] UPDATED)

Event-related desynchronization and synchronization (ERD/S) and movement-related cortical potential (MRCP) play an important role in brain-computer interfaces (BCI) for lower limb rehabilitation, particularly in standing and sitting. However, little is known about the differences in the cortical activation between standing and sitting, especially how the brain's intention modulates the pre-movement sensorimotor rhythm as they do for switching movements. In this study, we aim to investigate the decoding of continuous EEG rhythms during action observation (AO), motor imagery (MI), and motor execution (ME) for standing and sitting. We developed a behavioral task in which participants were instructed to perform both AO and MI/ME in regard to the actions of sit-to-stand and stand-to-sit. Our results demonstrated that the ERD was prominent during AO, whereas ERS was typical during MI at the alpha band across the sensorimotor area. A combination of the filter bank common spatial pattern (FBCSP) and support vector machine (SVM) for classification was used for both offline and pseudo-online analyses. The offline analysis indicated the classification of AO and MI providing the highest mean accuracy at 82.73$pm$2.38\% in stand-to-sit transition. By applying the pseudo-online analysis, we demonstrated the higher performance of decoding neural intentions from the MI paradigm in comparison to the ME paradigm. These observations led us to the promising aspect of using our developed tasks based on the integration of both AO and MI to build future exoskeleton-based rehabilitation systems.