Skip to content

Instantly share code, notes, and snippets.

View zduymz's full-sized avatar
👻
just a shadow

Duy Mai zduymz

👻
just a shadow
View GitHub Profile
@zduymz
zduymz / beautiful_idiomatic_python.md
Created January 20, 2017 03:18 — forked from JeffPaine/beautiful_idiomatic_python.md
Transforming Code into Beautiful, Idiomatic Python: notes from Raymond Hettinger's talk at pycon US 2013. The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]:
#!/bin/sh
### BEGIN INIT INFO
# Provides: none
# Required-Start: $local_fs $network $named $time $syslog
# Required-Stop: $local_fs $network $named $time $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: none
### END INIT INFO
#!/bin/sh
### BEGIN INIT INFO
# Provides: none
# Required-Start: $local_fs $network $named $time $syslog
# Required-Stop: $local_fs $network $named $time $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: none
### END INIT INFO
#!/bin/sh
### BEGIN INIT INFO
# Provides: none
# Required-Start: $local_fs $network $named $time $syslog
# Required-Stop: $local_fs $network $named $time $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: none
### END INIT INFO
#!/bin/sh
### BEGIN INIT INFO
# Provides: none
# Required-Start: $local_fs $network $named $time $syslog
# Required-Stop: $local_fs $network $named $time $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: none
### END INIT INFO
#!/bin/bash
#
# A script to start/stop the CoreNLP server on port 80, made
# in particular for the configuration running at corenlp.run.
# This script should be placed into:
#
# /etc/init.d/corenlp
#
# To run it at startup, link to the script using:
#

I just had to set up Jenkins to use GitHub. My notes (to myself, mostly):

Detailed Instructions

For setting up Jenkins to build GitHub projects. This assumes some ability to manage Jenkins, use the command line, set up a utility LDAP account, etc. Please share or improve this Gist as needed.

Install Jenkins Plugins

@zduymz
zduymz / mysql_backup.sh
Created August 7, 2017 03:04
just a script
#!/bin/bash
MYSQL_USER="root"
MYSQL_PASSWORD="password"
MYSQL_HOST="127.0.0.1"
mysql -u$MYSQL_USER -h$MYSQL_HOST -p$MYSQL_PASSWORD -e "show databases" |
grep -iv -E "(information_schema|Database)" > /tmp/db.txt
if [[ ! -f /tmp/db.ptr ]]; then
# ---------------------------------------------
$ORAFullPath = 'C:\Users\ab\Downloads\tnsnames.ora'
$CSVFullPath = 'C:\Users\ab\Documents\tnsnames.csv'
#Defaults/hard coded/static values - these will appear in every row of the CSV.
#------------------------------------------------------------------------------
#For those columns marked #Dynamic (which come from the ora file) the value will revert to the default below if its not provided in the ora file.
$uriVaultPost = "http://$strVaultIP/PasswordVault/WebServices/PIMServices.svc/Account"
$payloadVault = @{
account = @{
safe = "MS SQL Safe"; (this value can be hardcoded)
platformID = "Test-MYSQL"; (this value can be hardcoded)
address = "4.4.4.2"; (this is the HOST information read from tnsnames.ora)
DSN = "dsn_test"; (can be hardcoded)
Database = "dsn_test"; (this is the description value in tnsnames.ora)
username = "SYS"; (this is the SID/Service_name read from tnsnames.ora)
password = "xxxx"; (this should be combination of Servicename/sid_Database_Address from tnsnames.ora)