Skip to content

Instantly share code, notes, and snippets.

View g3rhard's full-sized avatar

Kirill Trofimov g3rhard

View GitHub Profile
@g3rhard
g3rhard / easylist.pl
Last active January 13, 2024 17:09
Adding EasyList subscriptions for PiHole project
#!/usr/bin/perl -w
#Source: https://newspaint.wordpress.com/2014/08/18/filtering-easylist-for-hosts-file-style-adblock/
use strict;
my %hosts = ();
while ( <> ) {
if ( $_ =~ m/^\|\|([a-z][a-z0-9-_.]+\.([a-z]{2,3}))\^\s*$/ ) {
$hosts{$1} = 1;
}
@g3rhard
g3rhard / get_user_cn.vbs
Created September 3, 2017 09:41
How to configure GitLab with Active Directory
Set WSHShell = WScript.CreateObject("WScript.Shell")
Set WSHShellUserEnvironment = WSHShell.Environment("User")
DomainName = "DOMAIN"
User = "USER"
SET UsrObj = GETOBJECT("WinNT://" & DomainName & "/" & User & ",user")
NT4Name = replace(UsrObj.ADsPath,"WinNT://","")
tempArray = split(nt4Name,"/")
NT4Name = tempArray(1)
QueryFilter = QueryFilter & "(samAccountName=" & NT4Name & ")"
QueryString = "<LDAP://" & DomainName & ">;" & QueryFilter & ";distinguishedName;subtree"
@g3rhard
g3rhard / ansible_template.sh
Last active September 4, 2017 09:49
Create folders for Ansible projects with Bash script
#!/bin/bash
# usage sh ansible_template.sh project_name
# Based on http://docs.ansible.com/ansible/latest/playbooks_best_practices.html
# Also, you can use ansible-galaxy:
# ansible-galaxy init project_name
pname=$1
mkdir -p $pname/{group_vars,host_vars,library,module_utils,filter_plugins,roles}
touch $pname/{production,staging,template.yml,$pname.yml}
mkdir -p $pname/roles/{common,$pname}/{tasks,handlers,templates,files,vars,defaults,meta,library,module_utils,lookup_plugins}
touch $pname/roles/{common,$pname}/{tasks,handlers,vars,defaults,meta}/main.yml
@g3rhard
g3rhard / check_winrm.sh
Created November 17, 2017 03:25
Check WinRM works without SSL
#!/bin/bash
if [ $# -eq 0 ]; then
echo "please provide hostname or ip address"
exit 1
fi
url=$1
output=$(curl -s -f -k -m 10 --header "Content-Type: application/soap+xml;charset=UTF-8" --header "WSMANIDENTIFY: unauthenticated" http://${url}:5985/wsman --data "<s:Envelope xmlns:s=http://www.w3.org/2003/05/soap-envelope xmlns:wsmid=http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd><s:Header/><s:Body><wsmid:Identify/></s:Body></s:Envelope>" || true);
if [[ $output == *"IdentifyResponse"* ]]
then
# Mediawiki, Bugzilla and mediawiki-bugzilla extension
# test setup
version: '2'
services:
mysql:
container_name: mw-bz-mysql
image: mysql
volumes:
- "./data/mysql:/var/lib/mysql"
restart: always
@g3rhard
g3rhard / chrome.json
Last active January 8, 2021 18:14 — forked from meets2tarun/chrome.json
Copy the file in /etc/chromium-browser/policies/managed and make required changes in chromium-browser or /etc/opt/chrome/policies/managed for Google Chrome
// Policy template for Linux.
// Uncomment the policies you wish to activate and change their values to
// something useful for your case. The provided values are for reference only
// and do not provide meaningful defaults!
// More information in https://www.chromium.org/administrators/policy-list-3
{
// Cross-origin HTTP Basic Auth prompts
//-------------------------------------------------------------------------
// Controls whether third-party sub-content on a page is allowed to pop-up an
// HTTP Basic Auth dialog box. Typically this is disabled as a phishing
# Please make this file available to others
# by sending it to <lirc@bartelmus.de>
#
# this config file was automatically generated
# using lirc-0.8.6-dnk(default) on Tue Jan 16 10:52:43 2018
#
# contributed by Kirill Trofimov
#
# brand: Rombica
# model no. of remote control: Cinema 4k v01
@g3rhard
g3rhard / ubuntu-setup.md
Created January 22, 2018 06:27 — forked from kyamagu/ubuntu-setup.md
Ubuntu in ActiveDirectory environment

Ubuntu setup

Setup instructions for the Ubuntu 16.04 workstations and servers in the laboratory environment. Replace systemctl with Upstart start|stop for Ubuntu 14.04.

Passwordless sudo

sudo tee /etc/sudoers.d/administrator <<EOF
administrator ALL=(ALL) NOPASSWD: ALL
EOF
@g3rhard
g3rhard / remote_control_mag250.md
Last active January 27, 2018 12:51
Вариации управления MAG250 по сети без ДУ

Взято с форума pristavka.de сообщение пользователя ZoYa-MAG-250

Если установить netrc - можно из командной строки управлять воспроизведением MAG 250 (проверялось под Windows):

  1. Нужно получить auth-key после ввода пароля (он попадёт в headers_and_cookies.txt): Код:
curl -v -d client-password=PASSWORD -D headers_and_cookies.txt http://192.168.1.111
@g3rhard
g3rhard / gogs_migrate.sh
Created February 15, 2018 06:53 — forked from senz/gogs_migrate.sh
gogs repo migration script
#!/usr/bin/env bash
## Usage:
## ./migrate.sh $clone_url $project_name $owner_uid
## Migrate a repository to gogs into the user namespace of the token-user
## ./migrate.sh git@mygitlab.com:group/repo.git repo 1
## uid can be a group uid
## NB: for local migration, if your gogs instance is inside docker or vm, you must provide path local relative to container's fs
echo $1;