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 | |
# Script to whitelist hosts for remote access using gmail's https atom feed. | |
# Update the vars defined below and chmod 700 root:root, since the password is in clear text. | |
# Use cron to run it periodically. | |
# | |
# To add a host to the whitelist send an email to the GMAILUSER account with a subject like: "allow 13.13.13.13" (whithout quotes) using any of the accounts in ALLOWED | |
# To remove a host from whitelist read or delete the corresponding email. Note the feed shows only unread mail. | |
# | |
# The script works by updating hosts.allow. It checks the feed for mails like those described above. | |
# The whitelist stored in hosts.allow, between 2 markers (START FEEDSCRIPT, END FEEDSCRIPT), which should not be removed |
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 | |
show_help() { | |
cat << EOF | |
Usage: ${0##*/} [-hz] [-b NUM] | |
Print level of battery charge (1-100) formatted with colors. | |
-h display this help and exit. | |
-b NUM print a NUM bars instead of a number, e.g. '▸▸▸▸▸▸▹▹▹▹'. | |
-z use zsh colors instead of bash. Remember to autoload -U colors && colors in .zshrc. |
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 | |
if [ "$#" -eq "2" ]; then | |
find $1 -type f \( -name '*.lis' -o -name '*.inp' -o -name '*.bnn' -o -name '*.bin' -o -name '*.flair' \) -exec install -D {} `readlink -f $2`/{} \; | |
else | |
echo -e "Usage: cpfluka originDir destinationDir\nCopies some FLUKA-relevant files from originDir into destinationDir, keeping the directory structure as seen from pwd."; | |
fi |
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 | |
CPUUSE=`top -b -n2 | grep "Cpu(s)" | tail -1 | sed -e 's/[^0-9]*\([0-9][0-9]*[\.\,][0-9]\).*/\1/'` | |
CORES=`cat /proc/cpuinfo | grep -i 'processor' | wc -l` | |
USEDCORES=`echo "scale=1;$CPUUSE * $CORES / 100" | bc` | |
echo CPU used: $CPUUSE% Threads: $USEDCORES/$CORES |
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 | |
#Server list: | |
declare -a arr=("server1" "server2" "server3") | |
#Command to execute: | |
cmd="./cpuuse.sh" | |
for i in "${arr[@]}" | |
do | |
echo "***Connecting to $i***" | |
ssh "$i" "$cmd" |
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 | |
# Put in .git/hooks/commit-msg and chmod +x it. | |
from __future__ import print_function | |
import sys | |
def fail(): | |
print("Commit aborted.") | |
sys.exit(1) |
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
import re | |
def human_order_key(text): | |
"""Key function to sort in human order.""" | |
# Adapted from http://nedbatchelder.com/blog/200712/human_sorting.html | |
return [int(c) if c.isdigit() else c for c in re.split(r'(\d+)', text)] |
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
# Example of mailing script. Quick and (a little) dirty. | |
# Dih5 - 2017 | |
# Spam is not cool. Thou shalt not spam! | |
import smtplib | |
import email | |
from email.mime.multipart import MIMEMultipart | |
from email.mime.text import MIMEText | |
from email.mime.base import MIMEBase | |
from email import encoders |
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
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | |
<profiles version="1"> | |
<profile kind="CodeFormatterProfile" name="Dih5" version="1"> | |
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_exception_specification" value="do not insert"/> | |
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/> | |
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/> | |
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="do not insert"/> | |
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/> | |
<setting id="org.eclipse.cdt.core.formatter.indent_statements_compare_to_body" value="true"/> | |
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_colon_in_base_clause" value="insert"/> |
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 html.entities import codepoint2name | |
def html_escape(text): | |
d = dict((chr(code), '&%s;' % name) for code, name in codepoint2name.items() if code!=38) # exclude "&" | |
text = text.replace("&", "&") | |
for key, value in d.items(): | |
text = text.replace(key, value) | |
return text |
OlderNewer