Skip to content

Instantly share code, notes, and snippets.

View taufik-nurrohman's full-sized avatar
🍁
I ❤ U

Taufik Nurrohman taufik-nurrohman

🍁
I ❤ U
View GitHub Profile
<?php
function curry() {
$curryArgs = func_get_args();
return function() use ($curryArgs){
$function = array_shift($curryArgs);
$mergedArgs = array_merge($curryArgs, func_get_args());
return call_user_func_array($function, $mergedArgs);
};
}
// http://ideone.com/Q5USEF
<?php
function minify_css($str){
# remove comments first (simplifies the other regex)
$re1 = <<<'EOS'
(?sx)
# quotes
(
<iframe frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?hl=ru&amp;ie=UTF8&amp;output=embed&amp;q={address}"></iframe>

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

ּ_בּ
בּ_בּ
טּ_טּ
כּ‗כּ
לּ_לּ
מּ_מּ
סּ_סּ
תּ_תּ
٩(×̯×)۶
٩(̾●̮̮̃̾•̃̾)۶
@taufik-nurrohman
taufik-nurrohman / universal-slug-url-generator.js
Created February 11, 2015 15:54
JavaScript Universal Slug URL Generator
/**
* Usage:
* ------
*
* <input type="text"> &rarr; <input type="text">
*
* <script>
* var input = document.getElementsByTagName('input');
* slug(input[0], input[1]);
* </script>
<!DOCTYPE html>
<!-- This is the shortest Image Uploader ever :)
And you can even make it shorter if you don't
want all the drag'n drop thing. -->
<!--
AUTHOR: @paulrouget <paul@mozilla.com>
LICENSE:
/**
* Cross Browser helper to addEventListener.
*
* @param {HTMLElement} obj The Element to attach event to.
* @param {string} evt The event that will trigger the binded function.
* @param {function(event)} fnc The function to bind to the element.
* @return {boolean} true if it was successfuly binded.
*/
var cb_addEventListener = function(obj, evt, fnc) {
// W3C model

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

@taufik-nurrohman
taufik-nurrohman / index.html
Created November 10, 2012 03:42
A CodePen by Taufik Nurrohman.
<figure id="slider">
<div class="container">
<img src="http://lorempixel.com/300/200/food/1" alt="Lorem ipsum dolor sit amet...">
<img src="http://lorempixel.com/300/200/food/2" alt="Consectetuer adipiscing elit...">
<img src="http://lorempixel.com/300/200/food/3" alt="Sed diam nonummy nibh euismod tincidunt...">
<img src="http://lorempixel.com/300/200/food/4" alt="Ut laoreet dolore magna aliquam erat volutpat...">
</div>
<figcaption></figcaption> <!-- slideshow caption -->
</figure>
<nav id="slider-nav"></nav>