- About me
- The world's fastest explanation of refactoring
- Some examples of refactoring from real-life applications
- Hairier examples of refactoring from real-life applications
- My refactoring algorithm
- Open mic
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 MyApp.Application do | |
use Application | |
def start(_type, _args) do | |
children = [ | |
Supervisor.Spec.worker(Producer, []), | |
Supervisor.Spec.worker(Consumer, [], id: 1) | |
] | |
opts = [strategy: :one_for_one, name: Stages.Supervisor] |
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
source: http://www.markbrilman.nl/2011/08/howto-convert-a-pfx-to-a-seperate-key-crt-file/ | |
`openssl pkcs12 -in [yourfile.pfx] -nocerts -out [keyfile-encrypted.key]` | |
What this command does is extract the private key from the .pfx file. Once entered you need to type in the importpassword of the .pfx file. This is the password that you used to protect your keypair when you created your .pfx file. If you cannot remember it anymore you can just throw your .pfx file away, cause you won’t be able to import it again, anywhere!. Once you entered the import password OpenSSL requests you to type in another password, twice!. This new password will protect your .key file. | |
Now let’s extract the certificate: | |
`openssl pkcs12 -in [yourfile.pfx] -clcerts -nokeys -out [certificate.crt]` |
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
const express = require('express'); | |
const proxy = require('express-http-proxy'); | |
const cors = require('cors'); | |
const app = express(); | |
app.use(cors()); | |
app.use('/', proxy('http://target-server.com')); | |
app.listen(3005); |
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
:set prompt "\ESC[1;36mλ> \ESC[m" |
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 bash | |
function get_events() { | |
echo "Fetching logs for $1 lambda in the $2 region (since $3)..." | |
aws logs filter-log-events --log-group-name "/aws/lambda/$1" --region "$2" --start-time "$3" --filter-pattern requestId | jq '.events' | |
} | |
case $1 in | |
"all") | |
get_events $2 ${3:-us-west-2} ${4:-1496030995836} | |
;; |
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
resource "aws_api_gateway_rest_api" "myApi" { | |
name = "myApi-${var.env}" | |
description = "My awesome API (${var.env} environment)" | |
} | |
resource "aws_api_gateway_deployment" "myApi" { | |
depends_on = [ | |
"aws_api_gateway_integration.myApi_myEndpoint_post", | |
"aws_api_gateway_integration_response.myApi_myEndpoint_post", | |
"aws_api_gateway_integration_response.myApi_myEndpoint_post_400", |
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
SELECT | |
t.tablename, | |
indexname, | |
c.reltuples AS num_rows, | |
pg_size_pretty(pg_relation_size(quote_ident(t.tablename)::text)) AS table_size, | |
pg_size_pretty(pg_relation_size(quote_ident(indexrelname)::text)) AS index_size, | |
CASE WHEN indisunique THEN 'Y' | |
ELSE 'N' | |
END AS UNIQUE, | |
idx_scan AS number_of_scans, |
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
chunk_size = 50_000 | |
lists = | |
Enum.map(0..19, fn x -> | |
range_start = x * chunk_size | |
range_end = range_start + chunk_size | |
Enum.map(range_start..range_end, fn y -> %{data: %{title: "#{y} is love, #{y} is life"}} end) | |
end) | |
Enum.each(lists, fn list -> Repo.insert_all(Meme, list) end) |
NewerOlder