Skip to content

Instantly share code, notes, and snippets.

@pandauxstudio
pandauxstudio / gist:1d96c9833c96314055f4ee35d31d8f71
Created March 17, 2017 23:32
.htaccess URL Redirect only if base is requested
RewriteEngine on
RewriteRule ^$ http://pandaux.co/ [R=301,L]
module.exports = function(grunt) {
// https://www.sitepoint.com/writing-awesome-build-script-grunt/
// http://paislee.io/testing-angularjs-with-grunt-karma-and-jasmine/
grunt.loadNpmTasks('grunt-karma');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
clean: {
@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"
},
/**
* getComponentSCSS
* ================
* Return corresponding sass code for specific component.
*
* @param $filePath Source SCSS file.
* @return SCSS
*/
function getComponentSCSS() {
/**
* convertCharactersToHtml
* =======================
* Converts HTML characters to HTML elements, such as replacing greater-than sign ">" with ">".
* @param string mixedString String with special characters.
* @return string HTML elements.
*/
function convertCharactersToHtml($mixedString) {
return htmlspecialchars($mixedString);
}
# 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
@pandauxstudio
pandauxstudio / mysite.yml
Created April 24, 2019 04:48
Allow JSON file uploads in SilverStripe CMS
SilverStripe\MimeValidator\MimeUploadValidator:
MimeTypes:
'json': 'text/plain'
@pandauxstudio
pandauxstudio / mysite.yml
Created April 24, 2019 04:50
Allow JSON file uploads in SilverStripe CMS
SilverStripe\MimeValidator\MimeUploadValidator:
MimeTypes:
'json': 'text/plain'
// 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 / 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');