Skip to content

Instantly share code, notes, and snippets.

package spark.examples
import org.apache.spark._
import org.apache.spark.SparkContext._
import org.json4s.jackson.JsonMethods
import org.json4s.jackson.JsonMethods._
import org.json4s.JsonAST._
object HDFSDeleteExample {
@amiorin
amiorin / gist:83efd81554b57fe3a42d
Created November 24, 2014 08:52
Pretty print json files
jq . <<< '{ "foo": "lorem", "bar": "ipsum" }'
{
"foo": "lorem",
"bar": "ipsum"
}
python -m json.tool <<< '{ "foo": "lorem", "bar": "ipsum" }'
{
"bar": "ipsum",
"foo": "lorem"
@amiorin
amiorin / main.yml
Last active August 29, 2015 14:12
Ansible idempotent iptables add rule
---
- name: Check forward udp port 53
command: iptables -t nat -C PREROUTING -i {{ eth }} -p udp --dport 53 -j REDIRECT --to-port 8600
register: result
failed_when: False
changed_when: False
when: server
tags: iptables
- name: Forward udp port 53
/**
* Required Variables.
*/
variable "name" {}
variable "port" {}
variable "elb_security_group" {}
variable "elb_subnets" {}
<?xml version="1.0"?>
<root>
<item>
<name>PageUp/PageDown to Right/Left</name>
<identifier>remap.pagetocursor</identifier>
<autogen>__KeyToKey__ KeyCode::PAGEUP, KeyCode::CURSOR_LEFT</autogen>
<autogen>__KeyToKey__ KeyCode::PAGEDOWN, KeyCode::CURSOR_RIGHT</autogen>
</item>
</root>
@amiorin
amiorin / proxy.pac
Last active December 21, 2018 14:39
function regExpMatch(url, pattern) {
try { return new RegExp(pattern).test(url); } catch(ex) { return false; }
}
function FindProxyForURL(url, host) {
// Important: replace 172.31 below with the proper prefix for your VPC subnet
if (shExpMatch(url, "*172.31.*")) return "SOCKS5 localhost:8157";
if (shExpMatch(url, "*saiki.zalan.do*")) return "SOCKS5 localhost:8157";
if (shExpMatch(url, "*ec2*.amazonaws.com*")) return 'SOCKS5 localhost:8157';
if (shExpMatch(url, "*.compute.internal*") || shExpMatch(url, "*://compute.internal*")) return 'SOCKS5 localhost:8157';
@amiorin
amiorin / S3Puller.scala
Created August 8, 2016 15:22 — forked from pjrt/S3Puller.scala
S3 List Status ad-infinitude
import com.amazonaws.services.s3._, model._
import com.amazonaws.auth.BasicAWSCredentials
val request = new ListObjectsRequest()
request.setBucketName(bucket)
request.setPrefix(prefix)
request.setMaxKeys(pageLength)
def s3 = new AmazonS3Client(new BasicAWSCredentials(key, secret))
val objs = s3.listObjects(request) // Note that this method returns truncated data if longer than the "pageLength" above. You might need to deal with that.
@amiorin
amiorin / s3-curl-backups.md
Created April 10, 2017 13:52 — forked from jareware/s3-curl-backups.md
Simple, semi-anonymous backups with S3 and curl

⇐ back to the gist-blog at jrw.fi

Simple, semi-anonymous backups with S3 and curl

Backing stuff up is a bit of a hassle, to set up and to maintain. While full-blown backup suites such as duplicity or CrashPlan will do all kinds of clever things for you (and I'd recommend either for more complex setups), sometimes you just want to put that daily database dump somewhere off-site and be done with it. This is what I've done, with an Amazon S3 bucket and curl. Hold onto your hats, there's some Bucket Policy acrobatics ahead.

There's also a tl;dr at the very end if you just want the delicious copy-pasta.

Bucket setup

@amiorin
amiorin / hit.sh
Created October 5, 2017 15:27 — forked from pesterhazy/hit.sh
hit - git-style interface for project helper scripts
#!/usr/bin/env bash
set -euo pipefail && cd "$(dirname "${BASH_SOURCE[0]}")/.."
# hit - git-like command dispatcher. Who needs Makefiles?
#
# Create a directory `bin/` at the top level of your project
# directory (the one committed to git). Copy this file into
# that folder, call it `hit` and make it executable.
#
# Type `bin/hit NAME` to run a subcommand called NAME. Subcommands
@amiorin
amiorin / hive-site.xml
Created October 2, 2019 21:21
EMR settings
[
{
"Classification": "hive-site",
"Properties": {
"hive.users.in.admin.role": "amiorin,hive"
}
}
]