Skip to content

Instantly share code, notes, and snippets.

View jorgecar's full-sized avatar

Jorge Carballo jorgecar

View GitHub Profile
@jorgecar
jorgecar / FileUploader.vue
Created March 5, 2019 22:05 — forked from CristalT/FileUploader.vue
File Uploader Component for Vue.js using Firebase Storage
<template>
<div>
<input type="file" multiple accept="image/jpeg" @change="detectFiles($event.target.files)">
<div class="progress-bar" :style="{ width: progressUpload + '%'}">{{ progressUpload }}%</div>
</div>
</template>
<script>
@jorgecar
jorgecar / gist:2fabddc606073ab5ad33e7cb622550ed
Created December 12, 2018 10:29 — forked from philfreo/gist:b307afd2339767481426
How to have Flask download a file and then serve it as an attachment
@app.route('/download/', methods=['GET'])
def download():
url = request.args['url']
filename = request.args.get('filename', 'image.png')
r = requests.get(url)
strIO = StringIO.StringIO(r.content)
return send_file(strIO, as_attachment=True, attachment_filename=filename)
@jorgecar
jorgecar / build-git.sh
Created November 18, 2016 07:54 — forked from pescobar/build-git.sh
compile git with openssl instead of gnutls
#!/usr/bin/env bash
# Clear out all previous attempts
rm -rf "/tmp/source-git/"
# Get the dependencies for git, then get openssl
sudo apt-get install build-essential fakeroot dpkg-dev -y
sudo apt-get build-dep git -y
sudo apt-get install libcurl4-openssl-dev -y
mkdir -p "/tmp/source-git/"
@jorgecar
jorgecar / README-Template.md
Created November 3, 2016 13:05 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@jorgecar
jorgecar / gist:d532337dd0753fddb1ffde9c98af8b31
Created July 14, 2016 06:56 — forked from hannesl/gist:3864416
Delete/cancel a Drupal user programmatically and safely.
// Tell Drupal to cancel this user.
// The third argument can be one of the following:
// - user_cancel_block: disable user, leave content
// - user_cancel_block_unpublish: disable user, unpublish content
// - user_cancel_reassign: delete user, reassign content to uid=0
// - user_cancel_delete: delete user, delete content
user_cancel(array(), $uid, 'user_cancel_reassign');
// user_cancel() initiates a batch process. Run it manually.
$batch =& batch_get();
@jorgecar
jorgecar / helper.inc.php
Created June 5, 2016 07:23 — forked from anonymous/helper.inc.php
Link to a node translation like l()
/**
* Get the nid of the translation of a node.
*
* @param $base_nid
* The nid of the node to search.
* @param $language_code
* The language that is needed. By default, the current UI language.
*
* @return
* The nid to search for.
@jorgecar
jorgecar / drupal-nginx-virtualhost.conf
Created January 11, 2016 09:35 — forked from Mulkave/drupal-nginx-virtualhost.conf
drupal virtual host configuration for Nginx
server {
server_name [host];
root /var/www/[document_root]; ## <-- Your only path reference.
# Enable compression, this will help if you have for instance advagg module
# by serving Gzip versions of the files.
gzip_static on;
location = /favicon.ico {
@jorgecar
jorgecar / entity-metdata-wrapper-examples.md
Created December 9, 2015 12:10 — forked from cesarmiquel/entity-metdata-wrapper-examples.md
Entity Metadata Wrapper API examples

Entidades en Drupal 7

En Drupal 7 se 'mergearon' los usuarios, nodos y taxonomías en una entidad. Las entidades pueden tener campos adicionales a los que ya tenían. Adicionalmente, cada campo puede estar traducido y, por lo tanto, tener distintos valores dependiendo del idioma. En general es mejor acceder a los valores de los campos via APIs en lugar de acceder directamente al campo. Listamos algunas de las funciones más útiles y recomendadas para utilizar:

  • entity_load() - permite cargar una entidad. Los tipos de las entidades pueden ser 'node', 'user', etc. Ver: entity_load()
  • field_get_items() - devuelve, dada una entidad y el nombre de un campo la lista de valores que contiene el campo. Ver: field_get_values()
  • field_view_value() - devuelve un array rendereable con el valor. Para obtener HTML hacer drupal_rend
@jorgecar
jorgecar / field_term_reference.php
Created November 25, 2015 16:13 — forked from olragon/field_term_reference.php
Drupal's entity_metadata_wrapper examples
// @see https://www.drupal.org/node/2378611#comment-9360381
$entity = entity_create('node', $values);
$wrapper = entity_metadata_wrapper('node', $entity);
$wrapper->field_my_term_reference->set(123);
$wrapper->save();