Skip to content

Instantly share code, notes, and snippets.

View zaidaldabbagh's full-sized avatar

Zaid Al-Dabbagh zaidaldabbagh

View GitHub Profile
@zaidaldabbagh
zaidaldabbagh / SilverStripe 3 on Heroku
Last active March 13, 2021 20:09 — forked from camfindlay/SilverStripe on Heroku
SilverStripe database setup on Heroku.
mysite/_config.php
<?php
// . . . config above
//Heroku ClearDB support
if(isset($_ENV['CLEARDB_DATABASE_URL'])) {
global $databaseConfig;
$parts = parse_url($_ENV['CLEARDB_DATABASE_URL']);
$databaseConfig['type'] = 'MySQLDatabase';
$databaseConfig['server'] = $parts['host'];
$databaseConfig['username'] = $parts['user'];
@zaidaldabbagh
zaidaldabbagh / drupal_8_theme.theme
Last active March 10, 2021 00:18
Drupal 8 - Menu preprocess hook to fetch linked nodes and access thumbnail field values
use Drupal\node\Entity\Node;
function ncea_preprocess_menu(&$vars, $hook) {
// Subjects Nav
if ($hook == 'menu__subjects') {
foreach ($vars['items'] as $key => $item) {
if ($vars['items'][$key]['below']) {
foreach ($vars['items'][$key]['below'] as $learningAreaKey => $learningAreaItem) {
$learningAreaUrl = $learningAreaItem['url'];
@zaidaldabbagh
zaidaldabbagh / hide-scrollbar-mixin.scss
Last active June 13, 2019 01:00
Sass mixin to hide scrollbar in Chrome, Firefox, Safari and IE.
@mixin hideScrollbar {
// https://blogs.msdn.microsoft.com/kurlak/2013/11/03/hiding-vertical-scrollbars-with-pure-css-in-chrome-ie-6-firefox-opera-and-safari/
// There is a CSS rule that can hide scrollbars in Webkit-based browsers (Chrome and Safari).
&::-webkit-scrollbar {
width: 0 !important
}
// There is a CSS rule that can hide scrollbars in IE 10+.
-ms-overflow-style: none;
// Use -ms-autohiding-scrollbar if you wish to display on hover.
// add overflowing text indicator for cards with longer texts
var win2dOptionValues = document.getElementsByClassName('win2dOption-value');
for (var i=0; i < win2dOptionValues.length; i++) {
var curOverflow = win2dOptionValues[i].style.overflow;
var isOverflowing = win2dOptionValues[i].clientWidth < win2dOptionValues[i].scrollWidth ||
win2dOptionValues[i].clientHeight < win2dOptionValues[i].scrollHeight;
if (isOverflowing) {
win2dOptionValues[i].className += " win2dOption-value--overflowing";
win2dOptionValues[i].style.overflowy = "scroll";
@zaidaldabbagh
zaidaldabbagh / mysite.yml
Created April 24, 2019 04:51
Allow JSON uploads in SilverStripe CMS
SilverStripe\MimeValidator\MimeUploadValidator:
MimeTypes:
'json': 'text/plain'
@zaidaldabbagh
zaidaldabbagh / addScrollAnimation.js
Last active February 8, 2019 00:23
Add scroll animation to anchor links on a page
import React from 'react';
import { render } from 'react-dom';
import { BrowserRouter as Router, Route } from 'react-router-dom';
import { createBrowserHistory } from 'history';
const addScrollAnimation = () => {
const anchorLinks = document.querySelectorAll('[href*="#"]');
anchorLinks.forEach((anchorLink) => {
anchorLink.addEventListener('click', (e) => {
const href = e.target.getAttribute('href');
@zaidaldabbagh
zaidaldabbagh / initVanillaTilt.js
Created January 15, 2019 20:13
Initializing VanillaTilt
import VanillaTilt from 'vanilla-tilt';
...
const initTilt = () => {
// init tilt
VanillaTilt.init(document.querySelector(".card"), {
max: 25,
speed: 400
});
function camelCaseToSentenceCase(word) {
const result = word.replace(/([A-Z])/g, ' $1');
const finalResult = result.charAt(0).toUpperCase() + result.slice(1);
return (
<span>{finalResult}</span>
);
}
@zaidaldabbagh
zaidaldabbagh / checkboxFilter.html
Last active December 4, 2018 00:10
Checkbox Styling with Minimal CSS — See https://codepen.io/zaidaldabbagh/pen/pQBNEo
<div class="filter">
<label class="filter__item">
<input type="checkbox" id="chkStatDraft" checked="" value="DRAFT">
<span>Draft</span>
</label>
<label class="filter__item">
<input type="checkbox" id="chkStatWD" value="WITHDRAWN">
<span>Withdrawn</span>
</label>
<label class="filter__item">
@zaidaldabbagh
zaidaldabbagh / package-example.json
Last active November 13, 2018 20:32
Example package.json for webpack setup — See zaidaldabbagh.com/blog/webpack-setup
{
"name": "mpi",
"version": "1.0.0",
"description": "Ministry for Primary Industries (MPI) website.",
"main": "index.js",
"dependencies": {
"bootstrap": "^3.1.1",
"include-media": "^1.4.9",
"infinite-scroll": "^3.0.5",
"moment": "^2.22.2",