Skip to content

Instantly share code, notes, and snippets.

View anova's full-sized avatar

Necat Bolpaça anova

View GitHub Profile
@anova
anova / pdf-download.php
Created February 14, 2014 09:35
Force browser to download a pdf file.
<?php
if(!isset($_GET['f'])) die('You must specify which files to download');
$f = $_GET['f'];
if(!endsWith($f, '.pdf')) die('File MUST have .pdf extension (' . $f . ')');
$f_array = explode('/', $f);
$file_name = $f_array[count($f_array) - 1];
$file_url = $f;
header('Content-Type: application/octet-stream');
@anova
anova / tacirnet-universal-analytics-conversion.html
Created March 5, 2014 07:09
isogram, universal analytics, e-commerce tracking
<!-- Çok önemli 1. adım: Analytics üzerinden site mutlaka e-ticaret sitesi olarak ayarlanmalıdır. -->
<!-- Çok önemli 2. adım: i,s,o,g,r,a,m kodundan sonra e-commerce plugin çağrılmalıdır. -->
<script>ga('require', 'ecommerce', 'ecommerce.js');</script>
<!-- Sipariş conversion kodu -->
<script>
ga('ecommerce:addTransaction', {
'id': '{{ siparis.id }}', // Transaction ID. Required.
//*********************************************************************************
@anova
anova / htmlencode_tr.php
Created April 30, 2014 13:47
html encode turkish
<?php
//htmlencode turkish
function htmlencode_tr($input) {
return str_replace(
array('ç', 'ğ', 'ı', 'ö', 'ş', 'ü', 'Ç', 'Ğ', 'İ', 'Ö', 'Ş', 'Ü'),
array('&#231;', '&#287;', '&#305;', '&#246;', '&#351;', '&#252;', '&#199;', '&#286;', '&#304;', '&#214;', '&#350;', '&#220;'),
$input);
}
@anova
anova / mssql_row_number_over.sql
Created June 28, 2014 19:40
MSSQL equivalent to MySql s LIMIT
--Thanks to Muharrem Taç - http://www.muharremtac.com
SELECT *
FROM (
SELECT ROW_NUMBER() OVER(ORDER BY UserId ASC) AS RNumber, *
FROM UserDetails
) AS [UserDetails] WHERE RNumber BETWEEN 100 AND 200
@anova
anova / scheduled-banner.html
Created July 25, 2014 11:33
A javascript scheduler for banner publish.
<div class="mainSlides">
<ul>
<li data-start="2014/07/28 04:00" data-end="2014/07/30 23:00"
data-bg-image="/images/banner/2014-07/ramazan-bayrami.jpg" style="display:none;"><a href="#!"></a></li>
</ul>
</div>
<script>
var banners,
date_now,
''' <summary>
''' Finds a Control recursively. Note finds the first match and exists
''' </summary>
''' <param name="ContainerCtl"></param>
''' <param name="IdToFind"></param>
''' <returns></returns>
Public Shared Function FindControlRecursive(Root As Control, Id As String) As Control
If Root.ID = Id Then
Return Root
End If
-- Turkce isimler sozlugu twitter : http://twitter.com/tserpico
CREATE TABLE `isimler` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`isimler` varchar(255) DEFAULT NULL,
`cinsiyet` varchar(255) DEFAULT NULL COMMENT 'erkek : E , kadın : K , uniseks : U',
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
-- ----------------------------
@anova
anova / .htaccess
Created August 9, 2014 08:33
Kriweb helicon test, .htaccess test (in /helicon-test subfolder)
RewriteEngine on
RewriteBase /helicon-test
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . ./helicon-test/index.php [NC,L,NS]
@anova
anova / instagram.php
Created August 9, 2014 09:02
Redirect to instagram who cames from iOS
<?php
//this code uses mobiledetect ( http://mobiledetect.net ) for detect mobile users
include dirname(__FILE__) . '/../mobile-detect/Mobile_Detect.php';
$detect = new Mobile_Detect();
if($detect->isiOS()) {
header('Location: instagram://user?username=instagram');
} else {
header('Location: http://instagram.com/instagram');
}
@anova
anova / mobile-width.js
Last active August 29, 2015 14:06
Learn mobile device width by its orientation.
window.info = function() {
var i = '';
i += 'screen.width =' + screen.width + '\n';
i += 'screen.height =' + screen.height + '\n';
i += 'window.orientation =' + window.orientation + '\n';
i += 'window.getWidth() =' + window.getWidth() + '\n';
alert(i);
};//window.info
window.getWidth = function() {