Skip to content

Instantly share code, notes, and snippets.

View claudiainbytes's full-sized avatar
😺
I build awesome digital stuff

Claudia Estupiñán Forero claudiainbytes

😺
I build awesome digital stuff
View GitHub Profile
@claudiainbytes
claudiainbytes / index.md
Created September 7, 2021 22:46 — forked from rstacruz/index.md
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@claudiainbytes
claudiainbytes / eu_cookie_banner.js
Created October 22, 2020 23:47 — forked from bavington/eu_cookie_banner.js
Simple EU Cookie Law Banner JavaScript
// Cookie for current question
function create_cookie(name, value, days2expire, path) {
var date = new Date();
date.setTime(date.getTime() + (days2expire * 24 * 60 * 60 * 1000));
var expires = date.toUTCString();
document.cookie = name + '=' + value + ';' + 'expires=' + expires + ';' + 'path=' + path + ';';
}
function retrieve_cookie(name) {
var cookie_value = "",
current_cookie = "",
@claudiainbytes
claudiainbytes / Cors.php
Created March 29, 2019 21:30 — forked from drewjoh/Cors.php
Laravel CORS Middleware
<?php // /app/Http/Middleware/Cors.php
namespace App\Http\Middleware;
use Closure;
class Cors {
public function handle($request, Closure $next)
{
return $next($request)
@claudiainbytes
claudiainbytes / gist:d9c9d84fa16d4afcf488086711082e98
Last active December 6, 2018 22:54
Drupal 8 Image Style using Twig
# Example 1.
<div class="col-md-8 blog--caja-right">
{% set imageblog = {
'#theme': 'image_style',
'#style_name': 'despliegue_blog',
'#uri': node.field_image.entity.uri.value,
'#attributes': { class: 'img-responsive' },
} %}
{{ imageblog }}
@claudiainbytes
claudiainbytes / Operaciones-Git
Created August 19, 2018 21:01 — forked from jelcaf/Operaciones-Git
Git Tips - Mini-trucos de Git para facilitarme la tarea
#############################################
# Push de la rama actual
git push origin $rama_actual
#############################################
# Volver a un commit anterior, descartando los cambios
git reset --HARD $SHA1
#############################################
# Ver y descargar Ramas remotas
@claudiainbytes
claudiainbytes / gist:08ec5fb1d0dc3d6feff66b69cc00be83
Created May 18, 2018 23:44
React Short-circuit Evaluation Syntax
{this.state.screen === 'list' && (
<ListContacts
contacts={this.state.contacts}
onDeleteContact={this.removeContact}
/>
)};
{this.state.screen === 'create' && (
<CreateContact />
)}
/* Combining .filter() and .map()
*
* Using the musicData array, .filter, and .map():
* - filter the musicData array down to just the albums that have
* sold over 1,000,000 copies
* - on the array returned from .filter(), call .map()
* - use .map() to return a string for each item in the array in the
* following format: "<artist> is a great performer"
* - store the array returned form .map() in a new "popular" variable
*
/* Using .filter()
*
* Using the musicData array and .filter():
* - return only album objects where the album's name is
* 10 characters long, 25 characters long, or anywhere in between
* - store the returned data in a new `results` variable
*
* Note:
* - do not delete the musicData variable
* - do not alter any of the musicData content
/* Using .map()
*
* Using the musicData array and .map():
* - return a string for each item in the array in the following format
* <album-name> by <artist> sold <sales> copies
* - store the returned data in a new albumSalesStrings variable
*
* Note:
* - do not delete the musicData variable
* - do not alter any of the musicData content