Skip to content

Instantly share code, notes, and snippets.

@brunorios1
brunorios1 / MyPresentationalComponent.js
Created June 2, 2017 19:56
react native presentational component
import React from 'react';
import { View } from 'react-native';
const MyPresentationalComponent = (props) => {
return (
<View>
{props.children}
</View>
);
};
@brunorios1
brunorios1 / MyComponent.js
Created June 2, 2017 19:53
react native class based component boilerplate
import React, { Component } from 'react';
import { View } from 'react-native';
class MyComponent extends Component {
render() {
return (
<View />
);
}
}
@brunorios1
brunorios1 / gist:c7e27bc13850ce4e9920
Created August 4, 2015 20:25
[d7] replace the meta content-type tag
function YOURTHEME_html_head_alter(&$head_elements) {
// replace the meta content-type tag for Drupal 7
// http://www.metaltoad.com/blog/how-change-content-type-meta-tag-drupal
$head_elements['system_meta_content_type']['#attributes'] = array(
'charset' => 'utf-8'
);
}
@brunorios1
brunorios1 / gist:dd78c1e17cd420785e8e
Last active February 8, 2017 16:49
[js] check if Modernizr is loaded, detect a feature and run code
if (typeof Modernizr == 'object') {
if (!Modernizr.touch) {
console.log('Touch device');
}
}
@brunorios1
brunorios1 / gist:e5e01ab27d9cc746e846
Created June 21, 2015 21:20
[d7] hook_form_alter views exposed filter #default_value
if($form_id == 'views_exposed_form') {
if($form['#id'] == 'views-exposed-form-view-display') {
if (!isset($_GET['field']) || $_GET['field'] == '') {
$default_value = 123;
$form_state['input']['industry'] = $default_value;
}
}
}
@brunorios1
brunorios1 / gist:806dfaff9733af94e8f2
Created June 20, 2015 16:58
[d7] how to render a custom fully themed field with label and multiple values
$user_name_field = field_view_field('user', $user, 'field_name');
$user_name = render($user_name_field);
//dsm($user_name);
@brunorios1
brunorios1 / gist:e423b4f5276c1fc4286e
Last active August 29, 2015 14:23
[d7] how to render a custom field without theme (single value)
$user_name = '';
$user_name_items = field_get_items('user', $user, 'field_name');
if(!empty($user_name_items)) {
$user_name_value = field_view_value('user', $user, 'field_name', $user_name_items[0]);
$user_name = render($user_name_value);
}
//dsm($user_name);
@brunorios1
brunorios1 / gist:a3d90ce3ba91d60b6285
Created March 24, 2015 17:51
[d7] theme image style example
<?php
// http://tylerfrankenstein.com/code/drupal-7-theme-image-style-example
$image = theme(
'image_style',
array(
'path' => 'public://my_example_image.jpg',
'style_name' => 'my_custom_image_style',
'alt' => 'Alternate Text',
'title' => 'Title Text',
@brunorios1
brunorios1 / SassMeister-input-HTML.html
Last active August 29, 2015 14:16
BEM-naming convention using Sass nesting
<div class="person person--male">
<div class="person__hand person__hand--right"></div>
<div class="person__hand person__hand--left"></div>
</div>
<div class="person person--female">
<div class="person__hand person__hand--right"></div>
<div class="person__hand person__hand--left"></div>
</div>
@brunorios1
brunorios1 / gist:3b25f5494d586fd59e7b
Last active August 29, 2015 14:16
[scss] Converts tracking to em, rem or px
// Converts tracking to em, rem or px
// Usage:
// Em: p { letter-spacing: ls(-50); }
// Rem: p { letter-spacing: ls(-50, 21, rem); }
// Px: p { letter-spacing: ls(-50, 21, px); }
$base-font-size: 16;
@function ls($target, $context: $base-font-size, $unit: em) {
@if ($unit == em) {