Skip to content

Instantly share code, notes, and snippets.

@sasajib
sasajib / uniqueTokenGenerator
Last active August 29, 2015 14:21 — forked from jeffsteinmetz/gist:063bd3237033f3af2ed9
UniqueTokenGenerator
import scala.util._
import java.security.SecureRandom
import java.security.MessageDigest
/*
* Generates a Bearer Token with a length of
* 32 characters (MD5) or 64 characters (SHA-256) according to the
* specification RFC6750 (http://tools.ietf.org/html/rfc6750)
*
* Uniqueness obtained by hashing system time combined with a
package atmo_demo
import org.atmosphere.config.service.{Disconnect, Ready, ManagedService}
import org.atmosphere.cpr._
import akka.actor.{Props, ActorSystem, Actor}
@ManagedService(path = "/search")
class Searcher {
private var factory: BroadcasterFactory = null
private lazy val system: ActorSystem = ActorSystem.create("atmoDemo")
@sasajib
sasajib / Comment.java
Created June 3, 2015 00:56
Official mybatis generator output example
package com.webdev.model;
import java.util.Date;
public class Comment {
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column Comment.Id
*
* @mbggenerated Wed Jun 03 06:42:27 BDT 2015
#!/bin/sh
# one way (older scala version will be installed)
# sudo apt-get install scala
#2nd way
sudo apt-get remove scala-library scala
wget http://www.scala-lang.org/files/archive/scala-2.11.4.deb
sudo dpkg -i scala-2.11.4.deb
sudo apt-get update

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

{
"data": [
{
"like_count": 105,
"total_count": 111,
"share_count": 5,
"click_count": 0,
"comment_count": 1
}
]
@sasajib
sasajib / app.js
Last active August 29, 2015 14:24 — forked from dbainbridge/app.js
Express and socket io connection
/**
* Module dependencies.
*/
var express = require('express')
, routes = require('./routes')
, http = require('http');
var app = express();
var server = app.listen(3000);
lazy val gulpDirectory = baseDirectory { _ / "admin-panel" }
unmanagedResourceDirectories in Assets <+= gulpDirectory
includeFilter in Assets in unmanagedResourceDirectories := "bower_components" || "dist" || "tmp"
excludeFilter in Assets in unmanagedResourceDirectories := new SimpleFileFilter(_.getParent == "node_modules")
name := """pavilion-play-v0.2"""
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayJava)
//Admin panel start
lazy val gulpDirectory = baseDirectory{ _ / "pavilion-panel"}
includeFilter in (Assets, unmanagedResources) := "dist"
@sasajib
sasajib / angularjs-providers-explained.md
Last active September 2, 2015 02:35 — forked from demisx/angularjs-providers-explained.md
AngularJS Providers: Constant/Value/Service/Factory/Decorator/Provider
Provider Singleton Instantiable Configurable
Constant Yes No No
Value Yes No No
Service Yes No No
Factory Yes Yes No
Decorator Yes No? No
Provider Yes Yes Yes

Constant