Skip to content

Instantly share code, notes, and snippets.

/**
* Convert a decimal to a fraction.
*
* @param number $decimal
* @return string
*/
public static function decimal2fraction($decimal)
{
$decimalBase = --$decimal;
$denomenator = 1;
@sasajib
sasajib / Sample.java
Last active August 29, 2015 14:11 — forked from kinjouj/Sample.java
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.apache.tika.exception.TikaException;
import org.apache.tika.metadata.Metadata;
import org.apache.tika.parser.AutoDetectParser;
import org.apache.tika.parser.ParseContext;
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
package com.company;
http://eveningsamurai.wordpress.com/2013/06/29/capturing-network-traffic-using-selenium-webdriverfirebug/
Proxy proxy = new Proxy();
// The URL here is the URL that the browsermob proxy is using
proxy.setHttpProxy("localhost:9100");
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability(CapabilityType.PROXY, proxy);
#!/bin/sh
DEST_DIR="/some/other/dir"
function linker() { # create simlink to downloaded files, rather than copy to final directory
if [ ! -d "$DEST_DIR/$1" ]; then mkdir "$DEST_DIR/$1"; fi
cd "$1"
for F in *; do
if [ -d "$F" ]; then linker "$1/$F"; fi
ln -s "$TR_TORRENT_DIR/$1/$F" "$DEST_DIR/$1"

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

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

@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")