Skip to content

Instantly share code, notes, and snippets.

View ghernandez345's full-sized avatar

Gabriel Hernandez ghernandez345

  • Fleet Device Management
  • London, UK
View GitHub Profile
@ghernandez345
ghernandez345 / rmb.sh
Last active July 31, 2017 09:30
Clean up local branches based on merged remote branches
git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d
@ghernandez345
ghernandez345 / parentDimensionsDependentOnChildren.js
Last active July 10, 2017 13:41
React native parent dimensions dependent on child components
/* Use this pattern when you want your parent components dimension
* to be dependent by it's children components dimensions.
*/
const styles = StyleSheet.create({
container: {
flexDirection: 'row',
alignItems: 'center',
alignSelf: 'flex-start'
},
@ghernandez345
ghernandez345 / chromOnTravis
Created January 18, 2016 10:59
executes chrome on travis CI; for browser tests.
// This block is needed to execute Chrome on Travis
// If you ever plan to use Chrome and Travis, you can keep it
// If not, you can safely remove it
// https://github.com/karma-runner/karma/issues/1144#issuecomment-53633076
if(configuration.browsers[0] === 'Chrome' && process.env.TRAVIS) {
configuration.customLaunchers = {
'chrome-travis-ci': {
base: 'Chrome',
flags: ['--no-sandbox']
}
@ghernandez345
ghernandez345 / index.html
Last active December 24, 2015 12:49
file upload btn snippet
<!-- The fileinput-button span is used to style the file input field as button -->
<button class="btn btn-default btn-lg upload-btn fileinput-button">
<span>Upload More Files</span>
<!-- The file input field used as target for the file upload widget -->
<input id="fileupload" type="file" name="files[]" multiple>
</button>
@ghernandez345
ghernandez345 / relatedContent.js
Created August 22, 2013 23:06
List menu that shows and hides related content.
/**
* Show the related content of an element. Just add `relation-list` to your `ul` that contains
* the elements that you will click. For all the elements related to the list items, just
* add class 'related-content'.
*
* (eg.)
* <ul class="content-list relation-list">
* <li></li>
* ....
* </ul>
@ghernandez345
ghernandez345 / path.js
Created August 16, 2013 23:38
d3 animated path rendering
// This will animate all the path rendering to draw from the begining of the path to the end of the path
var paths = d3.selectAll('path.link');
paths.each(function () {
var path = d3.select(this);
var totalLength = path.node().getTotalLength();
path.attr("stroke-dasharray", totalLength + " " + totalLength)
.attr("stroke-dashoffset", totalLength)
.transition()
@ghernandez345
ghernandez345 / component.js
Created June 25, 2013 00:19
Stupid hack for dumb android to fix a damn fixed button diappearing
// The only reason this stupid method exists is because some versions of android
// will not render the a fixed element correctly. We move it just so this dumb button
// will be visible.
moveButton: function () {
var self = this;
this.$('.buttons-section').css({bottom: '1px'});
setTimeout(function () {
self.$('.buttons-section').css({bottom: 0});
}, 200);
},
@ghernandez345
ghernandez345 / index.html
Last active December 18, 2015 10:39
Header with icon that always stays same distance from text. Very useful for responsive designs.
<!-- Simply wrap your h1 with another div. This html is very semantic and doesnt add a unnecessary div
tag just for the icon. As far as anyones concerned, no icon even exists according to this HTML. -->
<div class="header-container">
<h1>Some Header Text Here</h1>
</div>
@ghernandez345
ghernandez345 / index.html
Last active December 18, 2015 08:29
how to properly expand anchor tags when they contain children.
<!-- this anchor contains some other html elements as it's children. By default it will NOT
expand to the size of its children. It's demensions in the browser will be 0x0 until you implement the correct css. -->
<a href="#someLink" class="some-link-button">
<div class="button">Click here</div>
</a>
@ghernandez345
ghernandez345 / main.css
Last active December 18, 2015 04:19
Sticky footer
html,body {
height: 100%;
}
/* The bottom margin on #wrap must be the negative value of the height on #push and #footer.
*
* e.g.
* ------------------------------------------
* #push and footer height is 60px;
* #wrap margin bottom is -60px;