Skip to content

Instantly share code, notes, and snippets.

@shadcn
shadcn / gist:de147c42d7b3063ef7bc
Last active September 17, 2022 11:50
Convert a Hex string to UIColor in Swift
// Creates a UIColor from a Hex string.
func colorWithHexString (hex:String) -> UIColor {
var cString:String = hex.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet()).uppercaseString
if (cString.hasPrefix("#")) {
cString = cString.substringFromIndex(1)
}
if (countElements(cString) != 6) {
return UIColor.grayColor()
@shadcn
shadcn / README.md
Created June 8, 2022 06:29
next-drupal: how to run the marketing example.

Get the code

git clone https://github.com/chapter-three/next-drupal

Get the database

The database is not publicly available in the repo. You can ping @shadcn. I'll send you a copy.

@shadcn
shadcn / gist:cde26afc528a7bc7ae8d68ce658a8f2d
Created April 21, 2016 20:22
field_info_instance or how to get field info in Drupal 8
<?php
use Drupal\field\Entity\FieldConfig;
$info = FieldConfig::loadByName($entity_type, $bundle, $field_name);
@shadcn
shadcn / glob-for-radix.md
Created November 12, 2019 08:42
Glob for Radix

Step 1: Add import-glob-loader:

$ npm i import-glob-loader -D

Step 3: Update webpack config:

/*
 |--------------------------------------------------------------------------
 | Configuration
@shadcn
shadcn / custom-theme.js
Created October 29, 2020 09:30
Custom theme for Reflex
import { merge } from "theme-ui"
import base from "@reflexjs/preset-base"
export default merge(base, {
colors: {
text: "#000",
background: "#fff",
primary: "#2a9d8f",
secondary: "#e76f51",
},
@shadcn
shadcn / PurchasedPlanListBuilder.php
Created May 12, 2020 18:25
How to override the PurchasedPlanListBuilder for Apigee M10n
<?php
// Place in `custom_module/src/Entity/ListBuilder/PurchasedPlanListBuilder.php`
namespace Drupal\custom_module\Entity\ListBuilder;
use Drupal\apigee_m10n\Entity\ListBuilder\PurchasedPlanListBuilder as ApigeePurchasedPlanListBuilder;
class PurchasedPlanListBuilder extends ApigeePurchasedPlanListBuilder {

Add podcast to your site

This recipe adds podcast support to your Gatsby site using @arshad/gatsby-theme-podcast-core.


Install NPM packages

<NPMPackage name="@arshad/gatsby-theme-podcast-core"

import React from "react"
import { Link } from "gatsby"
import Image from "gatsby-image"
import Layout from "../../../components/layout"
import SEO from "../../../components/seo"
export const formatDuration = seconds => {
const minutes = Math.floor(seconds / 60)
const hours = Math.floor(seconds / (60 * 60))
@shadcn
shadcn / SerializerWithPager.php
Created December 20, 2016 06:53
A views Serializer plugin for Drupal 8 with pager
<?php
namespace Drupal\MODULE_NAME\Plugin\views\style;
use Drupal\rest\Plugin\views\style\Serializer;
/**
* The style plugin for serialized output formats with pager.
*
* @ingroup views_style_plugins
@shadcn
shadcn / create_menu_link.php
Last active September 10, 2018 09:33
Programmatically create a menu link in Drupal 8