Skip to content

Instantly share code, notes, and snippets.

View pgilad's full-sized avatar
🔭

Gilad Peleg pgilad

🔭
View GitHub Profile
@zuazo
zuazo / Chef-Gemfile.rb
Last active April 17, 2020 18:59
Gemfile template for a Chef Cookbook
# encoding: UTF-8
# -*- mode: ruby -*-
# vi: set ft=ruby :
# More info at http://bundler.io/gemfile.html
source 'https://rubygems.org'
# Used when running the tests against different Chef versions:
chef_version = ENV.key?('CHEF_VERSION') ? ENV['CHEF_VERSION'] : nil
@pgilad
pgilad / Instructions.md
Last active March 31, 2024 22:30
Git commit-msg hook to validate for jira issue or the word merge

Instructions

  • copy the file commit-msg to .git/hooks/commit-msg
  • make sure your delete the sample file .git/hooks/commit-msg.sample
  • Make commit msg executable. chmod +x .git/hooks/commit-msg
  • Edit commit-msg to better fit your development branch, commit regex and error message
  • Profit $$

Shell example

@pgilad
pgilad / res.sh
Created October 27, 2014 13:23
Curl and get only response code
curl -sL -w "%{http_code}" "http://somesite.com" -o /dev/null
@adamchainz
adamchainz / my_filters.py
Created March 25, 2015 23:10
Ansible Jinja2 filters for deleting anonymous ec2 instances
import datetime as dt
import time
import unittest
def aws_age_seconds(ec2_launch_time):
"""
Parse the ec2 launch time string and return how old it is in seconds.
"""
# Strip trailing subsecond part
#!/usr/bin/python
import random
import time
import statsd
ctr_name = 'stats.test.1'
while True:
client = statsd.StatsClient('localhost', 8125)
rand = random.randrange(1, 250)
print('count: (%d)' % rand)
@mistakster
mistakster / webpack.config.js
Created July 9, 2015 16:23
Webpack configuration file
/**
* Build for production:
* $ NODE_ENV=production webpack
*
* Build for staging or development mode
* $ webpack
*
* Run app server in dev mode and use Hot Module Replacement
* $ NODE_ENV=webpack nodemon --watch ./app index.js
*
@sitano
sitano / ansible-common-default.yaml
Created July 30, 2015 15:27
ansible task example on how to setup kernel.mm.transparent_hugepage (block) if it exists
# file: roles/common/tasks/item.yml
- name: be sure basic packages are installed
apt: pkg={{item}} state=latest update_cache=yes
tags: common
with_items:
- git
- subversion
- vim
- block:
@gblmarquez
gblmarquez / .tmux.conf
Created August 6, 2015 14:28
.tmux.conf with fish as default shell
# Default termtype. If the rcfile sets $TERM, that overrides this value.
set -g default-terminal screen-256color
# support logging out and back in
set -g update-environment "SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_CONNECTION"
# pbcopy support
set-option -g default-command "reattach-to-user-namespace -l bash"
# vi mode
@halberom
halberom / output
Created September 16, 2015 10:07
ansible - example of asserting that vars are defined with_items
PLAY [localhost] **************************************************************
GATHERING FACTS ***************************************************************
$ ansible-playbook --version
ansible-playbook 1.9.3
configured module search path = ~/git/ansible-modules-core:~/git/ansible-modules-extra:./library
$ ansible-playbook play.yml
ok: [localhost]
@guumaster
guumaster / 00-README.md
Last active January 23, 2023 15:48
How to upload a file with $.ajax to AWS S3 with a pre-signed url

Upload a file with $.ajax to AWS S3 with a pre-signed url

When you read about how to create and consume a pre-signed url on this guide, everything is really easy. You get your Postman and it works like a charm in the first run.

Then you open your browser, try your usual $.ajax() and send your PUT operation, and you hit the cold iced wall of AWS error message, a simple <Code>SignatureDoesNotMatch</Code> that will steal hours from your productivity.

So here I come to save you and give you a free working example of how to upload a file directly to AWS S3 from your browser. You are wellcome :).