Skip to content

Instantly share code, notes, and snippets.

View joel-thompson's full-sized avatar

Joel Thompson joel-thompson

  • CircleCI
  • San Francisco, CA
View GitHub Profile
@joel-thompson
joel-thompson / stackToSpacers.ts
Created April 4, 2025 15:52
calculates react/spacers give a stack delta
/**
* Calculates the required stem spacer changes and resulting reach changes for a bicycle stem adjustment.
* Uses trigonometric relationships in a right triangle formed by:
* - The vertical change (stackDelta) as the opposite side
* - The horizontal change (reachDelta) as the adjacent side
* - The spacer change (spacersDelta) as the hypotenuse
*
* Mathematical relationships used:
* - sin(headAngle) = stackDelta/spacersDelta
* - cos(headAngle) = |reachDelta|/spacersDelta
@joel-thompson
joel-thompson / intercom_custom_attributes.php
Created April 13, 2017 00:11
Intercom PHP custom attribute examples
$client->users->create([
"user_id" => "161661",
"custom_attributes" => [
"my_custom_attribute" => "foo123"
]
]);
$client->companies->create([
"name" => "foocorp", "id" => "135",
"custom_attributes" => [
@joel-thompson
joel-thompson / send_message_and_assign.rb
Last active April 6, 2017 20:10
Ruby code for sending a message in Intercom, grabbing the conversation based on the message_id, then re-assigning that same conversation to a team. could be re-used to do other operations on that conversation
my_user_id = '' # user_id of the person you are sending a message to
my_admin_id = '' # admin_id of the admin sending the message, and doing the re-assign
my_team_id = '' # admin_id of the team you are assigning to
# sends a message
message = intercom.messages.create({
message_type: 'email',
subject: 'Hey there',
body: "What's up :)",
template: "plain", # or "personal",
@joel-thompson
joel-thompson / functions.php
Created October 7, 2016 00:34
functions.php before attributes
<?php
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
function my_theme_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}
?>
@joel-thompson
joel-thompson / functions.php
Last active October 7, 2016 00:36
functions.php and style.css for child themes
<?php
function add_this_script_footer(){ ?>
<script>
// intercomSettings must already be defined at this point
intercomSettings.attribute1 = "value1";
intercomSettings.attribute2 = "value2";
Intercom('update');
</script>