Skip to content

Instantly share code, notes, and snippets.

View okram999's full-sized avatar

Niris Okram okram999

View GitHub Profile
#Added to install the nginx-1.8 from the nginx repo. EPEL doesn't have any later than 1.0.15 at the time of this change
#And we need the nginx to support proxy_protocol & real_ip_recursive directives
yum_repository 'nginx' do
description "Nginx.org repo"
baseurl "http://nginx.org/packages/centos/6/$basearch/"
gpgcheck false
enabled true
action :create
end
include_recipe 'yum'
include_recipe 'yum-epel'
include_recipe 'abc_jenkins::rubies'
include_recipe 'java'
include_recipe 'nginx'
include_recipe 'jenkins::master'
include_recipe 'abc_jenkins::chef_config'
include_recipe 'abc_jenkins::maven'
include_recipe 'abc_jenkins::git'
@okram999
okram999 / groovy-loop-with-2-variables
Last active April 21, 2016 17:05
groovy-loop-with-2-variables
def paths = ['some_path1', 'some_path2', 'another_path']
def dirs = ['dir1', 'dir_for_some_path2', 'another_dir']
[paths, dirs].transpose().each { path, dir ->
bat "xcopy %cd%${path}\\obj\\Lab5\\Package\\PackageTmp host1\\${dir} /E /Y /V"
bat "(robocopy %cd%${Path}${Another_fixed_path} ${Another_fixed_path}\\${dir} file1 file2) ^& IF %ERRORLEVEL% LEQ 7 exit 0"
}
# Fetch all of the remote branches and tags:
git fetch origin
# View all "old repo" local and remote branches:
git branch -a
# If some of the remotes/ branches doesn't have a local copy,
# checkout to create a local copy of the missing ones:
git checkout -b <branch> origin/<branch>
@okram999
okram999 / gist:6f0913639dd5ee0a82996252bec635b4
Created May 27, 2016 14:09
A sample pom with mvn release
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>BlueKing</groupId>
<artifactId>BlueKing</artifactId>
<version>12.0.10-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
This is all of the escape sequences Ruby supports. You may not use many of these, but memorize their format and what they do anyway. Try them out in some strings to see if you can make them work.
Escape What it does.
\\ Backslash ()
\' Single-quote (')
\" Double-quote (")
\a ASCII bell (BEL)
\b ASCII backspace (BS)
\f ASCII formfeed (FF)
\n ASCII linefeed (LF)
#Methods takes parameters as that of parameters in a script (ARGV)
def two_args(*argv)
a1, a2 = argv
puts "a1 = #{a1} & a2 = #{a2}"
end
puts two_args("one", "two")
============================================================
import hudson.model.*
def jobsPerView(viewName)
{
installView = jenkins.getView(viewName)
failedJobs_StatsJobs = installView.items.findAll{job -> job.isBuildable() && job.lastCompletedBuild && job.lastCompletedBuild.result == hudson.model.Result.FAILURE }
unstableJobs_StatsJobs = installView.items.findAll{job -> job.isBuildable() && job.lastCompletedBuild && job.lastCompletedBuild.result == hudson.model.Result.UNSTABLE }
}
# They both stores a block in a variable
#Differences:
1. Proc doesnt care the number of arguments passed
2. Proc exist out of a code block, when it meets 'return' while lambda processes return as moves on till 'end'
#Sample Proc
full_name = Proc.new {|first, last| first + " " + last}
p full_name["Jane", "Smith"]
Ternary Operators:
#1:
def s = ""
if (s != null && s.length() > 0) {
result = 'Found'
}
else {
result = 'Not Found'