This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CREATE TABLE `index1` ( | |
| `id` int(11) NOT NULL AUTO_INCREMENT, | |
| `lat` DECIMAL(9, 6) NOT NULL, | |
| `lng` DECIMAL(9, 6) NOT NULL, | |
| `ctime` DECIMAL(13, 3) NOT NULL, | |
| `user` int NOT NULL, | |
| PRIMARY KEY (`id`) | |
| ) ENGINE=MyISAM DEFAULT CHARSET=utf8; | |
| desc `index1`;# check the table index1 u create |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use test; | |
| set @er=6366.564864; | |
| set @lat=56.14262; | |
| set @lng=32.605853; | |
| set @dist=20; | |
| #1. | |
| SELECT id,lat,lng,@er*2*ASIN(SQRT(POWER(SIN((@lat - lat)*pi()/180 / 2), 2) + COS(@lat * pi()/180) * COS(lat * pi()/180) * POWER(SIN((@lng - lng) * pi()/180 / 2), 2) )) as dist FROM `unindex1` HAVING dist < @dist ORDER BY dist; | |
| # | |
| #2. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use test | |
| set @er=6366.564864; | |
| set @lat=-80.655719;#set the latitude where to find | |
| set @lng=91.099119; | |
| set @dist=100; #100km set the range 0-100km | |
| set @lat_length=20003.93/180;#lat length | |
| set @lat_left=@lat-(@dist/@lat_length); | |
| set @lat_right=@lat+(@dist/@lat_length); | |
| set @lng_left=@lng-@dist/abs(cos(radians(@lat))*@lat_length); | |
| set @lng_right=@lng+@dist/abs(cos(radians(@lat))*@lat_length); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # -*- coding:utf-8 -*- | |
| # | |
| # Author : Rhapsodyzs | |
| # E-mail : zs1213yh@gmail.com | |
| # Date : 14/01/08 11:01:17 | |
| # Desc : | |
| # | |
| import MySQLdb | |
| import random |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/env python | |
| import tornado.httpserver | |
| import tornado.ioloop | |
| import tornado.options | |
| import tornado.web | |
| import tornado.httpclient | |
| import tornado.gen | |
| from tornado.concurrent import run_on_executor | |
| #if < python3.2 you need do `sudo pip install futures` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import unittest, os, os.path, sys, urllib | |
| import tornado.database | |
| import tornado.options | |
| from tornado.options import options | |
| from tornado.testing import AsyncHTTPTestCase | |
| # add application root to sys.path | |
| APP_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) | |
| sys.path.append(os.path.join(APP_ROOT, '..')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var http = require('http'); | |
| var mongodb = require('mongodb'); | |
| var poolModule = require('generic-pool'); | |
| var pool = poolModule.Pool({ | |
| name: 'mongodb', | |
| create: function(callback) { | |
| mongodb.MongoClient.connect('mongodb://localhost/test', {server: {poolSize: 1}}, function(err, db) { | |
| callback(err, db); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /usr/bin/env python | |
| # Released to the public domain, by Tim Peters, 03 October 2000. | |
| """reindent [-d][-r][-v] [ path ... ] | |
| -d (--dryrun) Dry run. Analyze, but don't make any changes to, files. | |
| -r (--recurse) Recurse. Search for all .py files in subdirectories too. | |
| -n (--nobackup) No backup. Does not make a ".bak" file before reindenting. | |
| -v (--verbose) Verbose. Print informative msgs; else no output. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin | |
| export PATH | |
| # Check if user is root | |
| if [ $(id -u) != "0" ]; then | |
| printf "Error: You must be root to run this script!\n" | |
| exit 1 | |
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def check_palin(lister): | |
| if len(lister) <= 1 : | |
| print 'True' | |
| return True | |
| else: | |
| if lister[0] == lister[-1]: | |
| lister.pop() | |
| del lister[0] | |
| check_palin(lister) | |
| else: |