-- Save without header | |
copy ((select "name", "email from "user") to '/absolute-path-to-directory/filename.csv' delimiter ',' csv; | |
-- Save with header | |
copy ((select "name", "email from "user") to '/absolute-path-to-directory/filename.csv' delimiter ',' csv header; | |
-- When having issue `must be superuser or a member of pg_write_server_files role COPY to a file`, add a `\` in front of `copy` | |
\copy ((select "name", "email from "user") to '/absolute-path-to-directory/filename.csv' delimiter ',' csv; |
import { useReducer, useCallback, useRef, useEffect } from 'react'; | |
import cond from 'lodash/cond'; | |
import includes from 'lodash/fp/includes'; | |
import stubTrue from 'lodash/stubTrue'; | |
const initialState = { | |
response: null, // could be whatever type of response they are ,expecting | |
loading: false, | |
success: false, | |
error: false, |
This guide was written because I don't particularly enjoy deploying Phoenix (or Elixir for that matter) applications. It's not easy. Primarily, I don't have a lot of money to spend on a nice, fancy VPS so compiling my Phoenix apps on my VPS often isn't an option. For that, we have Distillery releases. However, that requires me to either have a separate server for staging to use as a build server, or to keep a particular version of Erlang installed on my VPS, neither of which sound like great options to me and they all have the possibilities of version mismatches with ERTS. In addition to all this, theres a whole lot of configuration which needs to be done to setup a Phoenix app for deployment, and it's hard to remember.
For that reason, I wanted to use Docker so that all of my deployments would be automated and reproducable. In addition, Docker would allow me to have reproducable builds for my releases. I could build my releases on any machine that I wanted in a contai
If you want a run-down of the 1.3 changes and the design decisions behidn those changes, check out the LonestarElixir Phoenix 1.3 keynote: https://www.youtube.com/watch?v=tMO28ar0lW8
To use the new phx.new
project generator, you can install the archive with the following command:
$ mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez
Phoenix v1.3.0 is a backwards compatible release with v1.2.x. To upgrade your existing 1.2.x project, simply bump your phoenix dependency in mix.exs
:
function* connectToSocket(url) { | |
const socket = new Socket(socketBaseUrl() + url, { params: { token: 'your-auth-token' } }); | |
socket.connect(); | |
return socket; | |
} | |
// channel.join is async, this is probably an error | |
function* joinChannel(socket, channel_name) { | |
const channel = socket.channel(channel_name, {}); | |
channel.join(); |
import R from 'ramda'; | |
const items = [ | |
{id: 1, name: 'Al', country: 'AA'}, | |
{id: 2, name: 'Connie', country: 'BB'}, | |
{id: 3, name: 'Doug', country: 'CC'}, | |
{id: 4, name: 'Zen', country: 'BB'}, | |
{id: 5, name: 'DatGGboi', country: 'AA'}, | |
{id: 6, name: 'Connie', country: 'AA'}, | |
]; |
When deciding between Memcached and Redis, here are a few questions to consider:
- Is object caching your primary goal, for example to offload your database? If so, use Memcached.
- Are you interested in as simple a caching model as possible? If so, use Memcached.
- Are you planning on running large cache nodes, and require multithreaded performance with utilization of multiple cores? If so, use Memcached.
- Do you want the ability to scale your cache horizontally as you grow? If so, use Memcached.
- Does your app need to atomically increment or decrement counters? If so, use either Redis or Memcached.
- Are you looking for more advanced data types, such as lists, hashes, and sets? If so, use Redis.
- Does sorting and ranking datasets in memory help you, such as with leaderboards? If so, use Redis.
- Are publish a
This function returns the nearest aspect ratio of a width and height within a limited range of possible aspect ratios.
In other words, while 649x360 technically has an aspect ratio of 649:360, it’s often useful to know that the nearest normal aspect ratio is actually 9:5 (648x360).
nearestNormalAspectRatio(width, height, [side], [maxWidth], [maxHeight])
Version numbers should be the ones you want. Here I do it with the last ones available at the moment of writing.
The simplest way to install elixir is using your package manager. Sadly, at the time of writing only Fedora shows
the intention to keep its packages up to date. There you can simply sudo dnf install erlang elixir
and you are good to go.
Anyway, if you intend to work with several versions of erlang or elixir at the same time, or you are tied to
a specific version, you will need to compile it yourself. Then asdf
is your best friend.