Skip to content

Instantly share code, notes, and snippets.

View qborreda's full-sized avatar

Quique Borredá qborreda

View GitHub Profile
@qborreda
qborreda / twitter-proxy.php
Created June 6, 2013 15:45 — forked from MikeRogers0/twitter-proxy.php
Access Twitter data from a php proxy
<?php
/**
* Usage:
* Send the url you want to access url encoded in the url paramater, for example (This is with JS):
* /twitter-proxy.php?url='+encodeURIComponent('statuses/user_timeline.json?screen_name=MikeRogers0&count=2')
*/
// The tokens, keys and secrets from the app you created at https://dev.twitter.com/apps
$config = array(
@qborreda
qborreda / no.control.js
Last active August 29, 2015 14:04
Various javaScript methods to prevent user control and menus ..
// Disable Context Menu
document.oncontextmenu = function () {
return false
};
// Disable dragging of HTML elements
document.ondragstart = function () {
return false
};
env = (function() {
var flags = {}, ua = navigator.userAgent, el = document.createElement('div'), video = document.createElement('video'), audio = document.createElement('audio'), root = document.documentElement, i
function flag(names) {
names = names.split(' ')
for (i = 0; i < names.length; i++)
flags[names[i]] = true
}
function classnames() {
var names = [], name
for(name in flags) if (flags.hasOwnProperty(name))
// Based on fantastic jQuery useragent parser plugin https://gist.github.com/373298
function parse(uaStr) {
var agent = {
platform: {},
browser: {},
engine: {}
};
var ua = uaStr,
p = agent.platform,

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

@qborreda
qborreda / data-action.js
Last active May 30, 2021 11:18 — forked from pbojinov/data-action.js
JavaScript event hooking with data-action
// Set up HTML hooks without id or extra classes
<button data-action="openLogin">Login</button>
<a href="javascript:;" data-action="openEditor">Link</a>
// Using [data-action=""] selectors instead of class selectors when binding events in JavaScript
var actions = {
openLogin: openLoginWindow,
openEditor: function() { ... }
//....
};
@qborreda
qborreda / FlexBox_Layout.scss
Created November 24, 2015 10:14 — forked from alisonailea/FlexBox_Layout.scss
Based on CSS Tricks: Using Flexbox - http://css-tricks.com/using-flexbox/ & Special Thanks to Hugo Giraudel- http://hugogiraudel.com/2013/07/15/understanding-sass-lists/ Flexbox with elegant depreciation. Works in IE10+, iOS 6-, Safari 3.1-6, Firefox 20-, Chrome, Opera 12.1 The advantage of this Mixin set is it is small and reusable. Use any cla…
@mixin setFlexBox($flexType){
//options are block level or inline
@if $flexType == 'block'{
display: -webkit-box;
display: -moz-box;
display: box;
display: -ms-flexbox;
display: flexbox;
display: -webkit-flex;
display: flex;
// Alerts
@include alert-variant($background, $border, $text-color);
// Background Variant
@include bg-variant($parent, $color);
// Border Radius
@include border-top-radius($radius);
@include border-right-radius($radius);
@include border-bottom-radius($radius);
@qborreda
qborreda / css-triangle.scss
Created November 30, 2015 08:48 — forked from patocallaghan/css-triangle.scss
CSS Triangles SCSS Mixin #css #scss #triangle #mixin
//==== Simple SCSS mixin to create CSS triangles
//==== Example: @include css-triangle ("up", 10px, #fff);
@mixin css-triangle ($direction: "down", $size: 20px, $color: #000) {
width: 0;
height: 0;
border-left: $size solid #{setTriangleColor($direction, "left", $color)};
border-right: $size solid #{setTriangleColor($direction, "right", $color)};
border-bottom: $size solid #{setTriangleColor($direction, "bottom", $color)};
border-top: $size solid #{setTriangleColor($direction, "top", $color)};
}
@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