Skip to content

Instantly share code, notes, and snippets.

@drifterz13
drifterz13 / openai-assistant-node.ts
Last active April 15, 2024 13:09
Node.js + OpenAI assistant example
require('dotenv').config()
import OpenAI from 'openai'
import fs from 'fs'
import path from 'path'
import { MessageContentText } from 'openai/resources/beta/threads/messages/messages'
const openai = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
})
@zorrodg
zorrodg / LICENSE
Last active November 30, 2023 19:37
CLI Integration Test Helper
MIT License
Copyright © 2019 Andrés Zorro
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@chrisnolet
chrisnolet / .bash_profile
Last active September 27, 2022 13:37 — forked from henrik/.bashrc
Color-coded git branch for bash prompt
git_branch() {
local branch=$(git --no-optional-locks branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/^* (*\([^)]*\))*/\1/')
if [[ -n $branch ]]; then
if [[ -z $(git --no-optional-locks status --porcelain 2> /dev/null) ]]; then
echo -e " \001\033[32m\002($branch)\001\033[0m\002"
else
echo -e " \001\033[31m\002($branch)\001\033[0m\002"
fi
fi
@nirvanatikku
nirvanatikku / css_inline_transformer.js
Created December 2, 2016 23:19
JavaScript CSS Inline Style Transformer (convert CSS + HTML into HTML with inline styles)
/**
* CSS Inline Transform v0.1
* http://tikku.com/css-inline-transformer-simplified
*
* Copyright 2010-2012, Nirvana Tikku
* Dual licensed under the MIT or GPL Version 2 licenses.
* https://github.com/jquery/jquery/blob/master/MIT-LICENSE.txt
*
* This tool leverages the jQuery library.
*
@cgmartin
cgmartin / logging-middleware.js
Created May 24, 2015 01:43
Morgan JSON log format example
'use strict';
var morgan = require('morgan');
var os = require('os');
morgan.token('conversation-id', function getConversationId(req) {
return req.conversationId;
});
morgan.token('session-id', function getSessionId(req) {
return req.sessionId;
@MarZab
MarZab / ngrams.js
Created April 13, 2015 09:08
JavaScript Implementation of N-Gram Text Categorisation based on paper by William B. Cavnar and John M. Trenkle
'use strict';
/*
N-Gram-Based Text Categorisation
Implementation by marko@zabreznik.net
28.3.2015 All rights reserved.
Based on the paper by:
William B. Cavnar and John M. Trenkle
Environmental Research Institute of Michigan
@jshbrntt
jshbrntt / pan-zoom-image.js
Last active October 16, 2018 11:10
A simple way of panning and zooming an image using Hammer.js.
// <img id="myimage" src="http://placecage/1280/720">
var image = document.getElementById('myimage');
var mc = new Hammer.Manager(image);
var pinch = new Hammer.Pinch();
var pan = new Hammer.Pan();
pinch.recognizeWith(pan);
@rmehner
rmehner / delete-databases.js
Last active April 4, 2024 09:18
Delete all indexedDB databases
// Credit to @steobrien from https://gist.github.com/rmehner/b9a41d9f659c9b1c3340#gistcomment-2940034
// for modern browsers, this works:
const dbs = await window.indexedDB.databases()
dbs.forEach(db => { window.indexedDB.deleteDatabase(db.name) })
// for older browsers, have a look at previous revisions of this gist.
@rxaviers
rxaviers / gist:7360908
Last active April 26, 2024 03:51
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@iwek
iwek / csv-to-json.js
Last active April 24, 2024 19:05
CSV to JSON Conversion in JavaScript
//var csv is the CSV file with headers
function csvJSON(csv){
var lines=csv.split("\n");
var result = [];
var headers=lines[0].split(",");
for(var i=1;i<lines.length;i++){