Skip to content

Instantly share code, notes, and snippets.

🙌

Fatih Acet fatihacet

🙌
View GitHub Profile
@fatihacet
fatihacet / simple-aop.js
Created Apr 14, 2011 — forked from anonymous/gist:666343
simple aop in javascript
View simple-aop.js
var fio = {};
fio.deneme = function(xxx){
alert(xxx);
}
var oldfunction = fio.deneme;
fio.deneme = function(){
@fatihacet
fatihacet / isValidURL.js
Created Oct 11, 2011
URL validator regex
View isValidURL.js
function isUrl(s) {
var regexp = /((http|https):\/\/)?[A-Za-z0-9\.-]{3,}\.[A-Za-z]{2}/;
return s.indexOf(' ') < 0 && regexp.test(s);
}
isUrl('http://fatihacet.com.tr')
@fatihacet
fatihacet / getdomcount.js
Created Oct 14, 2011 — forked from dashersw/getdomcount.js
get dom element counts by tag name with jquery
View getdomcount.js
var tags = {};
$("*").each(function(item) {
if (!tags[this.tagName]) {
tags[this.tagName] = 0;
}
tags[this.tagName]++;
});
console.dir(tags);
View yslow.html
<!DOCTYPE>
<html>
<head>
<title>YSlow Notes</title>
<style type="text/css">
body { margin: 0; padding: 0; background: #F6F6F6; font-size: 13px; color: #333; font-family: Arial; }
h2 { margin: 0; padding-left: 15px; font-size: 18px; border-bottom: 1px dotted #5F5F5F; color: #872929; }
p { margin: 0; padding: 5px 15px 30px; }
</style>
</head>
@fatihacet
fatihacet / fire-rainbow.css
Created Oct 15, 2011
FireRainbow color scheme
View fire-rainbow.css
.panelNode-script { background-color: #EFEFE7; color: black; cursor: default; font-family: Monaco,Monospace,Courier New !important; font-size: 12px; }
.sourceRow.hovered { background-color: #EEEEEE; }
.sourceLine { background: none no-repeat scroll 2px 0 #EEEEEE; border-bottom: 1px solid #EEEEEE; border-right: 1px solid #CCCCCC; color: #888888; }
.sourceLine:hover { text-decoration: none; }
.scriptTooltip { background: none repeat scroll 0 0 LightYellow; border: 1px solid #CBE087; color: #000000; }
.sourceRow[exeline="true"] { background-color: lightgoldenrodyellow; outline: 1px solid #D9D9B6; }
.js-comment { color: gray; font-size: 11px; }
.whitespace { color: blue; }
.js-variable { color: #7C3A99; }
.js-punctuation { color: black; }
@fatihacet
fatihacet / jquery.ajax-queue.js
Created Oct 15, 2011
Simple and easy jQuery AJAX queue implementation trying - this is draft version -
View jquery.ajax-queue.js
$.ajaxQueue = [];
var que = $.ajaxQueue;
$.ajaxSetup({
beforeSend: function(){
if (this.queue) {
que.push(this);
}
else {
return true;
@fatihacet
fatihacet / pubsub-simple.js
Created Oct 15, 2011
Simple PubSub implementation with JavaScript - taken from Addy Osmani's design patterns book -
View pubsub-simple.js
var pubsub = {};
(function(q) {
var topics = {}, subUid = -1;
q.subscribe = function(topic, func) {
if (!topics[topic]) {
topics[topic] = [];
}
var token = (++subUid).toString();
topics[topic].push({
token: token,
@fatihacet
fatihacet / code.js
Created Oct 24, 2011
Groups given object by a key
View code.js
var events = data.events;
var date = {};
for (var i = 0, ii = events.length; i < ii; i++) {
if (!date[events[i]['date']]) {
date[events[i]['date']] = [];
};
date[events[i]['date']].push(events[i]);
}
console.log(date);
@fatihacet
fatihacet / code.js
Created Oct 30, 2011
Convert number to nearest 10x digit
View code.js
// Divide by 10 and round it, then multiply by 10.
var x = 136;
console.log(Math.round(x / 10) * 10);
@fatihacet
fatihacet / base-url.js
Created Nov 22, 2011
returns base url from a string url.
View base-url.js
var u = 'www.loremipsum.com';
var p = /^(http:\/\/)?([^\/]+)/i
u.match(p)[2]
// http://www.loremipsum.com -> www.loremipsum.com
// www.loremipsum.com -> www.loremipsum.com
// www.loremipsum.com/dolor/sit/amet -> www.loremipsum.com
You can’t perform that action at this time.