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
class Printer | |
def self.full_name(person) | |
"Your name is: #{person.fname} #{person.lname}" | |
end | |
end | |
class Person | |
attr_reader :fname, :lname | |
def initialize(fname, lname) |
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
# typed: true | |
class Printer | |
extend T::Sig | |
sig { params(person: Person).returns(String) } | |
def self.full_name(person); end | |
end | |
class Person |
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
#!/bin/sh | |
echo "Loading the test enviromnment..." | |
source .env.test | |
RAILS_ENV=test bundle exec rspec | |
if [[ $? != 0 ]]; then | |
echo "RSpec tests have failures. Push rejected." | |
exit 1 |
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
<%= link_to "javascript: alert('c')" do %> | |
<%= image_tag "foo.png" %> | |
<% end %> |
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 Example.User do | |
use Example.Web, :model | |
schema "users" do | |
field :email, :string | |
timestamps() | |
end | |
@doc """ |
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 https://github.com/rubencaro/cipher first | |
require Cipher.Helpers, as: H | |
defmodule Enc do | |
@random_key H.env(:keyphrase) |> Cipher.Digest.generate_key | |
def stream_encrypt(xml) do | |
{_, result} = | |
:crypto.stream_init(:rc4, @random_key) | |
|> :crypto.stream_encrypt(xml) |
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
-- Assuming we have a list of items in the model (type alias Model = { items : List Item } | |
-- where Item is a record like { id : Int, name : String } | |
-- this goes in the view and generates an html dropdown | |
select | |
[ onSelect ValueSelectedMsg ] | |
(List.map (\item -> option [ value (toString item.id) ] [ text item.name ]) model.items) | |
targetSelectedIndex : Json.Decoder Int |
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
# Purge merged branches | |
git branch --merged | grep -v "\*" | grep -v master | grep -v staging | grep -v develop | xargs -n 1 git branch -d |
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
# Here's how to back up a named volume | |
# 1. Using a `ubuntu` image, we mount the named volume (`myproj_dbdata`) to a `/dbdata` folder inside the `ubuntu` container. | |
# 2. Then, we create a new folder inside the `ubuntu` container named `/backup`. | |
# 3. We then create an archive containing the contents of the `/dbdata` folder and we store it inside the `/backup` folder (inside the container). | |
# 4. We also mount the `/backup` folder from the container to the docker host (your local machine) in a folder named `/backups` inside the current directory. | |
docker run --rm -v myproj_dbdata:/dbdata -v $(pwd)/backups:/backup ubuntu tar cvf /backup/db_data_"$(date '+%y-%m-%d')".tar /dbdata |
NewerOlder