Skip to content

Instantly share code, notes, and snippets.

View cristinallamas's full-sized avatar
:shipit:

Cristina Llamas cristinallamas

:shipit:
View GitHub Profile
@cristinallamas
cristinallamas / export_databases.sh
Created October 11, 2019 19:42
Export databases individually
#! /bin/bash
TIMESTAMP=$(date +"%F")
BACKUP_DIR="/backup/$TIMESTAMP"
MYSQL_USER="backup"
MYSQL=/usr/bin/mysql
MYSQL_PASSWORD="password"
MYSQLDUMP=/usr/bin/mysqldump
mkdir -p "$BACKUP_DIR/mysql"
@cristinallamas
cristinallamas / drupal_alter.php
Created September 18, 2019 08:50 — forked from mrded/drupal_alter.php
Drupal: alter usage example
<?php
drupal_alter('foo', $x, $y);
/**
* Implements hook_foo_alter().
*/
function hook_foo_alter(&$x, &$y) {}
@cristinallamas
cristinallamas / one_coupon_of_type_per_order.php
Created September 16, 2019 15:24 — forked from proofoftom/one_coupon_of_type_per_order.php
Limits a coupon type (i.e. Discount Coupons) to one per order, while allowing other types (i.e. Gift Cards) to have multiple applied to the order.
<?php // Required for gist code formatting.
/**
* Implements hook_commerce_coupon_condition_outcome_alter().
*/
function mymodule_custom_commerce_coupon_condition_outcome_alter(&$outcome, $context) {
$order_wrapper = entity_metadata_wrapper('commerce_order', $context['order']);
$order_coupons = $order_wrapper->commerce_coupons->value();
$coupon = $context['coupon']->value();
@cristinallamas
cristinallamas / parent.php
Created March 21, 2019 13:00 — forked from crittermike/parent.php
Find the parent of a taxonomy term in Drupal 8
<?php
$parents = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadParents($term_id);
$parent_term = reset($parents);
@cristinallamas
cristinallamas / gist:4a9bbd245c281cfe87ad560200dfd9ef
Created January 8, 2019 15:58
Detect Route change in ReactJS
import { withRouter } from 'react-router-dom';
history.listen((location, action) => {
console.log("on route change");
// Do stuff.
})
@cristinallamas
cristinallamas / drupal-8-get-frontpage-alias.php
Created September 14, 2018 11:05 — forked from mikedotexe/drupal-8-get-frontpage-alias.php
Get homepage path of Drupal 8 site from configuration
<?php
use Drupal\Core\Config\Config;
// ...
$config = \Drupal::config('system.site');
$front_uri = $config->get('page.front');
$alias = \Drupal::service('path.alias_manager')->getAliasByPath($front_uri);
@cristinallamas
cristinallamas / image_src.html.twig
Created August 31, 2018 16:17 — forked from bogvsdev/image_src.html.twig
Drupal 8 twig, get image url
{% set the_image = item.content['#field_collection_item'].field_featurette_image %}
<img src="{{ file_url(the_image.entity.uri.value) }}" alt="{{ the_image.alt }}" title="{{ the_image.title }}">
or
<img src="{{file_url(node.field_hotel_image.entity.uri.value)}}" alt="3242">
@cristinallamas
cristinallamas / php_upgrade_to_71.sh
Created April 11, 2018 09:47 — forked from pixeline/php_upgrade_to_71.sh
Update Mac Os X's php version to php 7.1 using homebrew. Includes curl and mcrypt
# 1. Install brew --> http://brew.sh/
# 2. run the following commands in your Terminal
brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/homebrew-php
brew install --with-openssl curl
brew install --with-homebrew-curl --with-apache php71
brew install php71-mcrypt php71-imagick
# 3. Follow these instructions to make Apache and php-cli use the newer php executable and make the change persist after reboot.
brew info php71
@cristinallamas
cristinallamas / object.prototype-array-methods.js
Created April 9, 2018 14:15 — forked from rgdelato/object.prototype-array-methods.js
ES5 Array methods as applied to Object.prototype (map and filter are currently incorrect implementations)
// ES5 Array methods
// New methods added: Array.isArray, indexOf, lastIndexOf, every, some,
// forEach, map, filter, reduce, reduceRight
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
// Array.prototype.reduce(function (previousValue, currentValue, currentIndex, array), initialValue)
if (!Object.prototype.reduce) {
Object.prototype.reduce = function (callback, initialValue) {
var _this = this;
@cristinallamas
cristinallamas / SCSS.md
Created August 10, 2017 20:11 — forked from jareware/SCSS.md
Advanced SCSS, or, 16 cool things you may not have known your stylesheets could do

⇐ back to the gist-blog at jrw.fi

Advanced SCSS

Or, 16 cool things you may not have known your stylesheets could do. I'd rather have kept it to a nice round number like 10, but they just kept coming. Sorry.

I've been using SCSS/SASS for most of my styling work since 2009, and I'm a huge fan of Compass (by the great @chriseppstein). It really helped many of us through the darkest cross-browser crap. Even though browsers are increasingly playing nice with CSS, another problem has become very topical: managing the complexity in stylesheets as our in-browser apps get larger and larger. SCSS is an indispensable tool for dealing with this.

This isn't an introduction to the language by a long shot; many things probably won't make sense unless you have some SCSS under your belt already. That said, if you're not yet comfy with the basics, check out the aweso