Skip to content

Instantly share code, notes, and snippets.

View Daveiano's full-sized avatar
🏠
Working from home

Daveiano

🏠
Working from home
View GitHub Profile
@dbowling
dbowling / gist:2589645
Created May 3, 2012 21:25
Convert text to a valid CSS class name
string = 'Invalid C$$ class name';
string.replace(/[!\"#$%&'\(\)\*\+,\.\/:;<=>\?\@\[\\\]\^`\{\|\}~]/g, '').toLowerCase();
@opie4624
opie4624 / commandline.py
Last active February 7, 2024 01:39
Base Python Command Line template
#!/usr/bin/env python
#
# import modules used here -- sys is a very standard one
import sys, argparse, logging
# Gather our code in a main() function
def main(args, loglevel):
logging.basicConfig(format="%(levelname)s: %(message)s", level=loglevel)
@infojunkie
infojunkie / views_join_translation.module
Last active December 17, 2015 17:19
A Drupal Views join handler to be used with node translation relationships. This join returns translated nodes *or* the node itself if it is not translated. This is useful to guarantee that some node is returned. To understand the context: http://thereisamoduleforthat.com/content/view-nodes-and-their-translations.
<?php
/**
* Implements hook_views_data_alter().
*/
function views_join_translation_views_data_alter(&$data) {
$data['node']['translation']['relationship']['join_handler'] = 'views_join_translation';
}
/**
@nghuuphuoc
nghuuphuoc / gist:8282411
Last active February 11, 2022 18:45
Install wkhtmltopdf on Centos 6 x64
$ wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.9.9-static-amd64.tar.bz2
$ tar xvjf wkhtmltopdf-0.9.9-static-amd64.tar.bz2
$ mv wkhtmltopdf-amd64 /usr/bin/wkhtmltopdf
// In case you got the issue
// wkhtmltopdf: error while loading shared libraries:
// libfontconfig.so.1: cannot open shared object file: No such file or directory
//
// run the command below:
$ yum install urw-fonts libXext libXrender fontconfig libfontconfig.so.1
@JamesMGreene
JamesMGreene / gitflow-breakdown.md
Last active May 3, 2024 12:32
`git flow` vs. `git`: A comparison of using `git flow` commands versus raw `git` commands.

Initialize

gitflow git
git flow init git init
  git commit --allow-empty -m "Initial commit"
  git checkout -b develop master

Connect to the remote repository

@dmouse
dmouse / SubRequestController.php
Last active November 10, 2023 11:10
Drupal 8: how to create a sub-request
<?php
/**
* @file
* Contains Drupal\dmouse\Controller\SubRequestController.
* Generated by drupal/console.
*/
namespace Drupal\dmouse\Controller;
@Unifex
Unifex / template.php
Created August 17, 2016 00:55
Drupal 7: Find when a node is first published. This uses workbench moderation.
<?php
/**
* Implements hook_preprocess_node().
*/
function my_module_preprocess_node(&$variables) {
$node = $variables['node'];
// First published.
// This query uses workbench moderation to determine the first moderation
// transition that resulted in a published node and takes the timestamp
// from that record.
@jamesguan
jamesguan / python-date-format-to-javascript.js
Last active January 16, 2024 21:36
Function to convert python datetime format to javascript datetime format
// ES6 syntax is used.
/* Key: Python format
* Value: Javascript format
*/
const pyToJSDateFormats = Object.freeze({
'%A': 'dddd', //Weekday as locale’s full name: (In English: Sunday, .., Saturday)(Auf Deutsch: Sonntag, .., Samstag)
'%a': 'ddd', //Weekday abbreivated: (In English: Sun, .., Sat)(Auf Deutsch: So, .., Sa)
'%B': 'MMMM', //Month name: (In English: January, .., December)(Auf Deutsch: Januar, .., Dezember)
'%b': 'MMM', //Month name abbreviated: (In English: Jan, .., Dec)(Auf Deutsch: Jan, .., Dez)
@dphrag
dphrag / ErrorFocus.jsx
Created November 1, 2018 23:41
Formik Scroll To First Invalid Element W/O Refs
import React from 'react';
import { connect } from 'formik';
class ErrorFocus extends React.Component {
componentDidUpdate(prevProps) {
const { isSubmitting, isValidating, errors } = prevProps.formik;
const keys = Object.keys(errors);
if (keys.length > 0 && isSubmitting && !isValidating) {
const selector = `[id="${keys[0]}"]`;
const errorElement = document.querySelector(selector);
@skynet
skynet / upgrade-php7.sh
Created December 29, 2018 03:52 — forked from heathdutton/upgrade-php7.sh
Upgrade PHP to 7.3 on Amazon Linux (specifically for Elastic Beanstalk but should work elsewhere)
#!/usr/bin/env bash
# Upgrade an Amazon Linux EC2 to PHP 7.3
#
# Last tested w/ PHP 7.2 AWS Linux version 2.8.5
#
# Must be ran as sudo:
# sudo bash upgrade-php7.sh
#
# Can be added to ./.ebextensions/20_php.config like so:
# container_commands: