Skip to content

Instantly share code, notes, and snippets.

View mgmarino's full-sized avatar

Michael Marino mgmarino

View GitHub Profile
@mgmarino
mgmarino / HadoopUtils.java
Last active October 30, 2023 13:26
Example to use Iceberg on AWS KDA (Managed Flink)
package org.apache.flink.runtime.util;
import org.apache.hadoop.conf.Configuration;
public class HadoopUtils {
public static Configuration getHadoopConfiguration(
org.apache.flink.configuration.Configuration flinkConfiguration) {
return new Configuration(false);
}
}
@mgmarino
mgmarino / find_xport.py
Last active November 25, 2022 07:34
Find Lantronix XPort devices with a python script.
import socket
import numpy
numpy.set_printoptions(formatter={'int':lambda x:hex(int(x))})
def find_lantronix(timeout=4):
"""
Broadcasts to find xport devices on the current subnet.
"""
# Set up the socket
@mgmarino
mgmarino / Makefile
Last active January 1, 2022 08:56
Build BOOST shared memory using vectors on hopper.
# Makefile for linking against ROOT
# M. Marino 22 May 2007
TARGETS = main
SOURCES = $(wildcard *.cc) #uncomment these to add all cc files in directory to your compile list
SOURCES += $(wildcard *.C) #uncomment these to add all cc files in directory to your compile list
OBJS = $(SOURCES:.cc=.o)
TARGETOBJ = $(patsubst %, %.o, $(TARGETS))
@mgmarino
mgmarino / Move files using Dropbox SDK.md
Last active October 19, 2021 03:11
Move all files to another folder using Dropbox python SDK

Move files from one folder to another using Dropbox python SDK

A script to move all files from one folder to another in dropbox. It expects a JSON file credentials.json in the same directory of the form:

{
  "accessToken": "ACCESS_TOKEN",
  "sourceFolder": "/src_folder",
  "destinationFolder": "/dest_folder"
}
AWSTemplateFormatVersion: '2010-09-09'
Description: Voila Microservice Stack
Parameters:
Environment:
Type: String
AllowedValues:
- staging
- production
ECRRegistry:
@mgmarino
mgmarino / mpi4py_master_slave.py
Last active December 2, 2020 14:53
mpi4py standard slave/worker
#!/usr/bin/env python
"""
Standard Master/Slave design in mpi4py, collects results in a list and pickles them to a file.
"""
import ROOT
from mpi4py import MPI
import sys
import cPickle as pick
@mgmarino
mgmarino / save_doc.py
Last active August 16, 2020 17:01
Save a data document in a database with couchdb/python
"""
Save a document with couchdb in python
"""
import couchdb
import datetime
import time
import json
import random
import pytz
import configparser
import os
import boto3
import sys
def fail(msg):
print(msg)
sys.exit(1)
aws_profile = os.getenv("AWS_DEFAULT_PROFILE")
@mgmarino
mgmarino / daemon_test.py
Created July 30, 2015 14:37
Example for using python-daemon and runner.DaemonRunner
import time
import os
import logging
from daemon.runner import DaemonRunner
_base_path = "/path/to/daemon"
class MyApp(object):
"""
Define the required attributes
@mgmarino
mgmarino / example_slac.py
Created June 21, 2012 13:39
Example pyROOT script.
import ROOT
import sys
# Following necessary for loading dictionaries of classes stored in tree could
# also go in .rootlogon.C file
ROOT.gSystem.Load("libEXOUtilities")
def do_analysis(atree):
c1 = ROOT.TCanvas()