Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# shellcheck disable=SC2034
src='\033[0;32m'
applications_sv_app_firstvet_com='\033[0;36m'
applications_app_firstvet_com='\033[0;35m'
NC='\033[0m' # No Color
dirs=( "." "applications/app.firstvet.com" "applications/sv.app.firstvet.com" )
setColor() {
dir_norm=$(echo "$1" | sed "s/[\/.]/_/g")
@bperel
bperel / loc.sh
Last active July 25, 2022 13:35
FV LOC
#!/bin/bash
# shellcheck disable=SC2034
src='\033[0;32m'
applications_sv_app_firstvet_com='\033[0;36m'
applications_app_firstvet_com='\033[0;35m'
NC='\033[0m' # No Color
dirs=( "." "applications/app.firstvet.com" "applications/sv.app.firstvet.com" )
setColor() {
dir_norm=$(echo "$1" | sed "s/[\/.]/_/g")
@bperel
bperel / split.sh
Created February 22, 2021 21:18
Split multi-edge drawing
#!/bin/bash
image=/var/www/html/DucksManager-old/edges/se/elements/KAP.Fond-169-195.png
doubles=(181 188 194)
start=169
end=195
width=$(identify -format '%w' $image)
height=$(identify -format '%h' $image)
crop_size_single=$(echo "scale=3;$width/(${#doubles[@]}+1+$end-$start)" | bc)
select uc.universecode AS "Univers",
concat(
SUBSTRING_INDEX(
group_concat(distinct character_examples.charactername),
',',
5),
',...') AS "Exemples de personnages de cet univers",
count(distinct uc.charactercode) AS "Nombre de personnages",
count(distinct s.storycode) AS "Histoires avec au moins un personnage de cet univers"
from inducks_universe u
@bperel
bperel / graphviz-linter.sh
Created February 12, 2020 11:39
Graphviz linter
#/bin/bash
# Usage : chmod +x graphviz-linter.sh && ./graphviz-linter.sh myfile.dot
path=$1
output=''
indent=0
while read line; do
if [[ "${line:0:1}" = '}' ]]; then indent=$((indent - 1)); fi
@bperel
bperel / find-srefs-with-declaration.bash
Last active April 27, 2018 13:18
Find undeclared srefs
#!/bin/bash
grep -hrEo "ui-sref='([^(']+)" src | sed "s/ui-sref='//g" | \
while read -r sref; do
echo $sref;grep -r ".state('$sref'" src
done
@bperel
bperel / regexes.js
Created June 20, 2017 10:20
Regexes
(/(\$[a-zA-Z0-9]+) = (new [^;]+;)\n([ ]{4})\3\1->/g,'$1 = $2\n$3$3$1\n$3$3$3->')
(/(\$[a-zA-Z0-9]+)\n([ ]{4})(\2\2->(?!persist)[^;]+);\n\2\2\1->/g,'$1\n$2$3\n$2$2$2->')
@bperel
bperel / levenshtein.js
Last active April 23, 2017 14:10 — forked from andrei-m/levenshtein.js
Levenshtein distance between two given strings implemented in JavaScript and usable as a Node.js module
// https://gist.github.com/andrei-m/982927#gistcomment-1931258 looks like the fastest Levenshtein implementation
const levenshtein = (a, b) => {
if (a.length === 0) return b.length
if (b.length === 0) return a.length
let tmp, i, j, prev, val
// swap to save some memory O(min(a,b)) instead of O(a)
if (a.length > b.length) {
tmp = a
a = b
b = tmp
-- On DM server
create server 'coa_federated' foreign data wrapper 'mysql' options (HOST '127.0.0.1', DATABASE 'coa_federated', USER 'root', PASSWORD 'changeme', PORT 3306, SOCKET '', OWNER 'root');
sudo cp /var/www/inducks/createtables_clean.sql /var/www/inducks/createtables_clean_federated.sql
sudo sed -i "s/MyISAM/FEDERATED CONNECTION=\"coa\"/g" /var/www/inducks/createtables_clean_federated.sql
-- On coa server
CREATE USER federated@'%' IDENTIFIED BY 'changeme';
GRANT ALL ON coa.* TO federated@'%';
FLUSH PRIVILEGES;
{
"chatTitle": "CHAT external",
"chatWelcome": "Hej! Nästa tillgängliga handläggare kommer inom kort svara på ditt ärende.",
"defaultUsername": "Användare",
"defaultAgentName": "Handläggare",
"ownUsername": "Du",
"chatEnded": "Chatt sessionen är avslutad",
"agentJoined": "Handläggare {name} har anslutit sig till chatt sessionen",
"agentLeft": "Handläggare {name} har lämnat sessionen",
"agentTyping": "{agentName} skriver...",