Skip to content

Instantly share code, notes, and snippets.

@pandauxstudio
pandauxstudio / hide-scrollbar-mixin.scss
Last active December 21, 2022 15:31
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.
function camelCaseToSentenceCase(word) {
const result = word.replace(/([A-Z])/g, ' $1');
const finalResult = result.charAt(0).toUpperCase() + result.slice(1);
return (
<span>{finalResult}</span>
);
}
@pandauxstudio
pandauxstudio / addScrollAnimation.js
Created May 15, 2019 16:21
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');
// 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";
@pandauxstudio
pandauxstudio / mysite.yml
Created April 24, 2019 04:50
Allow JSON file uploads in SilverStripe CMS
SilverStripe\MimeValidator\MimeUploadValidator:
MimeTypes:
'json': 'text/plain'
@pandauxstudio
pandauxstudio / mysite.yml
Created April 24, 2019 04:48
Allow JSON file uploads in SilverStripe CMS
SilverStripe\MimeValidator\MimeUploadValidator:
MimeTypes:
'json': 'text/plain'
# obtained from https://stackoverflow.com/questions/8439650/how-to-drop-all-tables-in-a-sql-server-database
DECLARE @Sql NVARCHAR(500) DECLARE @Cursor CURSOR
SET @Cursor = CURSOR FAST_FORWARD FOR
SELECT DISTINCT sql = 'ALTER TABLE [' + tc2.TABLE_NAME + '] DROP [' + rc1.CONSTRAINT_NAME + ']'
FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc1
LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc2 ON tc2.CONSTRAINT_NAME =rc1.CONSTRAINT_NAME
OPEN @Cursor FETCH NEXT FROM @Cursor INTO @Sql
/**
* convertCharactersToHtml
* =======================
* Converts HTML characters to HTML elements, such as replacing greater-than sign ">" with "&gt;".
* @param string mixedString String with special characters.
* @return string HTML elements.
*/
function convertCharactersToHtml($mixedString) {
return htmlspecialchars($mixedString);
}
/**
* getComponentSCSS
* ================
* Return corresponding sass code for specific component.
*
* @param $filePath Source SCSS file.
* @return SCSS
*/
function getComponentSCSS() {
@pandauxstudio
pandauxstudio / Lodash _.pick
Created July 12, 2017 05:38
Eliminate certain properties within an array of objects
// source: https://jsfiddle.net/pandauxstudio/k1nq92sk/8/
// create dummy awards object array.
const awards = [
{
awardNumber: "1",
awardStatus: "CURRENT",
awardType: "CERT",
awardVersionNumber: 1,
caseId: "C11111"
},