Skip to content

Instantly share code, notes, and snippets.

😒
Nothing. Just me.

Taufik Nurrohman tovic

😒
Nothing. Just me.
Block or report user

Report or block tovic

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tovic
tovic / index.html
Created Nov 10, 2012
A CodePen by Taufik Nurrohman.
View index.html
<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>
@tovic
tovic / index.html
Created Nov 10, 2012
A CodePen by Taufik Nurrohman. JQuery Slideshow, Like Nivo Slider
View index.html
<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>
View jquery.masonry-0.6.js
(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);
@tovic
tovic / index.html
Created Jan 30, 2013
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.
View index.html
<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>
View gist:6570776
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) {
View curry.php
<?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);
};
}
View php-css-minifier
// http://ideone.com/Q5USEF
<?php
function minify_css($str){
# remove comments first (simplifies the other regex)
$re1 = <<<'EOS'
(?sx)
# quotes
(
View embed
<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>
View gist:6744843c9c798be173a3

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

@tovic
tovic / php-html-css-js-minifier.php
Last active May 29, 2019
PHP Function to Minify HTML, CSS and JavaScript
View php-html-css-js-minifier.php
<?php
// Based on <https://github.com/mecha-cms/extend.minify>
define('MINIFY_STRING', '"(?:[^"\\\]|\\\.)*"|\'(?:[^\'\\\]|\\\.)*\'|`(?:[^`\\\]|\\\.)*`');
define('MINIFY_COMMENT_CSS', '/\*[\s\S]*?\*/');
define('MINIFY_COMMENT_HTML', '<!\-{2}[\s\S]*?\-{2}>');
define('MINIFY_COMMENT_JS', '//[^\n]*');
define('MINIFY_PATTERN_JS', '/[^\n]+?/[gimuy]*');
define('MINIFY_HTML', '<[!/]?[a-zA-Z\d:.-]+[\s\S]*?>');
You can’t perform that action at this time.