Skip to content

Instantly share code, notes, and snippets.

View haani-niyaz's full-sized avatar

Haani Niyaz haani-niyaz

  • Melbourne, Australia
View GitHub Profile
<%= ruby code, result inserted %>
<% ruby code, result not inserted %> # use for loops, conditions...
<%- like above, but strips leading+trailings spaces from output -%>
<%# comment %>
<%% # literal <%
%%> # literal %>
<%= @name %> # variable visible in current scope
<%= scope.lookupvar('name') %> # search in all scopes
<%= scope['somewhere::name'] %> # Puppet 3 scope access
erb -x -T '-' <template> | ruby -c
@haani-niyaz
haani-niyaz / Nexus upload
Created March 20, 2017 22:53
How to upload to Nexus without POM
curl -u <user> --upload-file atlassian-bamboo-5.15.3.tar.gz http://<nexus-host>/content/repositories/releases/atlassian/atlassian-bamboo/5/15/3/atlassian-bamboo-5.15.3.tar.gz
@haani-niyaz
haani-niyaz / read-file-in-tar
Created April 6, 2017 23:48
Read a tar file without extracting it
# Find path
less <tar-file>
# File in stdout
tar xfO <tat-file> <path-to-file>
@haani-niyaz
haani-niyaz / module_access.py
Created April 8, 2017 08:40
Python module access from anywhere
import sys
sys.path.append('/path/to/module-dir')
@haani-niyaz
haani-niyaz / gitserver_port_forwarding.md
Last active June 28, 2022 12:38
Setup a port forwarding for git server

GIT Portforwarding

Setup port forwarding connection from a server that does not have access to the git_server but does have access to the proxy_server.

Configure port forwarding

#ssh -L <local_port>:git_server:<git_port> proxy_server
$ ssh -L 3333:mygitserver.com:7999 myproxyserver
@haani-niyaz
haani-niyaz / pbis_dns_update_ip.sh
Created April 18, 2017 05:24
Update DNS via pbis if name resolution is broken
sudo /opt/pbis/bin/update-dns --ipaddress <ip>
@haani-niyaz
haani-niyaz / django-handbook
Created May 1, 2017 07:52
Useful django commands
# Migrations
## Purge DB and start fresh
```
$ rm db.sqlite3
$ python manage.py migrate --noinput
```
@haani-niyaz
haani-niyaz / run_as_sudo_error.py
Created May 10, 2017 11:29
Inform user to run command as privileged user
import os
import errno
try:
# do something
except OSError, e:
if e.errno == errno.EACCES:
log.error('Must run as privileged user')
else:
raise