Get Homebrew installed on your mac if you don't already have it
Install highlight. "brew install highlight". (This brings down Lua and Boost as well)
| NSArray *sortedArray = [array sortedArrayUsingComparator: ^(id obj1, id obj2) { | |
| if ([obj1 integerValue] > [obj2 integerValue]) { | |
| return (NSComparisonResult)NSOrderedDescending; | |
| } | |
| if ([obj1 integerValue] < [obj2 integerValue]) { | |
| return (NSComparisonResult)NSOrderedAscending; | |
| } | |
| return (NSComparisonResult)NSOrderedSame; | |
| }]; |
| #!/usr/bin/python | |
| # -*- coding: utf-8 -*- | |
| from os import path | |
| import subprocess | |
| import time | |
| import sys | |
| def run(filename): | |
| """ Run Subprocess scripts and control them """ |
| #! /usr/bin/env python | |
| from os import fork, chdir, setsid, umask | |
| from sys import exit | |
| def main(): | |
| while 1: | |
| #main daemon process loop | |
| # Dual fork hack to make process run as a daemon |
Get Homebrew installed on your mac if you don't already have it
Install highlight. "brew install highlight". (This brings down Lua and Boost as well)
| <?php | |
| # please use php -f input.php < input00.txt > output00.txt | |
| $stdin = fopen('php://stdin', 'r'); | |
| $str = trim(fread($stdin, 1000)); | |
| fclose($stdin); | |
| $total = strlen($str); | |
| $count = 0; | |
| $end = $start = 0; |
| require_once __DIR__ . '/../vendor/autoload.php'; | |
| use Symfony\Component\EventDispatcher\EventDispatcher; | |
| use Symfony\Component\EventDispatcher\Event; | |
| $dispatcher = new EventDispatcher(); | |
| $dispatcher->addListener('event_name', function(Event $event) { | |
| echo $event->getName(), ' Done', "\n"; | |
| }); | |
| $dispatcher->dispatch('event_name'); |
| import os | |
| from scrapy.dupefilter import RFPDupeFilter | |
| from scrapy.utils.request import request_fingerprint | |
| class CustomFilter(RFPDupeFilter): | |
| """A dupe filter that considers specific ids in the url""" | |
| def __getid(self, url): | |
| mm = url.split("&refer")[0] #or something like that |
| # http://www.rabbitmq.com/tutorials/tutorial-two-python.html | |
| import sys, time, json, logging | |
| import pika | |
| hostname = 'localhost' | |
| logging.getLogger('pika').setLevel(logging.ERROR) | |
| class RabbitMQ(object): | |
| def __init__(self, hostname, queue, exchange = ''): | |
| self.hostname = hostname |
| Schema.virtual('id').get(function(){ | |
| return this._id.toHexString(); | |
| }); | |
| Schema.set('toJSON', { | |
| virtuals: true | |
| }); | |
| // or |