Skip to content

Instantly share code, notes, and snippets.

View AjaxOdessa's full-sized avatar
🇺🇦

Yevgen Lasman AjaxOdessa

🇺🇦
  • Cprime, Inc.
  • Odessa, Ukraine
View GitHub Profile
@lukeplausin
lukeplausin / bash_aws_jq_cheatsheet.sh
Last active July 15, 2024 09:10
AWS, JQ and bash command cheat sheet. How to query, cut and munge things in JSON generally.
# Count total EBS based storage in AWS
aws ec2 describe-volumes | jq "[.Volumes[].Size] | add"
# Count total EBS storage with a tag filter
aws ec2 describe-volumes --filters "Name=tag:Name,Values=CloudEndure Volume qjenc" | jq "[.Volumes[].Size] | add"
# Describe instances concisely
aws ec2 describe-instances | jq '[.Reservations | .[] | .Instances | .[] | {InstanceId: .InstanceId, State: .State, SubnetId: .SubnetId, VpcId: .VpcId, Name: (.Tags[]|select(.Key=="Name")|.Value)}]'
# Wait until $instance_id is running and then immediately stop it again
aws ec2 wait instance-running --instance-id $instance_id && aws ec2 stop-instances --instance-id $instance_id
# Get 10th instance in the account
@guss77
guss77 / mongo_db_recover_delete_record-2.4.py
Last active June 28, 2024 04:32
Try to recover deleted documents from a mongodb 2.4 data file. Based on https://gist.github.com/egguy/2788955 with help from https://yazadk.wordpress.com/2015/07/15/a-forensic-perspective-on-recovering-deleted-data-from-big-data-systems/#MongoDB . Make sure to change `decode_chunk` so it properly detects the objects you are trying to recover - i…
#!/usr/bin/python
"""A little script to recover deleted recording of a mongoDB db file
There's no optimization but it work and has saved me
"""
import struct
import bson
import pymongo
@PickledDragon
PickledDragon / list-constraints.sql
Created October 25, 2015 11:30
Postgres list all constraints
SELECT
tc.constraint_name, tc.table_name, kcu.column_name,
ccu.table_name AS foreign_table_name,
ccu.column_name AS foreign_column_name
FROM
information_schema.table_constraints AS tc
JOIN information_schema.key_column_usage AS kcu
ON tc.constraint_name = kcu.constraint_name
JOIN information_schema.constraint_column_usage AS ccu
ON ccu.constraint_name = tc.constraint_name
@lhotari
lhotari / jira_spam_cleaner.groovy
Created July 29, 2014 04:04
Jira Groovy Script for cleaning comment spam from a certain user
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.comments.Comment
import com.atlassian.jira.issue.comments.CommentManager
import com.atlassian.jira.issue.search.SearchException
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.user.ApplicationUser
@solusipse
solusipse / 01_postfix_installer.md
Last active October 25, 2023 20:34
Postfix + Dovecot + Postgresql + Postfixadmin + Roundcube

Postfix Installer

Following script may be used for configuring complete and secure email server on fresh install of Debian 7. It will probably work on other distributions using apt-get. After minor changes you'll be able to use it on other Linux distros.

Usage

  1. Run postfix.sh script.
  2. Configure postgres to allow connections.
  3. Configure postfix admin. Remember to set these:
@pfigue
pfigue / dnsmasq.pp
Last active December 30, 2015 03:49
dnsmasq Puppet Manifest to serve a local zone and forward external requests to Google's DNS servers.
package { 'dnsmasq':
ensure => present,
}
$dnsmasq_conf = "no-resolv
server=8.8.4.4
server=8.8.8.8
interface=eth0
no-dhcp-interface=eth0
no-hosts
package examples
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.canned.admin.CopyProject
import org.apache.log4j.Logger
def log = Logger.getLogger("com.onresolve.jira.groovy.MyScript")
Thread executorThread = new Thread(new Runnable() {
void run() {
@jordan-thoms
jordan-thoms / convertjsoncsv.rb
Last active December 15, 2022 21:51
Code to convert json to csv, with correct headings Usage: ruby convertjsoncsv.rb <input file> <output file>
require 'csv'
require 'json'
require "set"
json = JSON.parse(File.open(ARGV[0]).read)["results"]
# Pass 1: Collect headings
headings = SortedSet.new
json.each do |hash|
headings.merge(hash.keys)
end
@gereon
gereon / gist:3150445
Created July 20, 2012 12:20
Mac OSX Spotlight Enhancement

Mac OSX Spotlight Enhancement

Add this to Info.plist in /System/Library/Spotlight/RichText.mdimporter/Contents/ and Spotlight will search for source code files.

<string>public.c-header</string>
<string>public.c-plus-plus-header</string>
<string>public.c-source</string>
<string>public.objective-c-source</string>
public.c-plus-plus-source
@egguy
egguy / mongo_db_recover_delete_record.py
Created May 25, 2012 16:04
Recover deleted data from mongo DB database
"""A little script to recover deleted recording of a mongoDB db file
There's no optimization but it work and has saved me
"""
import struct
import bson
import pymongo
import sys