Skip to content

Instantly share code, notes, and snippets.

View muratcorlu's full-sized avatar

Murat Çorlu muratcorlu

View GitHub Profile
@muratcorlu
muratcorlu / install.sh
Last active April 14, 2016 09:47
Prerender Installation to Debian with Nginx Proxy and Caching
# Prerender kurulumu
sudo locale-gen UTF-8
sudo apt-get update
sudo apt-get install -y curl
curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
sudo apt-get install -y nodejs build-essential libfontconfig nginx-extras
sudo npm install -g phantomjs
sudo npm install -g prerender
sudo npm install -g pm2
@muratcorlu
muratcorlu / date_diff.js
Created December 18, 2013 22:01
Date difference with javascript
var date1 = new Date(2010, 6, 17);
var date2 = new Date(2013, 12, 18);
var diff = new Date(date2.getTime() - date1.getTime());
// diff is: Thu Jul 05 1973 04:00:00 GMT+0300 (EEST)
console.log(diff.getUTCFullYear() - 1970); // Gives difference as year
// 3
console.log(diff.getUTCMonth()); // Gives month count of difference
// 6
@muratcorlu
muratcorlu / connect-api-mocker.js
Created June 25, 2013 15:24
Connect middleware that creates mockes for rest apis.
var fs = require('fs');
module.exports = function (urlRoot, pathRoot) {
pathRoot = pathRoot.replace(urlRoot, '');
return function(req, res, next){
if (req.url.indexOf(urlRoot) === 0) {
// Ignore querystrings
url = req.url.split('?')[0];
@muratcorlu
muratcorlu / detay.html
Created October 24, 2015 18:29
Synaps Seçim sistemi embed kodları
<div synaps-secim></div>
SearchQuerySet().filter(user__iexact="murat").filter(content__startswith=request.GET.get('q'))[:10]
@muratcorlu
muratcorlu / jquery_disqus_lazyload.js
Created April 3, 2012 07:38
Load disqus comments when visitor scroll down page to comments
/**
* Load disqus comments when visitor scroll down page to comments
*
* Usage:
* Add a div with id "disqus_thread" and data attributes for every disqus parameter:
*
* <div id="disqus_thread" data-disqus-shortname="username" data-disqus-url="http://example.com/post/post-name/"></div>
*
* @author: Murat Corlu
* @link: https://gist.github.com/gists/2290198
@muratcorlu
muratcorlu / json.py
Created January 26, 2012 17:39
Python command line script to JSON parse
#!/usr/bin python
"""
requires simplejson module (https://github.com/simplejson/simplejson)
Usage example:
tail -f /var/log/json.log | grep "muratcorlu.com" | python json.py log.date log.url
"2011.12.14 14:21" "http://muratcorlu.com/post/archieve/"
"2011.12.14 14:29" "http://muratcorlu.com/"
@muratcorlu
muratcorlu / flashEvent.js
Created October 19, 2010 14:14
Fire events that can listen by Javascript from Flash
/*
* Flash runs fireFlashEvent function with a event name parameter and
* several optional parameters. Javascript can listen these events by
* binding with addFlashEventListener function.
*
* Requires jQuery
*/
// Global Document object for caching $(document) selector
Document = null;
@muratcorlu
muratcorlu / simpletimer.js
Created October 10, 2010 03:24
Simple timer with javascript
var timer = {
started: 0,
end: 0,
now: function(){ return new Date(); },
start: function(){ return this.started = this.now(); },
since: function(){ this.end = this.now(); return this.now()-this.started; }
}
// Usage:
@muratcorlu
muratcorlu / jsonencode.php
Created September 29, 2010 13:33
JSON Encoder
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="tr" lang="tr">
<head>
<title> JSON Encoder </title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<?php
if($_POST) {
$unicodes = array('\u015f', '\u015e', '\u011f', '\u011e', '\u0130', '\u0131', '\u00fc', '\u00dc', '\u00d6', '\u00f6', '\u00c7', '\u00e7');