Skip to content

Instantly share code, notes, and snippets.

@dnozay
dnozay / README.md
Last active May 31, 2023 02:12
Collection of useful stuff for interacting with gitlab.

Reset root/admin password

Lost the root/admin password? You can reset it using the command-line. Recipe adapted from gitlab issue #308.

# start the console
sudo gitlab-rails console
@dnozay
dnozay / README.md
Last active July 27, 2020 01:34
selinux policy for gitweb when using autofs / symlinks / ...etc

Commands to compile and load module:

checkmodule -M -m -o gitweb.mod gitweb.te
semodule_package -o gitweb.pp -m gitweb.mod
semodule -i gitweb.pp

Doesn't work on your system?

setenforce 0
@dnozay
dnozay / testldaps.rb
Created March 3, 2015 22:02
test LDAPS connection using TLS 1.1 and internal CA certificate validation.
# test LDAPS connection using TLS 1.1 and internal CA certificate validation.
require 'rubygems'
require 'net/ldap'
# refs:
# https://gist.github.com/jeffjohnson9046/7012167
# https://github.com/ruby-ldap/ruby-net-ldap/blob/master/lib/net/ldap.rb
def get_ldap_response(ldap)
@dnozay
dnozay / models.py
Created February 25, 2015 21:47
django - QuerySet whose delete() marks items as deactivated rather than delete rows.
# based on http://stackoverflow.com/questions/6459616/overriding-queryset-delete-in-django
class DeactivateQuerySet(models.query.QuerySet):
'''
QuerySet whose delete() does not delete items, but instead marks the
rows as not active, and updates the timestamps
'''
def delete(self):
self.deactivate()
@dnozay
dnozay / new-pass.sh
Created February 18, 2015 19:30
change slapd manager password.
#!/bin/bash
# License: MIT
# You can find a copy of the license here: http://opensource.org/licenses/MIT
# This simple script lets you change the LDAP admin password from
# a console on the LDAP server.
cd /tmp
set -o errexit
PASSWORD=$(slappasswd -h {SSHA})
@dnozay
dnozay / _Jenkins+Script+Console.md
Last active May 3, 2024 09:33
jenkins groovy scripts collection.
@dnozay
dnozay / lastaborted.groovy
Created January 22, 2015 18:39
jenkins - scan jobs and find if last build was aborted (e.g. maintenance) and who aborted it.
// scan all jobs and check if the last build was aborted (e.g. maintenance)
// and output user / timestamp
jobs = Jenkins.instance.getAllItems()
lastabort = null
jobs.each { j ->
if (j instanceof com.cloudbees.hudson.plugins.folder.Folder) { return }
numbuilds = j.builds.size()
if (numbuilds == 0) { return }
lastbuild = j.builds[numbuilds - 1]
@dnozay
dnozay / buildname.groovy
Created January 22, 2015 01:34
build-flow-plugin, change existing builds' displayName to include the git branch's name where applicable.
// for all builds from build-flow-plugin whose parameters include a GIT_BRANCH paramater,
// change the displayName to include branch and build number
import com.cloudbees.plugins.flow.*;
jobs = Jenkins.instance.getAllItems(BuildFlow);
jobs.each { it ->
it.builds.each { b ->
GIT_BRANCH = b.envVars['GIT_BRANCH']
( GIT_BRANCH =~ /(?:refs\/remotes\/)?(.+)/ ).each { full,branch ->
@dnozay
dnozay / creation.py
Created January 9, 2015 07:16
django 1.6, add unique_together constraint name.
class CustomDatabaseCreation(BaseDatabaseCreation):
def sql_create_model(self, model, style, known_models=set()):
final_output, pending_references = super(CustomDatabaseCreation, self).sql_create_model(model, style, known_models)
# get output generated by parent class for unique_together.
for field_constraints in opts.unique_together:
line = (' ' + style.SQL_KEYWORD('UNIQUE') + ' (%s)' %
", ".join(
[style.SQL_FIELD(qn(opts.get_field(f).column))
for f in field_constraints]))
@dnozay
dnozay / named_indices__models.py
Created January 8, 2015 18:49
django custom unique_together constraint name.
# named_indices/models.py
from django.db.backends.schema import BaseDatabaseSchemaEditor
old_create_index_name = BaseDatabaseSchemaEditor._create_index_name
if not hasattr(BaseDatabaseSchemaEditor, '_old_create_index_name'):
setattr(BaseDatabaseSchemaEditor, '_old_create_index_name', old_create_index_name)
def _create_index_name(self, model, column_names, suffix=""):
try: