Skip to content

Instantly share code, notes, and snippets.

`yarn add actioncable`
import ActionCable from 'react-native-actioncable'
const cable = ActionCable.createConsumer('ws://localhost:3000/cable');
export default class Room extends Component {
componentDidMount () {
this.subscription = cable.subscriptions.create(
'ChannelName',
@ugened47
ugened47 / 1 setup vps
Created December 16, 2019 11:31 — forked from PavloBezpalov/1 setup vps
Deploy Rails 5.1.1 to VPS(Ubuntu 16.04.2 LTS). Nginx mainline + pagespeed, Puma with Jungle, Capistrano3, PostgreSQL 9.6, RVM, Certbot
root# apt-get update
root# apt-get upgrade
// dependencies for Ruby
root# apt-get install -y git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev \
libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev \
libpcre3-dev unzip
// Node.js v7
root# curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
The common reason for this has something to do with shut down. When you shut down your PC or terminate your console(like Terminal in Mac) with your local server that using pg open, the error will occur.
As this https://stackoverflow.com/a/21420719/10738100 says, first try to remove PID file.
rm /usr/local/var/postgres/postmaster.pid
brew services restart postgresql
@ugened47
ugened47 / config.yml
Created December 3, 2018 08:54 — forked from verbaleks/config.yml
CircleCI 2.0 with parallelism & simplecov for Rails
# Ruby CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
defaults: &defaults
working_directory: ~/split_app
parallelism: 2
docker:
- image: circleci/ruby:2.5.0-node-browsers
@ugened47
ugened47 / CustomDrawer.js
Created June 28, 2017 09:27
React Navigation Custom Drawer Example
/* eslint-disable camelcase */
import React, { Component } from 'react'
import { Image, TouchableOpacity, Text, View } from 'react-native'
import AuthActions from '../Redux/AuthRedux'
import { connect } from 'react-redux'
import FBSDK from 'react-native-fbsdk'
import Styles from './Styles/DrawerContentStyles'
import { DrawerItems } from 'react-navigation'
upstream puma_<%= fetch(:nginx_config_name) %> { <%
flags = 'fail_timeout=0'
@backends = [fetch(:puma_bind)].flatten.map do |m|
etype, address = /(tcp|unix|ssl):\/{1,2}(.+)/.match(m).captures
if etype =='unix'
"server #{etype}:#{address} #{fetch(:nginx_socket_flags)};"
else
"server #{address.gsub(/0\.0\.0\.0(.+)/, "127.0.0.1\\1")} #{fetch(:nginx_http_flags)};"
end
end
# Creating app
rails new name
# Start server
rails server (s) [ -b $IP [-p $PORT] ]
# Scaffold (add model)
rails generate scaffold name attribute:type