This file contains hidden or 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
| with report_card_fields as ( | |
| select | |
| id as report_card_id, | |
| (regexp_matches(dataset_query, '"field",(\d+)', 'g'))[1]::int as field_id | |
| from report_card | |
| ) | |
| select | |
| rc.name as question_name, | |
| mt.name as table_name, | |
| mf.name as field_name |
This file contains hidden or 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 fs = require("fs"); | |
| const rawData = fs.readFileSync("plan.json"); | |
| const data = JSON.parse(rawData); | |
| const changes = data.resource_changes.filter( | |
| (c) => | |
| c.change.actions.indexOf("create") !== -1 && | |
| c.type.startsWith("aws_s3_bucket_") |
This file contains hidden or 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 fs = require('fs') | |
| const urlLib = require('url') | |
| function domainsFromHar(filePath) { | |
| const rawData = fs.readFileSync(filePath) | |
| const json = rawData && JSON.parse(rawData) | |
| const { log } = json || {} | |
| if (!log) return | |
| const { pages, entries } = log |
This file contains hidden or 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 django.db.models import Func, F, Value | |
| from images.models import Image | |
| Image.objects.all().update(original_filename=Func(F('file'), Value('^.*\/(.*)$'), Value('\\1'), function='regexp_replace')) |
This file contains hidden or 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 rest_framework.request import Request | |
| class RequestMaybeInitializedMixin(object): | |
| def initialize_request(self, request, *args, **kwargs): | |
| drf_request = super( | |
| RequestMaybeInitializedMixin, self).initialize_request( | |
| request, *args, **kwargs) |
This file contains hidden or 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
| function processServerError(error, fields) { | |
| const fieldErrors = {}; | |
| let otherErrors = []; | |
| if (typeof error === 'object') { | |
| for (const field of fields) { | |
| const value = error[field]; | |
| if (value) { | |
| if (value.constructor === {}.constructor) { | |
| Object.keys(value).forEach(key => { | |
| fieldErrors[`${field}.${key}`] = value[key]; |
This file contains hidden or 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 rest_framework import serializers | |
| from django.contrib.auth import password_validation | |
| class PasswordField(serializers.CharField): | |
| def __init__(self, *args, **kwargs): | |
| kwargs['write_only'] = True | |
| kwargs['style'] = {'input_type': 'password'} | |
| self.validate_password = kwargs.pop('validate_password', True) |