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/sh | |
cd /usr/lib/lua/luci/sys/zoneinfo | |
for f in tzdata.lua tzoffset.lua | |
do | |
mv $f $f.bak | |
wget -nv --no-check-certificate https://raw.githubusercontent.com/openwrt/luci/master/modules/luci-base/luasrc/sys/zoneinfo/$f | |
done |
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/env python | |
# -*- coding: utf-8 -*- | |
import sys | |
import subprocess | |
if len(sys.argv) < 2: | |
print("Usage: nmcli-toggle.py connection_id") | |
sys.exit() | |
conn_id = sys.argv[1] | |
active = subprocess.check_output(['nmcli', 'connection', 'show', '--active']) | |
up_down = ('up', 'down')[conn_id in active] |
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
iptables -A INPUT -p udp --sport 53 --match string --algo bm --hex-string '|5cfff164|' -j DROP | |
iptables -A INPUT -p tcp --sport 80 --match string --algo bm --string 'Location: http://lawfilter.ertelecom.ru' -j DROP |
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 UniqMixin: | |
def uniq(self): | |
uniq_list = [] | |
for el in self: | |
if el not in uniq_list: | |
uniq_list.append(el) | |
return self.__class__(uniq_list) | |
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 django import forms | |
from django.utils.safestring import mark_safe | |
from django.core.urlresolvers import reverse | |
class InstanceLinkWidget(forms.Widget): | |
def __init__(self, obj, attrs=None): | |
self.obj = obj | |
super(InstanceLinkWidget, self).__init__(attrs) |
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
def zip_trim(i1, i2, trim='shortest', default=None): | |
''' trim = 'shortest' | 'longest' | 'first' | 'second' | |
''' | |
i1_iter = iter(i1) | |
i2_iter = iter(i2) | |
while True: | |
stop = False | |
try: | |
e1 = next(i1_iter) | |
except StopIteration: |
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
<!-- {templates_dir}/admin/base_site.html --> | |
{% extends "admin/base.html" %} | |
{% load i18n %} | |
{% block title %}{{ title }} | {{ site_title|default:_('Django site admin') }}{% endblock %} | |
{% block branding %} | |
<h1 id="site-name"><a href="{% url 'admin:index' %}">{{ site_header|default:_('Django administration') }}</a></h1> | |
{% endblock %} |
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 -e | |
# Tool to create (and optionally install) Debian packages of i3 with | |
# window icons patch. | |
# Based on i3-gaps-deb by Gerhard A. Dittes | |
# Copyright (C) 2017 Gerhard A. Dittes | |
# | |
# This program is free software: you can redistribute it and/or modify |
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/env python3 | |
from abc import ABC, ABCMeta, abstractmethod | |
from types import FunctionType | |
from collections import OrderedDict | |
# flake8: noqa | |
class UnresolvedFreeVarsError(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
function doMagic(obj) { | |
return new Proxy(obj, { | |
construct: (target, args) => { | |
return doMagic(new target(...args)) | |
}, | |
get: (target, name) => { | |
let prop = Reflect.get(target, name) | |
if (typeof prop === 'function') { | |
return prop.bind(target) | |
} |
OlderNewer