Skip to content

Instantly share code, notes, and snippets.

@mirhampt
mirhampt / conditional-type.ts
Created July 20, 2020 17:12
Typescript Conditional Types with "never"
/**
A (contrived) example of conditional types with `never`.
*/
/** Gets keys that have string values from object T. */
type StringPropertyNames<T> = {
[K in keyof T]: T[K] extends string ? K : never;
}[keyof T];
/**
@mirhampt
mirhampt / recaptcha.coffee
Created October 5, 2010 00:40
Verify a recaptcha using CoffeeScript and node.js. This is not bulletproof, but it is a start.
# Send a request to recaptcha to verify the user's input.
#
# The first argument must be an object containing four parts:
# privatekey: Your recaptcha private key.
# remoteip: The IP of the user who submitted the form.
# challenge: The challenge value from the recaptcha form.
# response: The user's response to the captcha.
#
# Example usage (express):
#