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
prices = {'apple': 0.40, 'banana': 0.50} | |
my_purchase = { | |
'apple': 1, | |
'banana': 6} | |
grocery_bill = sum(prices[fruit] * my_purchase[fruit] | |
for fruit in my_purchase) | |
print 'I owe the grocer $%.2f' % grocery_bill |
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
#! /usr/bin/env python | |
from scapy import * | |
def arp_monitor_callback(pkt): | |
if ARP in pkt and pkt[ARP].op in (1,2): #who-has or is-at | |
return pkt.sprintf("%ARP.hwsrc% %ARP.psrc%") | |
sniff(prn=arp_monitor_callback, filter="arp", store=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
/* | |
* Copyright (c) 2009 Gaute Hope <[email protected]> | |
* Distributed under the terms of the GNU General Public Licence v2 | |
* | |
* Waits for change of ~/.plan | |
* | |
*/ | |
# include <iostream> | |
# include <sys/inotify.h> |
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
from itty import * | |
import Queue | |
import threading | |
queue = Queue.Queue() | |
message_count = 0 | |
message_count_lock = threading.Lock() | |
finish_queue = False | |
finish_queue_lock = threading.Lock() | |
wait_for_it = threading.Event() |
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
// TARGET.pid のファイルを削除で終了 | |
if ( WScript.Count == 0 ) { | |
WScript.Echo("対象ファイルをD&Dしてください"); | |
WScript.Quit(); | |
} | |
var TARGET = WScript.Arguments(0); | |
// バックアップするかチェックする間隔(ミリ秒) | |
var PERIOD = 60 * 1000; | |
var AutoBackup = { |
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
from scrapy import log | |
from scrapy.contrib.spiders import CrawlSpider, Rule | |
from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor | |
from scrapy.xpath.selector import HtmlXPathSelector | |
from scrapy.item import ScrapedItem | |
def safecn(i): | |
try: | |
return unichr(int(i)) | |
except: |
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
#include <stdio.h> | |
#include <stdbool.h> | |
#include <stdlib.h> | |
#include <stdarg.h> | |
#include <string.h> | |
#define NOINLINE __attribute__((noinline)) | |
const size_t CONTINUATION_STACK_SIZE = 8192; |
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
#include <stdio.h> | |
#include <stdbool.h> | |
#include <stdlib.h> | |
#include <stdarg.h> | |
#define NOINLINE __attribute__((noinline)) | |
typedef unsigned char byte; | |
typedef struct Continuation { |
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
#include <stdio.h> | |
#include <stdbool.h> | |
#include <stdlib.h> | |
#include <stdarg.h> | |
#include <string.h> | |
#define NOINLINE __attribute__((noinline)) | |
const size_t CONTINUATION_STACK_SIZE = 8192; |
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
//Derived from http://people.mozilla.org/~dietrich/ubiquity.js | |
var sources = ["history", "bookmarks", "starred", "tagged", "session"]; | |
var sorts = ["freshness", "age", "frequency", "infrequency", "recency", "staleness"] | |
var noun_type_places_datasource = new CmdUtils.NounType("datasource", sources); | |
var noun_type_places_sorts = new CmdUtils.NounType(" sort attribute", sorts); | |
var debugMode = true; | |