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 Box do | |
defmacro __using__(_env) do | |
quote do | |
import Box | |
end | |
end | |
@doc """ | |
Define module with struct and typespec, in single line |
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
######################################## | |
# 1. Build nodejs frontend | |
######################################## | |
FROM node:10.9-alpine as build-node | |
# prepare build dir | |
RUN mkdir -p /app/assets | |
WORKDIR /app | |
# set build ENV |
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
# Install pow | |
$ curl get.pow.cx | sh | |
# Install powder | |
$ gem install powder | |
# See that firewall is fucked | |
$ sudo ipfw show | |
00100 0 0 fwd 127.0.0.1,20559 tcp from any to me dst-port 80 in <- THIS ONE!!! | |
65535 81005 28684067 allow ip from any to any |
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 SupportChat do | |
import Phoenix.Component | |
alias Phoenix.LiveView.JS | |
@doc """ | |
Chat bubble at the bottom right corner. | |
""" | |
def bubble(assigns) do | |
~H""" | |
<div> |
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
<?php | |
class Form extends Validation { | |
private $action; | |
private $method; | |
private $name; | |
private $validation; | |
private $vMessage; | |
public $request = array(); | |
public $inputs = array(); |
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 Hello.Admin.CopyLink do | |
use Phoenix.Component | |
@doc """ | |
Render a button (styled as a link) that copies a value to clipboard when clicked. | |
Storybook: Basic | |
<.copy_link value="https://example.com" text="copy link" /> | |
""" | |
def copy_link(assigns) do |
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
require 'clockwork' | |
require 'sidekiq' | |
# load all jobs from app/jobs directory | |
# no need to load rails env, we only care about classes | |
# (#perform method is not invoked in this process) | |
Dir["app/jobs/*"].each {|f| load f } | |
module Clockwork | |
every(1.day, 'midnight.job', :at => '00:00'){ |
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
package controllers | |
import lib._ | |
import play.api.mvc._ | |
import play.api.libs.json._ | |
object Auth extends Controller { | |
val GITHUB = new OAuth2[GithubUser](OAuth2Settings( |
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
# config/initializers/instrumentation.rb | |
# Subscribe to grape request and log with Rails.logger | |
ActiveSupport::Notifications.subscribe('grape.request') do |name, starts, ends, notification_id, payload| | |
Rails.logger.info '[API] %s %s (%.3f ms) -> %s %s%s' % [ | |
payload[:request_method], | |
payload[:request_path], | |
(ends-starts)*1000, | |
(payload[:response_status] || "error"), | |
payload[:x_organization] ? "| X-Org: #{payload[:x_organization]}" : "", |
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 Recruitee.Repo do | |
use Ecto.Repo, otp_app: :recruitee | |
import Ecto.Query | |
@doc """ | |
Stream query results | |
Example: | |
iex> Candidate | |
...> |> where([c], c.foo > 4) |
NewerOlder