Skip to content

Instantly share code, notes, and snippets.

@MendyLanda
MendyLanda / drizzle-ulid.md
Created November 5, 2023 13:29
Implementing Efficient Binary ULID Storage in MySQL with Drizzle ORM

For anyone considering the use of ULIDs in MySQL with drizzle, here's a ready-to-use ULID type for your convenience.

import { Ulid as ULID } from "id128";

export const ulid = customType<{
  data: string;
  notNull: true;
  default: false;
@colemanw
colemanw / font-awesome-mime-type-icons.php
Last active March 11, 2024 04:21 — forked from guedressel/font-awesome-mime-type-icons.php
Font Awesome File Icons: Mapping MIME Types to correct icon classes
<?php
/**
* Get font awesome file icon class for specific MIME Type
* @see https://gist.github.com/guedressel/0daa170c0fde65ce5551
*
*/
function ($mime_type) {
// List of official MIME Types: http://www.iana.org/assignments/media-types/media-types.xhtml
$icon_classes = array(
@mjackson
mjackson / color-conversion-algorithms.js
Last active April 14, 2024 08:46
RGB, HSV, and HSL color conversion algorithms in JavaScript
/**
* Converts an RGB color value to HSL. Conversion formula
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
* Assumes r, g, and b are contained in the set [0, 255] and
* returns h, s, and l in the set [0, 1].
*
* @param Number r The red color value
* @param Number g The green color value
* @param Number b The blue color value
* @return Array The HSL representation
@creationix
creationix / hidepatch.js
Created March 20, 2013 16:24
Idea to make private properties and methods non-enumerable instead of prefixing them with underscores (in ES5 and above environments of course)
Object.defineProperty(Object.prototype, "hide", {
value: function () {
[].forEach.call(arguments, function (name) {
var descriptor = Object.getOwnPropertyDescriptor(this, name);
if (descriptor.enumerable) {
descriptor.enumerable = false;
Object.defineProperty(this, name, descriptor);
}
}, this);
}

Node.js Resources

What is node.js?

Node.js is just JavaScript running on the server side. That's it. That's all there is to it.

Express

  • Express Docs, if you want to get started and already know JavaScript this is the place to be
@max-mapper
max-mapper / readme.md
Last active October 12, 2015 10:17
introduction to node
@peterjmit
peterjmit / benchmark.sh
Created October 10, 2012 10:49
Bash Benchmark Script (using time)
#!/bin/bash
# REQUIRES SUDO
# Benchmark runner
repeats=20
output_file='benchmark_results.csv'
command_to_run='echo 1'
run_tests() {
# --------------------------------------------------------------------------
@tnydwrds
tnydwrds / jquery_transport.js
Created October 14, 2011 15:51
Quick jQuery Transport sample
// This is currently just a proof of concept. My OAuth usage requires setting
// a cookie client-side (server does not do this) after successful authentication.
// AIR runtime does not allow XHR to set cookie header so I had to use AIR's
// URLRequest object.
//
// I imagine you can do the same thing but use jsOAuth.request or something in
// place of URLRequest
//
// http://api.jquery.com/extending-ajax/#Transports
@tvandervossen
tvandervossen / gist:1231476
Created September 21, 2011 07:33
Mobile Safari viewport sizes on iOS 4.3 and 5
iPad
1024 × 690 In landscape on iOS 4.3
1024 × 672 In landscape on iOS 5
768 × 946 In portrait on iOS 4.3
768 × 928 In portrait on iOS 5
1024 × 660 Always showing bookmarks bar in landscape on iOS 4.3
1024 × 644 Always showing bookmarks bar in landscape on iOS 5
768 × 916 Always showing bookmarks bar in portrait on iOS 4.3
@subzey
subzey / LICENSE.txt
Created June 5, 2011 08:07 — forked from bytespider/LICENSE.txt
140byt.es -- encodeURIComponent based convert string to array of UTF-8 bytes
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE