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
@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>
@taufik-nurrohman
taufik-nurrohman / index.html
Created November 10, 2012 03:52
A CodePen by Taufik Nurrohman. JQuery Slideshow, Like Nivo Slider
<figure id="slider">
<div class="container">
<img src="http://lorempixel.com/400/250/sports/1" alt="Lorem ipsum dolor sit amet...">
<img src="http://lorempixel.com/400/250/sports/2" alt="Consectetuer adipiscing elit...">
<img src="http://lorempixel.com/400/250/sports/3" alt="Sed diam nonummy nibh euismod tincidunt...">
<img src="http://lorempixel.com/400/250/sports/4" alt="Ut laoreet dolore magna aliquam erat volutpat...">
</div>
<figcaption></figcaption> <!-- slideshow caption -->
<nav id="slider-nav"></nav> <!-- navigation -->
</figure>
@taufik-nurrohman
taufik-nurrohman / jquery.masonry-0.6.js
Created November 13, 2012 09:06 — forked from desandro/jquery.masonry-0.6.js
Early jQuery Masonry
(function($){
//Finding min and max values in array from http://snippets.dzone.com/posts/show/769
Array.prototype.min = function(){ return Math.min.apply({},this) };
Array.prototype.max = function(){ return Math.max.apply({},this) };
$.fn.masonry = function() {
this.each(function() {
var wall = $(this);
@taufik-nurrohman
taufik-nurrohman / index.html
Created January 30, 2013 12:07
A CodePen by Taufik Nurrohman. Text Input with Suggestion - Using JQuery and some extra markup to make a text input (text form) with some drop down suggestion value.
<div class="input-text-wrap">
<form action="http://www.google.com/search" method="get">
<input class="text-input" type="text" name="q" autocomplete="off"/>
<span class="down-arrow"></span>
<input class="submit-button" type="submit" value="Search"/>
<ul>
<li>Wallpaper 3D</li>
<li>Anime</li>
<li>Manga</li>
<li>Comics List</li>
function setVisibleTimeout(callback, delay) {
var id = null,
t = 0,
prefix = '';
'o webkit moz ms'.replace(/\S+/g, function(p) {
if ((p + 'Hidden') in document) {
prefix = p;
}
});
function onVisibilityChange(event) {
<?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 / php-html-css-js-minifier.php
Last active February 23, 2024 04:30
PHP Function to Minify HTML, CSS and JavaScript
<?php
// Based on <https://github.com/mecha-cms/x.minify>
namespace x\minify\_ { // start namespace
$n = __NAMESPACE__;
\define($n . "\\token_boolean", '\b(?:true|false)\b');
\define($n . "\\token_number", '-?(?:(?:\d+)?\.)?\d+');