Skip to content

Instantly share code, notes, and snippets.

View isramv's full-sized avatar
🐧

Israel M isramv

🐧
View GitHub Profile
#!/usr/bin/env bash
echo ">>> Installing Mailhog"
# Download binary from github
wget --quiet -O ~/mailhog https://github.com/mailhog/MailHog/releases/download/v0.2.1/MailHog_linux_amd64
# Make it executable
chmod +x ~/mailhog
@isramv
isramv / example.twig
Created February 10, 2023 16:11
How to check if a multiple paragraph is empty
{% set preprinted_supplies = node.field_issue_calendar.value %}
{% set preprinted_supplies_not_empty = [] %}
{% for item in preprinted_supplies %}
{% set psp = drupal_field('field_preprinted_supplied_pieces', 'paragraph', item.target_id) %}
{% if psp['#title'] is not null %}
{% set preprinted_supplies_not_empty = preprinted_supplies_not_empty|merge(['true']) %}
{% endif %}
{% endfor %}
{% if preprinted_supplies_not_empty|length > 0 %}
@isramv
isramv / custom.theme
Created February 10, 2023 15:05
Remove the word "Front |" from the homepage Drupal 9
function custom_theme_preprocess_html(&$vars) {
$vars['is_front'] = \Drupal::service('path.matcher')->isFrontPage();
}
@isramv
isramv / jQuery check if empty input add class
Last active June 14, 2022 23:37
Check if input has a value add and remove class jQuery
$('input#edit-keys-1').blur(function(){
tmpval = $(this).val();
if(tmpval == '') {
$(this).addClass('empty');
$(this).removeClass('not-empty');
} else {
$(this).addClass('not-empty');
$(this).removeClass('empty');
}
});
@isramv
isramv / mongo_on_mac_yosemite_10.10.4.md
Last active October 23, 2021 13:33
How to install mongodb on Mac Yosemite 10.10.4

how to install Mongo db on Mac Yosemite 10.10.4

I will be following the official documentation here but they take some things for granted, many users could get frustrated and confused that's why I created this gist.

I have downloaded the mongo files in my root user directory for example: /Users/israel/mongodb therefore if you want to do the same first enter cd in your terminal.

then enter pwd command in your terminal and you should be able to se something similar to /Users/<yourmacuser>

If the previous is correct you may want to proceed and open the terminal then download the tar:

@isramv
isramv / autofix.md
Last active October 8, 2020 15:45
stylelint implementation.

Fixing property sort order:

  • node ./node_modules/stylelint/bin/stylelint.js assets/styles/*.scss --fix
  • node ./node_modules/stylelint/bin/stylelint.js assets/styles/**/*.scss --fix
{
  "plugins": [
  "stylelint-order"
 ],
@isramv
isramv / font-awesome social round icons css.md
Created May 10, 2016 23:09
FontAwesome round social icons

Credits here: FortAwesome/Font-Awesome#4167

I agree. Use Pure css, with border-radius and a fixed width and height.

For example:

.social [class*="fa fa-"] {
    background-color: #333;
 border-radius: 30px;
@isramv
isramv / gatsby-node.js
Created May 28, 2020 18:21
gatsby-node.js
exports.onCreateNode = ({node, actions, getNodes, graphql, createNodeId, getCache}) => {
if (node.internal.type !== 'SitePage') {
return;
}
const {
createNode
} = actions
let media = []
@isramv
isramv / how_to_create_global_gitignore.md
Last active December 11, 2019 18:21
Create a global gitignore file.

Create the global gitignore.

$ touch .gitignore_global

let git know where your global ignore file is located at.

$ git config --global core.excludesfile ~/.gitignore_global

Drupal\geolocation\Plugin\Field\FieldType\GeolocationItem.php

public static function generateSampleValue(FieldDefinitionInterface $field_definition) {

  // Guadalajara.
  $longitude = (float) -103.3496;
  $latitude = (float) 20.6597;
  $radius = rand(1,5); // in miles