layout | title |
---|---|
post |
Blogging Like a Hacker |
A large collection of code samples which have been tested against GitHub's markdown parser... so you don't have to.
/** | |
* Truncate a list of names at return a human friendly sentence fragment. | |
* @param {string[]} list A list of name strings to format | |
* @param {number} max The maximum number of names to show before appending a count | |
* @example | |
* // returns "Abi, Jeri and Zoi" | |
* truncate(["Abi, Jeri, Zoi"]) | |
* @example | |
* // Returns "Abi and 2 others" | |
* truncate(["Abi, Jeri, Zoi"], 1) |
<?xml version="1.0" encoding="UTF-8"?> | |
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> | |
<sitemap> | |
<loc>hhttps://gretel.ai/sitemap.xml</loc> | |
</sitemap> | |
<sitemap> | |
<loc>https://docs.gretel.ai/sitemap.xml</loc> | |
</sitemap> | |
<sitemap> | |
<loc>https://docs.gretel.ai/sitemap.xml</loc> |
import perlin from "https://cdn.jsdelivr.net/npm/[email protected]/index.min.js" | |
(() => { | |
// node_modules/@georgedoescode/generative-utils/src/spline.js | |
function formatPoints(points, close) { | |
points = [...points]; | |
if (!Array.isArray(points[0])) { | |
points = points.map(({ x, y }) => [x, y]); | |
} | |
if (close) { | |
const lastPoint = points[points.length - 1]; |
from gretel_client import get_cloud_client | |
client = get_cloud_client('api', 'your_api_key') | |
project = client.get_project(name='your_project_name') | |
stream = project.iter_records(entity_stream="location") |
from gretel_client import get_cloud_client | |
client = get_cloud_client('api', 'your_api_key') | |
project = client.get_project(name='your_project_name') | |
project.send({'message':'Hello Gretel!'}) |
export const keysToQueryString = (keys) => ( | |
encodeURI(Object.keys(keys).reduce((string, key, index) => ( | |
`${string}${!index?'?':'&'}${key}=${keys[key]}` | |
), '')) | |
); |
// let value = Modulate(1, from: [0, 10], to: [0, 20], true); | |
// print(value); | |
// Returns 2 | |
func Modulate(_ input: Float, from: [Float], to: [Float], limit: Bool) -> Float { | |
let result = to[0] + (((input - from[0]) / (from[1] - from[0])) * (to[1] - to[0])); | |
if (limit) { | |
if (to[0] < to[1]) { | |
if (result < to[0]) { return to[0] } |
colors = ["#f23f3f", "#ff7f3b", "#f2c83f", "#3ac95c", "#4a95ff", "#ac59ff", "#ff8aed", "#3bbdca"] | |
fetti_bag = [] | |
exports.kaboom = () -> | |
unless fetti_bag.length > 1 | |
for i in [0..100] | |
fetti = new Layer | |
width: 20, height: 20 | |
scale: Utils.randomNumber(0.75, 1.25) |