Skip to content

Instantly share code, notes, and snippets.

View mtinra's full-sized avatar

Mana Tinratreengam mtinra

  • Phuket, Thailand
View GitHub Profile
@mtinra
mtinra / gist:23658af563742d487005
Created February 16, 2016 05:10 — forked from jonathanmoore/gist:2640302
Get the share counts from various APIs

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

@mtinra
mtinra / isnumber.js
Created November 17, 2016 03:16
Check input is number angularjs
//http://stackoverflow.com/a/31558451/4364777
if ( !isNaN(inputVar) && angular.isNumber(+inputVar)) {
//do somthing...
}
@mtinra
mtinra / .htaccess
Created March 17, 2017 17:40 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/

Facebook

http://www.facebook.com/sharer.php?u=URL

All other data will be fetched from open graph meta tags

<meta property="og:url" content="URL" />
<meta property="og:type" content="article" />
<meta property="og:title" content="Content" />
@mtinra
mtinra / vuebar.md
Created July 22, 2017 05:16
Vuebar
@mtinra
mtinra / async.js
Last active July 31, 2017 08:57
Async Await sample with fetch function
// Fetch is return promise
// function fetchAlmbums() {
// fetch('http://rallycoding.herokuapp.com/api/music_albums')
// .then(res => res.json())
// .then(json => console.log(json));
// }
// fetchAlmbums();
const fetchAlmbums = async () => {
@mtinra
mtinra / .env
Last active August 11, 2017 10:13
Sequelize config files for connect to SSL server at Heroku progresql
DATABASE_PATH = postgres://user:pass@localhost:5432/dbname
@mtinra
mtinra / center-everything.css
Last active June 2, 2018 10:17
CSS Flexbox
.container {
display: flex;
align-items: center;
justify-content: center;
}
@mtinra
mtinra / grid-pile-stacking-css-grids-for-impossible-layouts.markdown
Created June 3, 2018 03:15
GRID PILE: Stacking CSS Grids for Impossible Layouts
@mtinra
mtinra / cognito.yaml
Last active May 14, 2021 16:02 — forked from singledigit/cognito.yaml
Create a Cognito Authentication Backend via CloudFormation
AWSTemplateFormatVersion: '2010-09-09'
Description: Cognito Stack
Parameters:
AuthName:
Type: String
Description: Unique Auth Name for Cognito Resources
API_ID:
Type: String
Despription: API Gateway ID