Skip to content

Instantly share code, notes, and snippets.

import sys
import socket
def write_to_log(car):
try:
with open('solver.txt', 'a+') as f:
f.write("-----------\n")
f.write("Moves: %s\n" % car.total_moves)
f.write(car.all_data_received)
f.write("-----------\n")
import sys
import socket
sample_map = """
|-----|
| T |
| P |
| |
| c|
|~ Z|
import random
words = [ "best practices", "industry standard", "data retention", "common carrier",
"national security", "due diligence", "cyber-space", "Awareness",
"abuse of human rights", "lawful intercept", "censorship",
"ecosystem", "Digital Human Rights", "APT", "Transparency", "Open Data",
"Security Language", "Militarization of Cyberspace", "Big Data",
"E-Democracy", "Cyber Security", "Terrorism", "Anonymity", "Cyber Espionage",
"Hacktivism", "The Cloud", "Internet of Things", "Internet Policy", "Trolling",
"Cyber War", "Cyber Weapon", "Rule of Law", "Internet kill switch",
"Digital Divide", "Third World", "Internet Freedom", "Cyber 9/11",
@hellais
hellais / traceroute
Created May 21, 2013 13:04
traceroute
import sys
import requests
import lxml.html
ip = sys.argv[1]
r = requests.get("http://lg.ring.nlnog.net/traceroute/lg01/ipv4?q=" + ip)
root = lxml.html.fromstring(r.text)
result = root.cssselect("pre")[0]
print lxml.html.fromstring(lxml.html.tostring(result).replace("<br>", "\n")).text_content()
import os
from zope.interface import implements
from twisted.internet import abstract, interfaces, reactor, fdesc
class NamedPipeReader(abstract.FileDescriptor):
def __init__(self, file_name, reactor=None):
abstract.FileDescriptor.__init__(self, reactor=reactor)
self.file_name = file_name
@hellais
hellais / foo.js
Last active December 12, 2015 03:49
it("should fail if an attribute is missing inside the provided Context (POST, 406)", function(done){
var test = clone(dummyContext),
idx = 0,
doneRequest = function() {
if (idx == args.length) done()
};
args.forEach(function (arg) {
idx += 1;
httpo://4caair3hubdudppc.onion
@hellais
hellais / gist:4552537
Last active March 9, 2024 13:34
Clear the logs of the all the files you downloaded in OSX (ref: www.tuaw.com/2012/02/14/mac-os-xs-quarantineevents-keeps-a-log-of-all-your-downloads/)
# To delete all the currently stored files
sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'delete from LSQuarantineEvent where LSQuarantineEventIdentifier like "%%";'
# To never store such information you can sym link it to dev null
ln -s /dev/null ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV2
from twisted.trial import unittest
from twisted.internet import defer
from storm.twisted.transact import transact, Transactor
from storm.twisted.testing import FakeThreadPool
class Antani(object):
@transact
def antani(self):
from twisted.trial import unittest
from storm.twisted.transact import transact, Transactor
from storm.twisted.testing import FakeThreadPool
class Antani(object):
@transact
def antani(self):
return "foobar"