Skip to content

Instantly share code, notes, and snippets.

@kopiro
kopiro / facebook-speak-online-friends.js
Created July 14, 2012 08:20
Facebook speaks new online friends
function in_array (needle, haystack)
{
for (var key in haystack)
if (haystack[key] == needle)
return true;
return false;
}
var initOnline = AvailableList.getOnlineIDs();
@kopiro
kopiro / time-ago.php
Created July 26, 2012 21:06
Time ago function PHP
<?php
function time_ago($date, $granularity=1)
{
$date = strtotime($date);
if (!$date) return '';
$difference = time() - $date;
$periods = array(
'decad' => 315360000,
'ann' => 31536000,
'mes' => 2628000,
@kopiro
kopiro / share-counts.php
Created August 11, 2012 16:14
Get share counts in PHP
<?php
class SocialCount
{
public static function getAll($link)
{
return self::getServices($link);
}
#!/bin/bash
/usr/local/mysql/bin/mysqldump --add-drop-database -h $1 -u $2 -p $5 > /tmp/dump.sql; mysql -h $3 -u $4 -p $5 < /tmp/dump.sql;
@kopiro
kopiro / kopiro.timeago.js
Created August 23, 2012 17:32
Kopiro TimeAgo
Date.prototype.timeAgoString = function(granularity)
{
var t = this.timeAgo(granularity);
var r = [];
for (var i=0; i<t.length; i++)
r.push( t[i].time+' '+t[i].key );
return r.join(' e ');
}
Date.prototype.timeAgo = function(granularity)
@kopiro
kopiro / kopirotimeago-implementation.htm
Created August 24, 2012 10:55
Simple KopiroTimeAgo Implementation
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" id="jquery-script"></script>
<script type="text/javascript" src="https://raw.github.com/kopiro/kopiroTimeAgo/master/kopiro.timeago.js"></script>
<script type="text/javascript">
jQuery(document).ready(function($){
$('time').kopiroTimeAgo({ granularity:5 });
});
</script>
@kopiro
kopiro / add-timestamp-to-ticker.js
Last active May 13, 2017 07:56
Add the time to the story Facebook ticker
[].forEach(document.querySelectorAll('.fbFeedTickerStory'), function(t) {
t.innerHTML += '<i>'+(new Date(t.dataset['ticker-timestamp']*1000).toTimeString().match(/[0-9][0-9]\:[0-9][0-9]\:[0-9][0-9]/))+'</i>';
});
@kopiro
kopiro / fbtypalert.js
Last active October 11, 2015 00:08
Ticker Notify when someone Typ you in Facebook Chat
var jq = document.createElement('script');
jq.src = '//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js';
document.body.appendChild(jq);
var jqI = setInterval(function()
{
if (!jQuery in window) return;
clearInterval(jqI);
jQuery.noConflict();
window.$J = jQuery;
@kopiro
kopiro / fbtypreadinibit.js
Last active October 11, 2015 00:08
Block Typing/Read message Facebook notify
AsyncRequest.prototype.sendOriginal = AsyncRequest.prototype.send;
AsyncRequest.prototype.send = function(ka){
if ( this.uri.path.match('typ|read_status|mark_seen')) return;
this.sendOriginal(ka);
}
@kopiro
kopiro / autoinc-tvseries.sh
Created September 25, 2012 21:01
Auto Increment when watching TV series
#!/bin/sh
cur=$(cat current);
serie=$(echo $cur | awk -F"x" '{print $1}');
episode=$(echo $cur | awk -F"x" '{print $2}');
if ! [[ "$serie" =~ ^[0-9]+$ ]]; then
echo "Unmatched serie, exit";
exit;