Skip to content

Instantly share code, notes, and snippets.

Avatar

Murat Çorlu muratcorlu

View GitHub Profile
@muratcorlu
muratcorlu / README.md
Created Feb 9, 2020
Node Simple Logger
View README.md

Simple logging utility for NodeJS v8+.

const { warn } = require('./logger');

warn('Something');

You can set log level via LOG_LEVEL env variable.

@muratcorlu
muratcorlu / gamespark-realtime.ts
Last active Oct 11, 2018
GameSpark SDK for TypeScript (for using with NativeScript)
View gamespark-realtime.ts
const OpCodes = {
LOGIN_RESULT: -1,
PING_RESULT: -3,
UDP_CONNECT_MESSAGE: -5,
PLAYER_READY_MESSAGE: -7,
PLAYER_CONNECT_MESSAGE: -101,
PLAYER_DISCONNECT_MESSAGE: -103,
}
export class Connection {
@muratcorlu
muratcorlu / nginx.conf
Created Nov 3, 2017
Serve static websites by dynamically mapping domain names and folders with nginx
View nginx.conf
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/${host}/public;
index index.html;
server_name _;
gzip on;
@muratcorlu
muratcorlu / install.sh
Last active Apr 14, 2016
Prerender Installation to Debian with Nginx Proxy and Caching
View install.sh
# 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 / detay.html
Created Oct 24, 2015
Synaps Seçim sistemi embed kodları
View detay.html
<div synaps-secim></div>
View elevatorsaga.js
{
init: function(elevators, floors) {
var upWaiters = {},
downWaiters = {},
idleElevators = [],
floorCount = floors.length,
arrayUnique = function(a) {
return a.reduce(function(p, c) {
if (p.indexOf(c) < 0) p.push(c);
return p;
@muratcorlu
muratcorlu / restview.py
Created Dec 24, 2014
Simple Django RestView view class
View restview.py
from django.http import HttpResponse, JsonResponse, HttpResponseForbidden, HttpResponseNotAllowed, HttpResponseNotFound
from django.forms.models import model_to_dict
from django.db.models import Model
from django.db.models.query import QuerySet
from functools import wraps
from django.utils.decorators import available_attrs
from django.core import serializers
class PermissionError(Exception):
pass
@muratcorlu
muratcorlu / README.md
Last active Dec 11, 2017
Django Multisite User Model
View README.md

This code is a sample for a question on Stackoverflow about making multisite user models with Django 1.7.

Usage:

Add these lines to your settings file:

AUTH_USER_MODEL='s1.Member'
SITE_ID = 1
AUTHENTICATION_BACKENDS = ( 'MyApp.MyModule.MyModelBackend',)
@muratcorlu
muratcorlu / similarity_score.py
Created Apr 6, 2014
Get similarity score of two words with python
View similarity_score.py
def get_score(word1, word2):
shared_chars = [char for char in word1.lower() if char in word2.lower()]
return len(shared_chars)
# Usage
get_score('murat', 'burak')
# > 3
@muratcorlu
muratcorlu / ng-incomplete-confirmation.js
Created Feb 19, 2014
Sayfada yarım kalmış bir form varken sayfadan çıkılmak istendiğinde uyarı vermeye yarayan AngularJS directive'i
View ng-incomplete-confirmation.js
/**
* @ngdoc directive
* @name safe.directive:incomplete-confirmation
*
* @element ANY
*
* @description
*
* `name` attribute'u olan bütün form elementlerinde çalışarak
* üzerinde değişiklik yapılmış ancak kaydedilmemiş bir form olduğunda