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
@haani-niyaz
haani-niyaz / 0_reuse_code.js
Created February 24, 2014 09:25
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@haani-niyaz
haani-niyaz / App::error()
Created July 11, 2014 08:58
Laravel app error function with view and status code in response
App::error(function(Exception $exception, $code)
{
Log::error($exception->getMessage());
switch ($code) {
case 404:
return Response::view('errors.404',array(), 404);
break;
default:
@haani-niyaz
haani-niyaz / jiraCustomFields.groovy
Last active August 29, 2015 14:06
JIRA Custom Fields
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor
// Importing ModifiedValue & DefaultIsseuChangeHolder class to update fields via the script
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
@haani-niyaz
haani-niyaz / update_yaml_config
Created February 9, 2015 04:20
Ruby script to update yaml config value via command-line variable
# call script with:
# ruby scriptname.rb hieravar=value
require 'yaml'
# Get value to change hieravar=value
arg = ARGV[0].split('=')
field_name = arg[0]
field_value = arg[1]
@haani-niyaz
haani-niyaz / .fixtures.yaml
Last active August 29, 2015 14:24
Sample .fixtures.yaml for rspec-puppet
fixtures:
#repositories:
#stdlib: git://github.com/puppetlabs/puppetlabs-stdlib.git
#apt: git://github.com/puppetlabs/puppetlabs-apt.git
symlinks:
tomcat: "#{source_dir}"
authbind: "#{source_dir}/../authbind"
stdlib: "#{source_dir}/../stdlib"
apt: "#{source_dir}/../apt"
@haani-niyaz
haani-niyaz / alias-to-git-branch
Last active August 29, 2015 14:24
Create an alias to a git branch
# Alias for remote branch (f1 tracks feature_1)
git checkout --track -b f1 origin/feature_1
# To enable push/pull to remote tracking branch (enables local(alias) branch to push to remote branch)
git config push.default upstream
@haani-niyaz
haani-niyaz / serverspec_rspec_cheatsheet.html
Created May 26, 2016 23:52 — forked from mearns/serverspec_rspec_cheatsheet.html
A cheat sheet for server spec and rspec
<!DOCTYPE html >
<html>
<!-- This was hacked together by hand after python-markdown output the bulk of it.
Maybe someday I'll put together a better script to aut-generate this from markdown source. -->
<head>
<!-- github-markdown, plus github pygments -->
<style type='text/css'>
/* <![CDATA[ */
@font-face {
font-family: octicons-link;
grep -rl 'apples' /dir_to_search_under | xargs sed -i 's/apples/oranges/g'
@haani-niyaz
haani-niyaz / sed-search-and-replace
Created August 17, 2016 06:06
Search and replace string in file
sudo sed -i "s/^tenant.amount=1500/tenant.amount=2100/g" /opt/web/config.properties
hiera <key> # to query common.yaml only
hiera <key> -m <FQDN> # to query config of a given node (using mcollective)
hiera <key> -i <FQDN> # to query config of a given node (using Puppet inventory)
hiera <key> environment=production fqdn=myhost1 # to pass values for hiera.yaml
# To dump complex data
hiera -a <array key>
hiera -h <hash key>