Skip to content

Instantly share code, notes, and snippets.

@guillegette
guillegette / gist:da63d24880334518af3d
Last active August 29, 2015 14:18
Improved set function
/**
* Original
* Set name of the the item
*
* @param string $name
*/
public function setName($name = "")
{
if (empty($name)) {
throw new \Exception("Item name can't be empty");
SCRIPT7002: XMLHttpRequest: Network Error 0x2ef3, Could not complete the operation due to error 00002ef3.
@guillegette
guillegette / parse-dates.js
Last active May 7, 2017 12:09
Parse dates in natural language for Slack Message Menus
/* Example payload
{
name: 'set_due_date',
value: '',
callback_id: 'new_task_message',
team: { id: 'TXXXXXXXX', domain: 'gette' },
channel: { id: 'CXXXXXXXX', name: 'work' },
user: { id: 'UXXXXXXXX', name: 'guillegette' },
action_ts: '1494154614.757129',
message_ts: '1494138801.457727',
{
"id": "5d372c84d96093007b1e4e0c",
"custom": true,
"name": "Pending Taks",
"payload": {
"sort": [],
"limit": 100,
"expand": [
"createdBy",
"assignedTo",
@guillegette
guillegette / task_completed.json
Created December 15, 2021 16:33
Outgoing webhooks event sample
{
"id": "61b8e1be1406c410721345d2",
"type": "task_completed",
"createdAt": "2021-12-14T18:26:06.341Z",
"updatePatch": {
"status": "done",
"doneAt": "2021-12-14T18:26:06.304Z",
"doneBy": "4e2a196930fc8294cbc14fc239b012ba",
"removedBy": null,
"removedAt": null
// TokenID: Supply
const stickers = {
'1012': 10,
'1013': 11,
'1014': 9,
'1015': 20,
'1016': 15,
'1017': 5,
'1018': 10,
'1019': 17,
@guillegette
guillegette / callback.js
Last active August 3, 2022 06:40
Implementing Slack Oauth 2.0 for www.workat.com
const loginCallback = async (req, res, next) => {
const redirectUri = 'https://...'; // would be the URL defined above
const slackClient = await getSlackOpenIdClient(redirectUri);
const { slackLoginVerifyCode } = req.session;
const tokenSet = await slackClient.callback(
redirectUri,
req.query,
{ code_verifier: slackLoginVerifyCode }
);
<html>
<head>
<title>Welcome to Workast</title>
<meta charset="utf-8">
<meta name="description" content="Welcome to Workast">
<meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
<link rel="icon" type="image/png" href="https://cdn.workast.io/prod/images/favicon.png">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
@guillegette
guillegette / README.md
Created March 8, 2023 11:36
Creating prompts

How to write prompts

A guide on how to write and format your prompts

The basics

When you build the form for your application, each form question has an "Identifier". This is a unique value given to the question so you can later reference it in your prompt. THe identifier can be any string or number of any length, but make sure is unique to the rest of the form questions.

Once you have established your form questions, you can then write your prompt. While you are writing your prompt, you will probably want to incorporate in the text the response that a user give to a specific question. To do this, you simply write {{identifier}}. For example, a prompt to get blog articles for a product: "Return a list of blog post ideas for a product named {{product}}", where "product" is the identifier I gave to the form question.

import React, {
forwardRef, useEffect, useImperativeHandle, useState,
} from 'react'
import { useEditor, EditorContent, Editor } from '@tiptap/react';
import Mention from '@tiptap/extension-mention';
import StarterKit from '@tiptap/starter-kit'
import { ReactRenderer } from '@tiptap/react'
import tippy from 'tippy.js'
import { Marked } from 'marked';
import TurndownService from 'turndown';