Skip to content

Instantly share code, notes, and snippets.

View live_view.ex
defmodule AppWeb.PageLive do
use AppWeb, :live_view
alias App.Posts
alias App.Posts.Post
alias App.Votes
@impl true
def mount(_params, session, socket) do
socket = maybe_assign_user(session, socket)
View gist:a274e699b88538df4b63fb66c46af663
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
@mplatts
mplatts / command_line.sh
Last active Aug 14, 2017
Elixir Phoenix Cheatsheet
View command_line.sh
mix help
iex -S mix phx.server # like rails c
h Enum => shows help for Enum
Dossy.Accounts.__info__(:functions) => will list functions in this module
mix phx.routes
# DATABASE
mix ecto.gen.migration add_weather_table
mix ecto.migrate
@mplatts
mplatts / 0firebase_functions_cheatsheet.js
Last active Feb 7, 2020
Firebase functions cheatsheet
View 0firebase_functions_cheatsheet.js
// Core
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
const db = admin.database();
admin.auth().createUser({
uid: uid,
displayName: displayName,
photoURL: photoURL
@mplatts
mplatts / contacts.rb
Last active Feb 20, 2017
Rest properties fields
View contacts.rb
{
:alpha => "WILL L", # user.rest_alpha ?
:name => "Lynne Williams", # user.first_name, user.last_name
:leasename => "Lynne Williams", # ???
:leaseshortname => "Lynne Williams", # ???
:postalline1 => "27B Fisher Avenue", # user.address_line_one
:postalline3 => "Southport Qld 4215", # user.address_line_two
:tenantsuburb => "Southport", # user.suburb
:tenantstate => "Qld", # user.state
:tenantpcode => 4215, # user.postcode
@mplatts
mplatts / meteor_browser_policy.js
Last active Oct 12, 2015
Meteor browser policy
View meteor_browser_policy.js
// First install the browser policy package:
// meteor add browser-policy
BrowserPolicy.framing.disallow();
BrowserPolicy.content.disallowInlineScripts();
BrowserPolicy.content.disallowEval();
BrowserPolicy.content.allowInlineStyles();
BrowserPolicy.content.allowFontDataUrl();
// Change these to whatever services your app needs access to
View example.com.conf
server {
# Internet traffic will come in on port 80
listen 80;
# Apply only to traffic heading to example.com
# NOTE: change to your domain name
server_name example.come;
# When things are going wrong we can check the logs
access_log /var/log/nginx/app.dev.access.log;
@mplatts
mplatts / boot-4-cheat.txt
Last active Sep 27, 2015
Bootstrap 4 cheatsheet
View boot-4-cheat.txt
a - all
t - top
b - bottom
l - left
r - right
x - left and right
y - top and bottom
m-t = margin-top: 1em
m-t-md = margin-top: 1.5em
View iframeSeek.js
// Usage:
//
// var video = videojs('video_id');
// video.iframeSeek();
//
// To start the player at 30s
// $iframe[0].contentWindow.postMessage('startTime:30', '*')
//
(function(window, videojs) {
@mplatts
mplatts / error.js
Created Aug 26, 2015
Meteor error explanation
View error.js
// see http://docs.meteor.com/#/full/meteor_error
var error = new Meteor.Error('error-name', 'reason');
alert(error) //=> Error: reason [error-name]
alert(error.reason) //=> reason
alert(error.error) //=> error-name
// Explanation.. alert(error) is the same as going alert(error.toString()), which results in "Error: error.reason [error.error]"
You can’t perform that action at this time.