Skip to content

Instantly share code, notes, and snippets.

View drmzio's full-sized avatar

Daniel Ramirez drmzio

View GitHub Profile
@drmzio
drmzio / schema.json
Created March 30, 2023 00:09 — forked from dvdsgl/schema.json
Figma Platform schema
{
"$ref": "#/definitions/FileResponse",
"$schema": "http://json-schema.org/draft-06/schema#",
"definitions": {
"BlendMode": {
"enum": [
"COLOR",
"COLOR_BURN",
"COLOR_DODGE",
"DARKEN",
<script type="text/javascript">
window.$widget = window.$widget || {};
window.WIDGET_SITE_ID = 'xxx-xxx-xxx-xxx';
(function(w, d) {
var s = d.createElement('script');
s.defer = true;
s.src = '//www.widgetscripts.com/embed.js';
d.getElementsByTagName('head')[0].appendChild(s);
})(window, document);
</script>
@drmzio
drmzio / tsconfig.json
Created November 16, 2021 00:01
Next.js TypeScript config
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
@drmzio
drmzio / states_hash.json
Created August 11, 2021 18:54 — forked from mshafrir/states_hash.json
US states in JSON form
{
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",
@drmzio
drmzio / toFloatString.js
Created August 5, 2021 18:40
Stripe convert amount to float
/**
* Converts Stripe amounts like 25000 to the currency amount like "250.00" in string format.
* @param amount - A stripe whole number amount.
* @return string
*/
export const toFloatString = (amount) => {
const total = (amount / 100)
.toLocaleString('en-US', { style: 'currency', currency: 'usd' })
.replace('$', '');
@drmzio
drmzio / getPages.js
Last active July 12, 2021 22:04
Get list of all pages using require.context
export const getPages = () => {
const ctx = require.context('./', true, /\.js$/);
return ctx
.keys()
.filter(page => !page.startsWith('./_')) // Filters out _app.js and _document.js
.map(page => {
page = page
.replace(/(\/index)?\.js$/i, '') // Removes the index.js files
.replace(/\.(\/)?/i, '/'); // Normalize the homepage directory to "/"
.sr-only {
clip: rect(1px, 1px, 1px, 1px);
clip-path: inset(50%);
height: 1px;
width: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
}
@drmzio
drmzio / ID.js
Created April 5, 2019 22:39
ID - a unique ID/name generator for JavaScript
// Generate unique IDs for use as pseudo-private/protected names.
// Similar in concept to
// <http://wiki.ecmascript.org/doku.php?id=strawman:names>.
//
// The goals of this function are twofold:
//
// * Provide a way to generate a string guaranteed to be unique when compared
// to other strings generated by this function.
// * Make the string complex enough that it is highly unlikely to be
// accidentally duplicated by hand (this is key if you're using `ID`
@drmzio
drmzio / .env.example
Created February 25, 2019 20:35 — forked from LukeTowers/.0 - cheatsheet.sh
Introduction to OctoberCMS
APP_DEBUG=true
APP_URL=http://example.local
APP_KEY=
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=website-oc-example-LOCAL
DB_USERNAME=homestead
DB_PASSWORD=secret
@drmzio
drmzio / Plugin.php
Last active February 13, 2022 09:47
October CMS RainLab.Blog media manager plugin extension
<?php
namespace Acme\BlogBanner;
use System\Classes\PluginBase;
use Event;
/**
* Class Plugin
*