Skip to content

Instantly share code, notes, and snippets.

View mehmetkose's full-sized avatar
:electron:
Reacting

Mehmet Kose mehmetkose

:electron:
Reacting
  • Sour Cream LTD
  • Dublin, Ireland
  • 10:10 (UTC +01:00)
  • X @mehmetkose
View GitHub Profile
@mehmetkose
mehmetkose / main.py
Created September 19, 2012 21:29
Linode VPS üzerinde Nginx, Supervisord, Tornado Yapılandırması | Dosyalar
#mehmetkose.org/linode-uzerinde-nginx-supervisord-tornado-yapilandirmasi.html
import tornado.ioloop
from tornado.options import define, options, logging
import tornado.web
define("port", default=8888, help="run on the given port", type=int)
settings = {
"debug": True,
@mehmetkose
mehmetkose / gist:6388375
Created August 30, 2013 10:11
Page Popularity Algorithm
#!/usr/bin/env python
#Mehmet Kose 2012 - Popularity Algorithm
from time import time
simmdii = int(round(time() * 1000))
def rank (time,like,unlike,visit,comment):
millis = int(round(time.time() * 1000))
return ( millis - time ) / ((like*2)-unlike)*(visit+comment)
@mehmetkose
mehmetkose / ws
Created August 30, 2013 10:14
Multiple Websocket Handler in Tornado
class UpdateHandler(tornado.websocket.WebSocketHandler,BaseHandler):
#cache = []
brain = {}
cache_size = 200
listenners = {}
def allow_draft76(self):
# for iOS 5.0 Safari
return True
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import random
kuponsayisi = 40000
kuponlar = []
ii = 0
while ii < kuponsayisi:
cd ~
sudo apt-get update
sudo apt-get install openjdk-7-jre-headless -y
### Check http://www.elasticsearch.org/download/ for latest version of ElasticSearch and replace wget link below
# NEW WAY / EASY WAY
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.7.deb
sudo dpkg -i elasticsearch-0.90.7.deb
@mehmetkose
mehmetkose / iddaa
Created March 5, 2014 19:30
iddaa maç sonucu üreteci.
import random
macsayisi = 3
kuponsayisi = 600
ornekkupon = [[0,0], [0,0], [1, 0], [1, 1]]
def skor_uret():
return random.randint(0,2)
def kupon_uret(macsayisi):

Sublime Text 2 – Useful Shortcuts (PC)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.

Editing

Ctrl+C copy current line (if no selection)
Ctrl+X cut current line (if no selection)
Ctrl+⇧+K delete line
Ctrl+↩ insert line after
Install Ionic to dev android app on ubuntu 14.04
0. Instal ubuntu-14.04-desktop-amd64.iso
sudo apt-get update
sudo apt-get install exfat-fuse exfat-utils
sudo reboot
1. Copy jdk-7u60-linux-x64.tar.gz, apache-ant-1.9.4-bin.tar.gz to /opt and copy adt-bundle-linux-x86_64-20140321.zip to HOME/android
cd /opt
sudo tar zxvf jdk-7u60-linux-x64.tar.gz
import tornado.ioloop
import tornado.web
import logging
import motor
client = motor.MotorClient('mongodb://localhost:27017')
db = client.test_database
class MainHandler(tornado.web.RequestHandler):
@tornado.web.asynchronous
@mehmetkose
mehmetkose / gist:fea7bdce1727df2aa967
Created March 30, 2015 13:44
data from mongo in websocket's open.
class BaseHandler(tornado.web.RequestHandler):
db = motor.MotorClient('mongodb://localhost:27017').mydb
@tornado.gen.coroutine
def get_group_names(self):
user = yield self.db.user.find_one({'_id':ObjectId(self.current_user)})
raise tornado.gen.Return(user['groups'])
class WebSocketHandler(tornado.websocket.WebSocketHandler, BaseHandler):
def __init__(self, *args, **kwargs):