Skip to content

Instantly share code, notes, and snippets.

View TarasMartynyuk's full-sized avatar

Taras Martyniuk TarasMartynyuk

View GitHub Profile
# -*- encoding: utf-8 -*-
# Author: Epix
#
# Ban Xunlei IP for deluge
# This script will check deluge connected peers per 30 seconds.
# When an IP with UA in `BAN_PATTERNS` is found, the IP will be added to `BLOCK_LIST_FILE`.
# However if the IP is uploading or reporting 100% progress, it will say "WTF?"
import logging
function Add-EnvPath {
param(
[Parameter(Mandatory=$true)]
[string] $Path,
[ValidateSet('Machine', 'User', 'Session')]
[string] $Container = 'Session'
)
if ($Container -ne 'Session') {
@paniag
paniag / lab3.hs
Last active October 14, 2018 20:51
Caltech CS 11 Haskell Lab 3
data AbstractInteger = Zero | Succ AbstractInteger | Pred AbstractInteger
deriving (Eq, Show)
instance Ord AbstractInteger where
-- compare :: AbstractInteger -> AbstractInteger -> Ordering
compare (Pred x) (Pred y) = compare x y
compare (Pred _) Zero = LT
compare (Pred _) (Succ _) = LT
compare Zero (Pred _) = GT
compare Zero Zero = EQ
# function processes each sub-directory and then adds each source file in directory
# each function should cascade back upward in setting variables so that the bottom directory
# adds its source first, and then the level above it adds its source and passes both up, and so on...
function( recursively_include_src which_directory return_variable )
if( ${return_variable} STREQUAL "headers" )
set( file_extension ".h" )
else( ${return_variable} STREQUAL "headers" )
set( file_extension ".c" )
endif( ${return_variable} STREQUAL "headers" )