$ mysql_secure_installation
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
/** | |
* from: | |
* "Decoupling Logic with Domain Events [Guide] - Domain-Driven Design w/ TypeScript" | |
* https://khalilstemmler.com/articles/typescript-domain-driven-design/chain-business-logic-domain-events/ | |
*/ | |
import { UseCase } from '../../../../core/domain/UseCase'; | |
import { CreateUserDTO } from './CreateUserDTO'; | |
import { Either, Result, left, right } from '../../../../core/logic/Result'; | |
import { UserEmail } from '../../domain/userEmail'; |
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
/** | |
* This middleware redirects routes without locale to a prefixed ones. | |
* Useful for links included on email templates. | |
*/ | |
export default function(context) { | |
const { route, redirect, app } = context | |
const { path, query } = route | |
const previousLocaleCode = app.i18n.getLocaleCookie() | |
const localeCodes = app.i18n.locales.map(l => l.code) |
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
= attraction-weight($font-size) | |
&[data-weight="100"] | |
.name | |
span | |
font-size: $font-size * 1 | |
opacity: 1 | |
small | |
&.size-65 | |
font-size: $font-size * .65 |
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
# We can't use dynamic segment for the festivals because ActiveAdmin can't | |
# include it to default_url_options. So all named routes in admin will break. | |
Festival::KEYS.each do |festival_key| | |
scope festival_key do | |
scope ':locale', defaults: {locale: I18n.locale} do | |
devise_for :admin_users, ActiveAdmin::Devise.config | |
ActiveAdmin.routes(self) | |
end | |
end | |
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
#!/usr/bin/env ruby | |
# Snippet to build command line executables like this: | |
# ./my_script command --opt-a "opt A" | |
require 'optparse' | |
require 'singleton' | |
require 'pry' | |
class Command |
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
ARCHETYPE_ROTATION = [ | |
["common_man", "helpful", "idealist", "ruler", | |
"alchemist", "mentor", "hero", "creative", | |
"explorer", "rebel", "seducer", "joker"], | |
["joker", "seducer", "rebel", "explorer", | |
"creative", "hero", "mentor", "alchemist", | |
"ruler", "idealist", "helpful", "common_man"], | |
["mentor", "creative", "joker", "hero", |
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
import Foundation | |
import CoreLocation | |
// Calculate destination location based on origin location, distance (meters) and direction (degrees from north). | |
// Playing: myOriginLocation.destinationBy(distance: 5.0, direction: 45.0) | |
// http://www.geomidpoint.com/destination/calculation.html (Spherical earth model) | |
extension CLLocation { | |
func destinationBy(# distance: CLLocationDistance, direction: CLLocationDirection) -> CLLocation { | |
let earthRadius = 6372.7976 | |
let angularDistance = (distance / 1000) / earthRadius |
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
{ | |
"round": { | |
"questions": [ | |
{"id": 0}, | |
{"id": 1} | |
], | |
"answers": [ | |
{"answer_choice_id": 0, "seconds": 3.872}, | |
{"answer_choice_id": 1, "seconds": 10.09} | |
] |
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
value = | |
if answer.seconds <= 3 | |
Question::BASE_SCORE_VALUE | |
else | |
# Value is proportional to time taken to answer the question. | |
Question::BASE_SCORE_VALUE * (1 - (answer.seconds.to_f / Question::MAX_TIME_TO_ANSWER)) | |
end | |
# Double value if question is bonus | |
value * (answer.question.bonus? ? 2 : 1) |
NewerOlder