Skip to content

Instantly share code, notes, and snippets.

View qborreda's full-sized avatar

Quique Borredá qborreda

View GitHub Profile
/**
* Chrome Snippet
* Shows all variables in _global_ other than native
*/
(function() {
var standardGlobals = ["top", "window", "location", "external", "chrome", "document", "inlineCSS", "target", "width", "height", "canvas", "data", "DOMURL", "img", "svg", "ctx", "url", "w", "a", "speechSynthesis", "webkitNotifications", "localStorage", "sessionStorage", "applicationCache", "webkitStorageInfo", "indexedDB", "webkitIndexedDB", "crypto", "CSS", "performance", "console", "devicePixelRatio", "styleMedia", "parent", "opener", "frames", "self", "defaultstatus", "defaultStatus", "status", "name", "length", "closed", "pageYOffset", "pageXOffset", "scrollY", "scrollX", "screenTop", "screenLeft", "screenY", "screenX", "innerWidth", "innerHeight", "outerWidth", "outerHeight", "offscreenBuffering", "frameElement", "clientInformation", "navigator", "toolbar", "statusbar", "scrollbars", "personalbar", "menubar", "locationbar", "history", "screen", "postMessage", "close", "blur", "focus", "ondeviceorientation", "
@qborreda
qborreda / countCSSRules.js
Last active September 13, 2016 07:55 — forked from psebborn/countCSSRules.js
Count the number of rules and selectors for CSS files on the page.
/**
* Chrome Snippet
* Count the number of rules and selectors for CSS files on the page.
* Flags up the >4096 threshold that confuses IE.
*/
function countCSSRules() {
var results = '',
log = '';
if (!document.styleSheets) {
@qborreda
qborreda / DropZone.jsx
Created August 24, 2016 12:29 — forked from pizzarob/01_DropZone.jsx
HTML5 Drag and Drop File Upload React Component
import React, {PropTypes} from 'react';
import classNames from 'classnames';
const ANIMATION_DURATION = 1000;
class BatchDropZone extends React.Component {
static propTypes = {
// function that recieves an array of files
import React, {PropTypes} from 'react';
import icons from './_getIcons';
import colors from '_style/colors';
export default function Icon (props) {
let {color, size, value, ...more} = props;
delete more.className;
delete more.style;
@qborreda
qborreda / rule-ordering.css
Created June 29, 2016 14:51
Rule Ordering at CSS/SCSS/etc..
.declaration-order {
/* Positioning */
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 100;
/* Box-model */
@qborreda
qborreda / debug_to_console.php
Created June 6, 2016 16:24
PHP script to send console.log messages
/**
* Send debug code to the Javascript console
*/
function debug_to_console($data) {
if(is_array($data) || is_object($data))
{
echo("<script>console.log('PHP: ".json_encode($data)."');</script>");
} else {
echo("<script>console.log('PHP: ".$data."');</script>");
}
@qborreda
qborreda / regexp.js
Created May 16, 2016 09:54
Some RegExp for easy access
Email
/^(([a-zA-Z]|[0-9])|([.])){1,65}[@](([a-zA-Z0-9])|([.])){1,65}[.](([a-zA-Z0-9]){1,4})+$/gi
Phone (123-456-789)
/^(([0-9]{4,4})?[\-]?[\s]){4,4}$/g
@qborreda
qborreda / MyContainerComponent.jsx
Last active May 12, 2016 18:50
Redux Ecosystem
import React from 'react'
import { connect } from 'react-redux'
// Create the component that you want to make smart.
class MyContainerComponent extends React.Component {
//...
// Here you have access to the Dispatcher through the props.
doAction() {
this.props.dispatch({
@qborreda
qborreda / Revealing.js
Created May 9, 2016 15:26
Addy Osmani's Revealing Module Pattern
var myRevealingModule = (function () {
var privateVar = "Ben Cherry",
publicVar = "Hey there!";
function privateFunction() {
console.log( "Name:" + privateVar );
}
function publicSetName( strName ) {
@qborreda
qborreda / Decorator.js
Last active May 9, 2016 15:24
Addy Osmani's Decorator Pattern
// A vehicle constructor
function Vehicle( vehicleType ){
// some sane defaults
this.vehicleType = vehicleType || "car";
this.model = "default";
this.license = "00000-000";
}