Skip to content

Instantly share code, notes, and snippets.

View saiful-semantic's full-sized avatar

Dr. Saiful Amin saiful-semantic

View GitHub Profile
# --- Silent Bot Blocking - No Error Logs ---
SetEnvIfNoCase User-Agent "AhrefsBot|PetalBot|DotBot|MJ12bot|SemrushBot|oai-searchbot|BLEXBot|Amazonbot" bad_bot
SetEnvIfNoCase User-Agent "bot[^a-z]|crawler|spider|scraper" bad_bot
<Location "/">
Order allow,deny
Allow from all
Deny from env=bad_bot
# Suppress error logging for bot blocks
@saiful-semantic
saiful-semantic / Drupal11-Ubuntu24.md
Last active October 8, 2024 07:05
Drupal 11 on Ubuntu 24 LTS

Setup the server

sudo dpkg-reconfigure tzdata
sudo apt update
sudo apt upgrade
sudo apt install plocate zip

Main dependencies (LAMP)

@saiful-semantic
saiful-semantic / .tmux.conf
Last active December 11, 2024 07:43
Tmux-conf
# Global defaults
set -g default-terminal xterm-color
# don't do anything when a 'bell' rings
set -g visual-activity off
set -g visual-bell off
set -g visual-silence off
setw -g monitor-activity off
set -g bell-action none
@saiful-semantic
saiful-semantic / replace-bitstreams.ts
Last active June 15, 2024 07:42
Replace PDF files for an item in DSpace 7
import * as DSpace from 'dspace7-node'
import * as csv from 'fast-csv'
import {readdirSync, createReadStream} from 'node:fs'
(async () => {
const baseUrl = '' // full API URL, e.g., https://demo.dspace.org/server
const user = ''
const password = ''
DSpace.init(baseUrl)
@saiful-semantic
saiful-semantic / move-collection.ts
Last active June 14, 2024 19:12
Moving a bunch of items to another collection
import * as DSpace from 'dspace7-node'
(async () => {
const baseUrl = '' // full API URL, e.g., https://demo.dspace.org/server
const user = ''
const password = ''
DSpace.init(baseUrl)
await DSpace.login(user, password)
const items = [] // read lines from a csv
@saiful-semantic
saiful-semantic / create_subtheme.sh
Created June 28, 2019 18:36
Create new sub-theme for Drupal Bootstrap using starterkit
cd themes/custom
# change this to your custom theme_name
export CUSTOM_THEME=mytheme
cp -r ../bootstrap/starterkits/THEMENAME $CUSTOM_THEME
cd $CUSTOM_THEME
mv THEMENAME.starterkit.yml $CUSTOM_THEME.info.yml
for file in THEMENAME.*; do mv $file ${file//THEMENAME/$CUSTOM_THEME}; done
for file in config/*/THEMENAME.*; do mv $file ${file//THEMENAME/$CUSTOM_THEME}; done
grep -Rl THEMENAME |xargs sed -i -e "s/THEMENAME/$CUSTOM_THEME/"
grep -Rl THEMETITLE |xargs sed -i -e "s/THEMETITLE/$CUSTOM_THEME/"
TASK [kohadevbox : Instance creation | Create Koha instance] *******************
fatal: [xenial]: FAILED! => {"changed": true, "cmd": "koha-create --create-db kohadev", "delta": "0:00:02.261843", "end": "2018-05-09 09:42:38.390012",09:42:36.128169", "stderr": "", "stderr_lines": [], "stdout": "Koha instance is empty, no staff user created.", "stdout_lines": ["Koha instance is empt
RUNNING HANDLER [kohadevbox : restart apache] **********************************
RUNNING HANDLER [kohadevbox : reload ssh] **************************************
to retry, use: --limit @/vagrant/site.retry
PLAY RECAP *********************************************************************
xenial : ok=29 changed=25 unreachable=0 failed=1
@saiful-semantic
saiful-semantic / gist:c554f69c5e58a94970af995a7cea692b
Created October 9, 2016 15:10
javascript group select checkboxes
<script>
function select_unselect(chkType, action) {
var importForm = this.document.import_form;
var checkBoxes;
if (chkType == 'locations') checkBoxes = importForm.locations;
if (chkType == 'classes') checkBoxes = importForm.classes;
if (chkType == 'statuses') checkBoxes = importForm.statuses;
for (i = 0; i < checkBoxes.length; i++)
checkBoxes[i].checked = action;
}