Skip to content

Instantly share code, notes, and snippets.

View nelix's full-sized avatar
🎯
Focusing

Nathan Hutchision nelix

🎯
Focusing
View GitHub Profile
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
#! /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)
/*
* 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>
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()
// TARGET.pid のファイルを削除で終了
if ( WScript.Count == 0 ) {
WScript.Echo("対象ファイルをD&Dしてください");
WScript.Quit();
}
var TARGET = WScript.Arguments(0);
// バックアップするかチェックする間隔(ミリ秒)
var PERIOD = 60 * 1000;
var AutoBackup = {
@nelix
nelix / sp.py
Created July 9, 2009 19:23 — forked from qingfeng/sp.py
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:
#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;
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdarg.h>
#define NOINLINE __attribute__((noinline))
typedef unsigned char byte;
typedef struct Continuation {
#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;
//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;