Skip to content

Instantly share code, notes, and snippets.

View anova's full-sized avatar

Necat Bolpaça anova

View GitHub Profile
@anova
anova / javascript-module-immadiate-fn-call.js
Created October 13, 2014 12:15
Javascript module pattern with immediate function call.
//http://www.addyosmani.com/resources/essentialjsdesignpatterns/book/#modulepatternjavascript
var User = (function(){
var _Name, _Surname;
return {
getName : function(){
return _Name;
},
setName : function(value) {
if(value !== undefined){
@anova
anova / mustache-array-render.html
Created October 15, 2014 13:52
How to render array with mustache.js
<script id="child-template" type="text/mustache">
{{#.}}
<div class="child-wrapper">
<div class="child-name-wrapper">{{name}}</div>
<div class="child-birthdate-wrapper">{{birthdate}}</div>
<div class="child-gender-wrapper">{{gender}}</div>
</div>
{{/.}}
</script>
<!--
@anova
anova / isDate.js
Created October 16, 2014 20:22
Useful function for string -> date validation.
;function isDate(value) {
try {
//Change the below values to determine which format of date you wish to check. It is set to dd/mm/yyyy by default.
var YearIndex = 2;
var MonthIndex = 1;
var DayIndex = 0;
value = value.replace(/-/g, "/").replace(/\./g, "/");
var SplitValue = value.split("/");
var OK = true;
@anova
anova / description-bookmarklet.js
Created October 22, 2014 15:22
get active page's description. bookmarklet
javascript:alert(document.querySelector('meta[name="description"]').getAttribute('content'))
@anova
anova / tacirnet-banner-group.html
Created October 24, 2014 12:52
Show banners if banner group name equal with product slug.
{% get_banners as bannerlar %}
{% for banner in bannerlar %}
{% if banner.group == product.name|slugify %}
{% for banner_resim in banner %}
<li class="{% if forloop.counter|divisibleby:2 %}indexbanner-right{% endif %}">
{{ banner.group }}
<a href="{{ banner_resim.url }}">s
<span><img src="{{ media_url }}{{ banner_resim.picture }}" /></span>
</a>
</li>
@anova
anova / window-orientation.js
Last active August 29, 2015 14:11
Get window width by its orientation. (mobile devices)
//Duplicate of : https://gist.github.com/anova/169824fa1f0f458b4ab3
//I forgot, sorry for duplication
@anova
anova / web.config
Created May 7, 2015 13:49
Redirect old domain to new with web.config.
<?xml version="1.0"?>
<configuration>
<system.webServer>
<httpRedirect enabled="true" destination="http://www.example.com" httpResponseStatus="Permanent" />
</system.webServer>
</configuration>
<!doctype html>
<html>
<head>
<title>Screen resolution</title>
<meta name="viewport" content="initial-scale=1.0, width=device-width" />
<style>
html,body{ height: 100%; }
</style>
<script>
function writeScreenResolution(){
@anova
anova / parallel-loading-for-css.js
Created December 12, 2012 23:52
Parallel loading for css files. I need this for font embedding css files.
//this script is inline for avoid extra request.
var fonts = new Array();
fonts.push('css/font/pfsquaresanspromedium.css');
fonts.push('css/font/pfhighwaysanspro-thin.css');
fonts.push('css/font/ubuntu-m.css');
fonts.push('css/font/pfhighwaysanspro-regular-light-italic.css');
fonts.push('css/font/pfsquaresanspro-italic-regular.css');
var head = document.getElementsByTagName('head')[0];
var link = document.getElementsByTagName('link')[0];
for(var i in fonts) {
@anova
anova / webformmailer.php
Created October 29, 2015 08:20
Godaddy's standard webformmailer
<?php
if ( !isset($_SERVER['SPI'])) {
die();
}
if (!isset($_SERVER['DOCUMENT_ROOT'])) {
echo("CRITICAL: we seem to be running outside of the norm.\n");
header("Location: http://".$_SERVER["HTTP_HOST"]."/");
die("CRITICAL: Document root unavailable.\n");