Ruby 193 on Centos 6.6

By polfilm,
yum install -y centos-release-SCL
yum install -y ruby193
source /opt/rh/ruby193/enable
echo "source /opt/rh/ruby193/enable" | sudo tee -a /etc/profile.d/ruby193.sh

File Duplicates Recursive in Linux

By polfilm,
md5deep -r -l . > filelist.txt
sort < filelist.txt > filelist_sorted.txt

First command will render all hashes for all files
Second will sort the list so as you scroll you will easily spot duplicates with their paths.
m5deep is in most apt-get and yum repos.

DenyHosts

By polfilm,

If you’re getting bombarded with brute force login attempts. Below will install DenyHosts as a daemon that will with default settings scan your /var/log/secure for failed login attempts. It is initially set to 5 failed attempts and then IP ends up in the hosts.deny file. You should get a good long look a the .cfg file to understand full capabilities. (For example running against Apache logs for web attacks)

wget http://downloads.sourceforge.net/project/denyhosts/denyhosts/2.6/DenyHosts-2.6.tar.gz
tar -zxvf DenyHosts-2.6.tar.gz
cd DenyHosts-2.6
python setup.py install
cp /usr/share/denyhosts/daemon-control-dist /usr/share/denyhosts/daemon-control
cp /usr/share/denyhosts/denyhosts.cfg-dist /usr/share/denyhosts/denyhosts.cfg
ln -s /usr/share/denyhosts/daemon-control /etc/init.d/denyhosts
chkconfig --add denyhosts
service denyhosts start 
tail -f /etc/hosts.deny /var/log/secure

Root Zone Database

By polfilm,

The Root Zone Database represents the delegation details of top-level domains, including gTLDs such as .com, and country-code TLDs such as .uk.

http://data.iana.org/TLD/tlds-alpha-by-domain.txt

Registrars List (UK)
http://www.nominet.org.uk/uk-domain-names/registering-uk-domain/choosing-registrar/list-registrars

Lighttpd rewrite rules for WordPress sites

By polfilm,
  # Handle 404 errors
  server.error-handler-404 = "/index.php"
 
  # Rewrite rules
  url.rewrite-final = (
 
    # Exclude some directories from rewriting
    "^/(wp-admin|wp-includes|wp-content|gallery2)/(.*)" => "$0",
 
    # Exclude .php files at root from rewriting
    "^/(.*.php)" => "$0",
 
    # Handle permalinks and RSS feeds
    "^/(.*)$" => "/index.php/$1"
  )

Bat Command from Powershell

By polfilm,

This way you don’t have to worry about escaping anything.

$command = @'
cmd.exe /C c:\windows\system32\ntbackup.exe backup "C:\Documents and Settings\Administrator\Local Settings\Application Data\Microsoft\Windows NT\NTBackup\data\chameme.bks" /n "1file.bkf1 created 06/09/2013 at 09:36" /d "Set created 06/09/2013 at 09:36" /v:no /r:no /rs:no /hc:off /m normal /j chameme /l:s /f "\\fs1\Exchange Backups$\1file.bkf"
'@

Invoke-Expression -Command:$command

Ubuntu New User

By polfilm,
sudo useradd -d /home/<username> -s /bin/bash -m <username>
sudo passwd <username>
sudo adduser <username> sudo

Ipa. Change Admin Password

By polfilm,
LDAPTLS_CACERT=/etc/ipa/ca.crt ldappasswd \
           -ZZ -D 'cn=directory manager' -W \
           -S uid=admin,cn=users,cn=accounts,dc=domain,dc=com

or

kadmin.local
Authenticating as principal admin/admin@EXAMPLE.COM with password.
kadmin.local:  change_password admin@EXAMPLE.COM
Enter password for principal "admin@EXAMPLE.COM": 
Re-enter password for principal "admin@EXAMPLE.COM": 

Fedora 20. Set hostname permanently.

By polfilm,

1.Set the hostname in /etc/hostname

2. Edit /etc/cloud/cloud.cfg (which is a YAML file) and set preserve_hostname: true at the toplevel (one can also pass this option in with the user data)

Check SSH keypair fingerprint

By polfilm,

PRIVATE

ssh-keygen -lf ~/.ssh/id_rsa.pub

PUBLIC

openssl x509 -noout -fingerprint -in /etc/ssl/certs/ssl-cert-snakeoil.pem

Git: Few Good Commands

By polfilm,

To move repo with history

git clone --bare <old_repo>
cd into bare old_repo and: git push --mirror <new_repo>

To clone from HTTPS with self-generated cert

git -c http.sslVerify=false clone https://<repo>

Restore all deleted files in folder

git ls-files -d | xargs git checkout --

Automatic Versioning
Begin Versioning:

git tags -a 2.1

Retrieve:

git describe --tags

Result similar to this where 411 is number of commit for above given tag.

2.1-441-gff635ba

  Category: GIT
  Comments: None

UI Frameworks

By polfilm,

Don’t even think about starting work on UI without looking at those…

http://bootstrapdocs.com/v2.3.1/docs/components.html
https://github.com/twbs/bootstrap
http://discover-devtools.codeschool.com/
http://modernizr.com/docs/
http://afarkas.github.io/webshim/demos/demos/shiv.html
https://github.com/dyve/django-bootstrap-toolkit
http://backbonejs.org/
http://knockoutjs.com/
http://billpull.github.io/knockout-bootstrap/
http://django-debug-toolbar.readthedocs.org/en/1.0/
https://github.com/eldarion/eldarion-ajax