Skip to content

Instantly share code, notes, and snippets.

View davidkaneda's full-sized avatar

David Kaneda davidkaneda

View GitHub Profile
davidkaneda / users-by-cost.ts
Last active December 29, 2022 03:40
Mongo aggregate command that calculates total cost on openai calls from all user’s suggestions, based on the model being used, as well as the total number of words generated, then sorts by cost.
View users-by-cost.ts
await AiSuggestion.aggregate([
$group: {
_id: "$user",
models: {
$push: {
model: "$request.model",
totalTokens: { $sum: "$response.usage.total_tokens" },
title: Press release
label: Company name
required: true
label: Announcement summary
required: true
helperText: Brief notes are fine
davidkaneda / noise.js
Created April 1, 2012 21:56
Noise in Canvas + JS
View noise.js
var canvas = document.getElementById("acanvas");
var w = canvas.width = 200;
var h = canvas.height = 200;
var context = canvas.getContext("2d");
for(i=0;i<w;i++) {
for(j=0;j<h;j++) {
var num = Math.floor(Math.random()*255);
davidkaneda / _user-select.scss
Created March 3, 2012 21:05
User select mixin
View _user-select.scss
@mixin user-select($select) {
$select: unquote($select);
@include experimental(user-select, $select,
-moz, -webkit, not -o, not -ms, -khtml, official
davidkaneda / color-overlay.scss
Created February 20, 2012 20:59 — forked from nimbupani/color-overlay.scss
Sass Snippets
View color-overlay.scss
// Use @include colorize('image.png', red, 0.5)
@mixin colorize($image, $color, $opacity) {
background: $color;
$color: transparentize($color, 1 - $opacity);
background: -webkit-linear-gradient(left, $color, $color), url($image);
background: -moz-linear-gradient(left, $color, $color), url($image);
background: -ms-linear-gradient(left, $color, $color), url($image);
background: -o-linear-gradient(left, $color, $color), url($image);
View book.scss
&.bg-blueprint-grid {
@include background-blueprint-grid(
$width: 50px, $width-alt: 5px
&.bg-noise {
@include background-noise(
$opacity: 1
View _toolbar.scss
@import '../global';
$global_row_height: 2.5em;
$toolbar_spacing: .2em;
$default_toolbar_gradient: 'matte';
@mixin sencha-toolbar {
.x-toolbar {
height: $global_row_height;