Skip to content

Instantly share code, notes, and snippets.

View modcab's full-sized avatar

Modesto Caballero modcab

  • Modlabs IT Solutions
  • London, UK
View GitHub Profile
@modcab
modcab / Convert .mov or .MP4 to .gif.md
Created November 1, 2022 11:01 — forked from SheldonWangRJT/Convert .mov or .MP4 to .gif.md
Convert Movie(.mov) file to Gif(.gif) file in one command line in Mac Terminal

This notes is written by Sheldon. You can find me with #iOSBySheldon in Github, Youtube, Facebook, etc.

Need

Convert .mov/.MP4 to .gif

Reason

As a developer, I feel better to upload a short video when I create the pull request to show other viewers what I did in this PR. I tried .mov format directly got after finishing recording screen using Quicktime, however, gif offers preview in most web pages, and has smaller file size.

This is not limited to developer, anyone has this need can use this method to convert the files.

@modcab
modcab / file.php
Created June 14, 2018 12:12
Drupal 8 - Extract file url from media field
<?php
$url = $item['content']['field_media_image'][0]['#url'];
$media_id = $url->getRouteParameters()['media'];
$media = entity_load('media', $media_id);
$filefield = $media->field_image_file->referencedEntities();
$entity = current($entity);
$uri = $entity->getFileUri();
$url = Url::fromUri(file_create_url($uri))->toString();
@modcab
modcab / multiple_ssh_setting.md
Created September 11, 2017 11:37 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@modcab
modcab / module.php
Created July 12, 2017 12:41
Drupal 8 - Get MIME type from file uri.
<?php
$mime = \Drupal::service('file.mime_type.guesser')->guess($uri);
@modcab
modcab / gist:227fc7e78adf5e6a5486790eeed1e77b
Created June 16, 2017 12:56
XDebug: how to debug remote console application? - From https://stackoverflow.com/a/17183664
export PHP_IDE_CONFIG="serverName={SERVER NAME IN PHP STORM}"
export XDEBUG_CONFIG="remote_host=$(echo $SSH_CLIENT | awk '{print $1}') idekey=PHPSTORM"
@modcab
modcab / core-lib-Drupal-Core-Entity-ContentEntityBase.php
Created May 19, 2017 10:16
Drupal 8 - Content entities - How __get (magical method) vs get (explicit method) work
<?php
public function get($field_name) {
if (!isset($this->fields[$field_name][$this->activeLangcode])) {
return $this->getTranslatedField($field_name, $this->activeLangcode);
}
return $this->fields[$field_name][$this->activeLangcode];
}
public function &__get($name) {
@modcab
modcab / homepage.php
Created December 6, 2016 14:52
Drupal 8 - Get absolute URL from front page.
Url::fromUri('internal:/')->setAbsolute()->toString()
@modcab
modcab / 0_reuse_code.js
Created November 18, 2016 09:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@modcab
modcab / modulename.module.php
Last active November 8, 2016 15:10
Drupal 8 - View - Add a footer programmatically.
<?php
/**
* Implements hook_views_pre_view().
*/
function projectname_views_pre_view(\Drupal\views\ViewExecutable $view, $display_id, array &$args) {
// Project - Assets - 'Add' link.
if ($view->id() == 'project_assets' && $display_id === 'block_1') {
$account = \Drupal::currentUser();
// If we're in a group.
if (($group = \Drupal::routeMatch()->getParameter('group')) &&
@modcab
modcab / script.js
Created October 6, 2016 09:21
Owl carousel, with loop = true, get the right current slide on 'changed' event
$(carousel_selector)
.owlCarousel(owlOptions)
.on('changed.owl.carousel', function(e) {
// Number of items, not counting cloned ones.
var count = e.item.count;
// When carousel is infinite,
// there's a certain offset to the first item.
// We'll try to remove it to do our calculations.
var offset = Math.floor((count + 1) / 2);
// This posittion index includes some offset.