This file contains 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
module DB where | |
import Control.Concurrent.MVar | |
import Control.Concurrent (forkIO) | |
import Control.Monad (forever, replicateM) | |
import Database.PostgreSQL.Simple | |
type QueryFunc a = Connection -> IO a | |
type DBActor = MVar (QueryFunc ()) |
This file contains 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
module Actors where | |
import Control.Concurrent.MVar | |
import Control.Concurrent (forkIO) | |
import Control.Monad (forever, replicateM) | |
type PoolQuery a b = a -> IO b | |
type PoolActor a = MVar (PoolQuery a ()) |
This file contains 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 Control.Applicative | |
import Control.Monad | |
import Data.Aeson | |
import Data.Maybe | |
import qualified Data.ByteString.Lazy.Char8 as LC8 | |
import qualified Data.Map as Map | |
import Network.HTTP.Conduit | |
import Text.XML.HXT.XPath.Arrows (getXPathTrees) | |
import Text.XML.HXT.Core |
This file contains 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
{"Bed Capacity":{"Kidney Dialysis":"0","ICCU":"0","Gynecology":"2","Cardiology":"2","Hematology":"0","PICU":"0","Chemotherapy":"0","ICU":"4","Radiotherapy":"0","Neonatal":"4","Urology":"5","Pediatric":"0","Surgery":"35","Burns":"0","Internal Medicine":"16","Nephrology":"2","Operation Rooms":"3","Ophthalmology":"0","Chest":"0","ENT":"0","Total Beds":"79","Orthopedic":"5","Maternity":"4","Psychiatric":"0","Oncology":"0","Day Care":"0","IMU":"0"},"Activity Statistics in 2007":{"Occupancy Days/ Patient":"4","Infant Mortality":"0","Discharges":"3996","Out Patient Visits":"27238","Total Mortality":"0","Admissions":"4022","Hospitalization Days":"15003","Car Accident":"0","Emergency Room Visits":"1018","C- Section":"0","Normal Delivery":"1","Work Accident":"0","Major Operations":"476","Still Birth":"0","Bed Occupancy Rate":"1","Minor Operations":"2396","Maternal Mortality":"0"},"Human Resources":{"X-Ray Technician":"3","Specialized Doctor":"10","Dentists":"0","Physiotherapiests":"3","Administrative workers":"38","Gen |
This file contains 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
{ | |
"Bed Capacity": { | |
"Kidney Dialysis": "7", | |
"ICCU": "0", | |
"Gynecology": "0", | |
"Cardiology": "45", | |
"Hematology": "14", | |
"PICU": "4", | |
"Chemotherapy": "0", | |
"ICU": "0", |
This file contains 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
myReadPixels:: Int -> Int -> Int -> Int -> IO [Pixel] | |
myReadPixels x y w h = do | |
let arraySize = w * h * 4 | |
array <- mallocForeignPtrArray arraySize :: IO (ForeignPtr Word8) | |
let pos = Position (fromIntegral x) (fromIntegral y) | |
withForeignPtr array $ \ptr -> do | |
-- fromIntegral is needed because Position and Size store GLints not Ints | |
readPixels pos | |
(Size (fromIntegral w) (fromIntegral h)) | |
(PixelData RGBA UnsignedByte ptr) |
This file contains 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 nodes = document.querySelectorAll(".js-setLabelWidth"); | |
var elementWidths = []; | |
var widths = nodes.map(function(node) { | |
var width = getComputedStyle(node)["width"]; | |
return parseInt(width, 10); | |
}); | |
var maxWidth = (widths.reduce(Math.max, 0) + 1) / 16; |
This file contains 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 tornado.web | |
from multiprocessing import Pipe | |
from _multiprocessing import Connection | |
class MultiprocessApplication(tornado.web.Application): | |
def __init__(self, *args, **kwargs): | |
self._conn_main_recv, self._conn_main_send = Pipe() | |
tornado.web.Application.__init__(self, *args, **kwargs) | |
def setup(self, ioloop, is_main_process): |
This file contains 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 os | |
import tornado.httpserver | |
import tornado.ioloop | |
import tornado.web | |
from multiprocessing import Pipe | |
class HelloHandler(tornado.web.RequestHandler): | |
def get(self): | |
self.write(self.application.communicate('hello world')) |
This file contains 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
> python -m cProfile -s time client.py | |
3806027 function calls (3805761 primitive calls) in 39.336 CPU seconds | |
Ordered by: internal time | |
ncalls tottime percall cumtime percall filename:lineno(function) | |
100000 21.909 0.000 37.780 0.000 {method 'recv_multipart' of 'zmq._zmq.Socket' objects} | |
900002 8.073 0.000 8.920 0.000 threading.py:179(__init__) | |
900002 3.256 0.000 12.176 0.000 threading.py:174(Condition) | |
300000 3.061 0.000 15.871 0.000 Queue.py:22(__init__) |
OlderNewer