This file contains hidden or 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
| """Use it like this: main('192.168.1.0/24')""" | |
| IPV4_MIN = 0 | |
| IPV4_MAX = 0xFFFFFFFF | |
| def not_network(ipv4_address, ipv4_netmask): | |
| assert IPV4_MIN <= ipv4_address <= IPV4_MAX | |
| assert IPV4_MIN <= ipv4_netmask <= IPV4_MAX | |
| def hostmask_netmask(m): |
This file contains hidden or 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
| private static boolean overlap(final String net1, final String net2) | |
| { | |
| SubnetInfo subnet1 = new SubnetUtils(net1).getInfo(); | |
| SubnetInfo subnet2 = new SubnetUtils(net2).getInfo(); | |
| int mask1 = subnet1.asInteger(subnet1.getNetmask()); | |
| int mask2 = subnet2.asInteger(subnet2.getNetmask()); | |
| int maskToUse = mask1 < mask2 ? mask1 : mask2; | |
| int addr1 = subnet1.asInteger(subnet1.getAddress()) & maskToUse; |
This file contains hidden or 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 os | |
| # Automatically set the __all__ variable with all | |
| # the available plugins. | |
| plugin_dir = "plugins" | |
| __all__ = [] | |
| for filename in os.listdir(plugin_dir): | |
| filename = plugin_dir + "/" + filename |
This file contains hidden or 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
| go test -run=. -bench=. -benchtime=5s -count 5 -benchmem -cpuprofile=cpu.out -memprofile=mem.out -trace=trace.out ./package | tee bench.txt | |
| go tool pprof -http :8080 cpu.out | |
| go tool pprof -http :8081 mem.out | |
| go tool trace trace.out | |
| go tool pprof $FILENAME.test cpu.out | |
| # (pprof) list <func name> | |
| # go get -u golang.org/x/perf/cmd/benchstat | |
| benchstat bench.txt |
This file contains hidden or 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 | |
| import sys | |
| import NZA | |
| def print_volumes_by_pool(pool): | |
| volumes = NZA.nms.zvol.get_names_by_prop('volume_name', pool, '') | |
| for volume in volumes: | |
| name = NZA.nms.zvol.get_child_prop(volume, 'name') | |
| size = NZA.nms.zvol.get_child_prop(volume, 'size') |
This file contains hidden or 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 | |
| import sys | |
| import NZA | |
| def delete_volumes_in_pool(pool): | |
| print "Removing volumes in pool %s..." % pool | |
| volumes = NZA.nms.zvol.get_names_by_prop('volume_name', pool, '') | |
| for volume in volumes: | |
| try: |
This file contains hidden or 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 | |
| # | |
| # This is an example iptables script to configure | |
| # a firewall for a personal machine. | |
| # | |
| # It filters bad packets and bans the desired IP | |
| # addresses, and allows remote connections to a | |
| # controlled set of ports. | |
| # |
This file contains hidden or 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 flask import Flask, redirect, request, session, url_for | |
| from functools import wraps | |
| from requests_oauthlib import OAuth1Session | |
| import json | |
| import os | |
| # Application tokens (returned when the user registers an app) |
This file contains hidden or 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 org.springframework.context.ApplicationContext; | |
| import org.springframework.context.ApplicationContextAware; | |
| import org.springframework.stereotype.Service; | |
| @Service | |
| public final class BeanLoader implements ApplicationContextAware | |
| { | |
| private static BeanLoader instance; | |
| private ApplicationContext applicationContext; |
This file contains hidden or 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 | |
| # Basic QoS script that uses OpenDPI (http://www.opendpi.org/) | |
| # Netfilter wrapper to identify packets by the protocol. | |
| # | |
| # This script enqueues packets in three queues, each one | |
| # with a different priority: | |
| # | |
| # The first queue has the higher priority and gets the TCP SYN | |
| # packets, ACKs, ICMPs and packets with Minimize-Delay TOS. |
NewerOlder