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 / 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) {
@taufik-nurrohman
taufik-nurrohman / README.md
Created January 23, 2016 15:16 — forked from dciccale/README.md
Cross-browser triggerEvent function done with 127 bytes of JavaScript

triggerEvent

Cross-browser function to trigger DOM events.

@taufik-nurrohman
taufik-nurrohman / extract-html-attributes.php
Created January 17, 2015 00:45
Regex to Extract HTML Attributes
<?php
/*! Based on <https://github.com/mecha-cms/cms/blob/master/system/kernel/converter.php> */
function extract_html_attributes($input) {
if( ! preg_match('#^(<)([a-z0-9\-._:]+)((\s)+(.*?))?((>)([\s\S]*?)((<)\/\2(>))|(\s)*\/?(>))$#im', $input, $matches)) return false;
$matches[5] = preg_replace('#(^|(\s)+)([a-z0-9\-]+)(=)(")(")#i', '$1$2$3$4$5<attr:value>$6', $matches[5]);
$results = array(
'element' => $matches[2],
'attributes' => null,
'content' => isset($matches[8]) && $matches[9] == '</' . $matches[2] . '>' ? $matches[8] : null
@taufik-nurrohman
taufik-nurrohman / keyboard-event._key.js
Last active September 1, 2016 04:22
Just another polyfill for that `KeyboardEvent.key` property (lower-cased)
(function() {
// Key maps for the deprecated `KeyboardEvent.keyCode`
var keys = {
// control
8: 'backspace',
9: 'tab',
13: 'enter',
16: 'shift',
17: 'control',
@taufik-nurrohman
taufik-nurrohman / gist:04c1b879f7423027615c4f45e2f716df
Created September 4, 2016 08:53 — forked from hiddentao/gist:5946053
Generate overridable getters and setters in Javascript
// see blog post: http://www.hiddentao.com/archives/2013/07/08/generate-overridable-getters-and-setters-in-javascript/
Function.prototype.generateProperty = function(name, options) {
// internal member variable name
var privateName = '__' + name;
options = options || {};
options.get = ('undefined' === typeof options.get ? true : options.get );
options.set = ('undefined' === typeof options.set ? true : options.set );
// pre-initialise the internal variable?
@taufik-nurrohman
taufik-nurrohman / slugify.php
Created January 14, 2015 01:00
Slug URL Generator
<?php
function do_slug($text, $lower = true, $strip_underscores_and_dots = true, $connector = '-') {
$text_accents = array(
// Numeric characters
'¹' => 1,
'²' => 2,
'³' => 3,
// Latin
'°' => 0,
@taufik-nurrohman
taufik-nurrohman / foobar.md
Created January 16, 2017 16:41 — forked from t32k/foobar.md
foo, bar, baz, qux, quux, corge, grault, garply, waldo, fred, plugh, xyzzy, thud
@taufik-nurrohman
taufik-nurrohman / compose-function.js
Last active March 27, 2017 04:17
Compose Function
// Reply for <https://medium.com/@Dewey92/cleaner-code-dengan-function-composition-137f30d928e4>
function compose() {
var i, arg = arguments,
output = arg.pop();
for (i = 0; i < arg.length; ++i) {
if (typeof arg[i] !== "function") continue;
output = arg[i](output);
}
return output;