Skip to content

Instantly share code, notes, and snippets.

View johnhok's full-sized avatar

Johnathan Hok johnhok

View GitHub Profile
@johnhok
johnhok / README.md
Created January 13, 2021 17:31 — forked from donaldpipowitch/README.md
Handle server errors in Formik

Whenever the server returns validation errors and we would set them with setFieldError they would be lost if any field would get a change or blur event. But we want to keep these kind of errors until the specific field changes. Additional we want to handle generic server errors (which are not specific to a field, but the whole form).

With these hooks field specific server side errors should be added like this:

const { setStatus } = useFormikContext();

const errors = {};
// adjust serverErrors to your own responses
// in this case they look like this: Array<{ name: string, error: string }>
#!/usr/bin/env ruby
if ARGV.include?("-h") || ARGV.include?("--help")
puts "USAGE: check.rb [HOSTNAME] [TLS_VERSION] [VERIFY]"
puts " default: check.rb rubygems.org auto VERIFY_PEER"
puts " example: check.rb github.com TLSv1_2 VERIFY_NONE"
exit 0
end
host = ARGV.shift || "rubygems.org"
@johnhok
johnhok / gist:1197759
Created September 6, 2011 14:51
Caching file uploads on S3 using knox for node.js
var knox = require('knox');
var s3client = knox.createClient({
key: 'KEY GOES HERE',
secret: 'SECRET GOES HERE',
bucket: 'BUCKET NAME GOES HERE'
});
var fileHeaders = {
'Cache-Control': 'public,max-age=290304000'
};