Skip to content

Instantly share code, notes, and snippets.

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

Mehmet Kose mehmetkose

:electron:
Reacting
View GitHub Profile
@mehmetkose
mehmetkose / s3.py
Last active August 29, 2015 14:18 — forked from taylanpince/s3.py
import hashlib, hmac, mimetypes, os, time
from base64 import b64encode, b64decode
from calendar import timegm
from datetime import datetime
from email.utils import formatdate
from urllib import quote
from tornado.gen import coroutine, Return
from tornado.httpclient import AsyncHTTPClient, HTTPError
@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):
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
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

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
@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):
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
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import random
kuponsayisi = 40000
kuponlar = []
ii = 0
while ii < kuponsayisi:
@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
@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)