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 boto3 | |
from moto import mock_dynamodb2 | |
# Requires having created a table called "test-abuse" with only | |
# a partition key called 'Key' | |
item = { | |
"Key": "some-irrelevant_key", | |
"SetTypeAttribute": {"SS": set([])}, | |
} |
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 .auth import AccessControlList | |
class GoodBookService(object): | |
def __init__(self, acl_service=AccessControlList()): | |
self.acl = acl_service | |
def create_book(self, user, book): | |
if self.acl.can_create_book(user): | |
# ... code to create book | |
else: |
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 .auth import AccessControlList | |
acl = AccessControlList() | |
class BadBookService(object): | |
def create_book(self, user, book): | |
if acl.can_create_book(user): | |
# ... code to create book | |
else: | |
# ... raise an exception |
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
[Unit] | |
Description=BuckyServer for client metrics RUM | |
After=network.target | |
[Service] | |
PIDFile=/run/bucky-server.pid | |
User=bucky | |
WorkingDirectory=/usr/share/bucky-server | |
ExecStart=/usr/bin/nodejs /usr/share/bucky-server/start.js | |
ExecReload=/bin/kill -s HUP $MAINPID |
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 re | |
from lxml import etree | |
def _escape_latex_control_chars_in(text): | |
text = re.sub('#', r'\#', text) | |
text = re.sub('{', r'\{', text) | |
text = re.sub('}', r'\}', text) | |
text = re.sub('~', r'\\textasciitilde', text) | |
text = re.sub('_', r'\_', text) |
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
class Crawler: | |
def __init__(self, base_url, writer, predicate): | |
""" | |
* base_url is the first URL that would be crawled. | |
* writer is a class that is defined below. It is in-charge of writing | |
to the file system. | |
* predicate is a function with signature predicate(url). It | |
returns true, false and on the basis of that, the decision on | |
whether to download a link or not is taken. """ |
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 config = require('config'); | |
var winstonConfig = require('winston-config'); | |
winstonConfig.fromJson(config.get('logging'), function (err, winston) { | |
// Handle error | |
var SomeService = require('./SomeService'); | |
var logger = winston.loggers.get('protocol'); | |
logger.info('Started application'); |
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 SomeService = require('./SomeService'); | |
var config = require('config'); | |
var winstonConfig = require('winston-config'); | |
winstonConfig.fromJson(config.get('logging'), function (err, winston) { | |
// Handle error | |
var logger = winston.loggers.get('protocol'); | |
logger.info('Started application'); | |
} |
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
#!/bin/bash | |
# USAGE | |
# $> sudo ./sync-hosts-file | |
# Run this command in a directory where you have a hosts.append file | |
# which has hosts in the /etc/hosts style. | |
if [ "$(id -u)" != "0" ]; then | |
echo "You need to be root to execute this script" | |
exit 1 |
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/python | |
import sys | |
import os | |
import subprocess | |
proxies = { | |
'150': 'http://10.3.100.150:8080/', | |
'211': 'http://10.3.100.211:8080/', | |
'212': 'http://10.3.100.212:8080/', |
NewerOlder