Skip to content

Instantly share code, notes, and snippets.

@shlomiv
shlomiv / solve.sh
Last active August 26, 2018 07:45
Windows bash script to automatically convert NEF to jpg, plate solve them using the wonderful "All Sky Plate Solver", and then automatically display the image's location (and orientation) in Stellarium.
#!/bin/bash
if [ $# -eq 0 ]
then
echo "Usage: solve.sh windows-style-raw-file-with-path [focal length] [pixel size]"
echo
echo 'e.g: ./solve.sh "C:\Users\astroman\Pictures\digiCamControl\crescent nebula\DSC_0027.nef"'
echo
echo "Converts NEF to small jpeg using nconvert (XnView), plate-solves it using the great 'All Sky Plate Solver' (http://www.astrogb.com/astrogb/All_Sky_Plate_Solver.html), and showing the position and rotation of the sensor in stellarium using the remote control plugin. (http://stellarium.org/doc/0.15/remoteControlDoc.html)"
echo "By Shlomi Vaknin"
@shlomiv
shlomiv / emr_bootstrap_java_8_ubuntu.sh
Created August 30, 2017 20:54
Install java 8 on an emr machine automatically.
# Check java version
JAVA_VER=$(java -version 2>&1 | sed 's/java version "\(.*\)\.\(.*\)\..*"/\1\2/; 1q')
if [ "$JAVA_VER" -lt 18 ]
then
echo "Getting add-apt-repository"
wget --no-check-certificate --no-cookies "https://blog.anantshri.info/content/uploads/2010/09/add-apt-repository.sh.txt" -O add-apt-repository.sh
echo "Adding oracle java ppa"
(def cps (map (fn[[a x]] (.displayName x)) (java.nio.charset.Charset/availableCharsets)))
(def s (slurp "test.txt"))
(time (with-open [w (io/writer "all-codes1")]
(doseq [f cps
t cps]
(try
(.write w (str f "->" t))
(.write w (String. (.getBytes s f) t))
(.write w "\n\n")
@shlomiv
shlomiv / shlomi-blender.py
Created January 11, 2017 23:14
My blender for video editing user profile.
import bpy
import os
def kmi_props_setattr(kmi_props, attr, value):
try:
setattr(kmi_props, attr, value)
except AttributeError:
print("Warning: property '%s' not found in keymap item '%s'" %
(attr, kmi_props.__class__.__name__))
except Exception as e:
@shlomiv
shlomiv / install-perf-on-ec2.sh
Last active December 9, 2016 22:27
Often in an aws emr cluster I will want to check what exactly is going on.. here is a little script that automates installing perf in any cluster node.
#!/bin/sh
# Author: Shlomi Vaknin
# Install perf with java flamegraphs on amazon ec2 instances
# let yarn using be able to sudo
sudo -s
echo "yarn ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
# install required packages
@shlomiv
shlomiv / make-perf.sh
Last active December 6, 2016 23:52
A script for automatically downloading source, building and installing perf for ubuntu linux kernels. Useful if your kernel version does not have the required pacakages (linux-tools and linux-cloud-tools) available on ppa,
#!/bin/sh
# Author: Shlomi Vaknin
# Automatically build and install perf for ubuntu linux kernels.
# Useful if your kernel version does not have the required pacakages (linux-tools and linux-cloud-tools) available on ppa,
SCRIPT=$(readlink -f "$0")
BASEDIR=$(dirname "$SCRIPT")
echo "Automatic perf build and install script. \n"
@shlomiv
shlomiv / com.apple.spaces
Created August 17, 2016 23:45
defaults read com.apple.spaces
> defaults read com.apple.spaces
{
SpacesDisplayConfiguration = {
"Management Data" = {
"Management Mode" = 1;
Monitors = (
{
"Current Space" = {
id64 = 4;
type = 0;
// Split an rdd according to its partition number
def splitByPartition[T:ClassTag](rdd: RDD[T], hotPartitions:Int): (RDD[T], RDD[T]) = {
val splits = rdd.mapPartitions { iter =>
val partId = TaskContext.get.partitionId
val left = if (partId < hotPartitions) iter else empty
val right = if (partId >= hotPartitions) iter else empty
Seq(left, right).iterator
}
val left = splits.mapPartitions { iter => iter.next().toIterator}
@shlomiv
shlomiv / count-clj-sloc.sh
Last active March 15, 2016 02:36 — forked from andrewvc/count-clj-sloc.sh
Counting SLOC in clojure is pretty easy since the syntax is so simple.
# Count SLOC
export SLF=`mktemp -t cljslocXXXX`; find src test -name "*.clj" | xargs egrep -v "(^[[:space:]]*$|^[[:space:]]*;)" | cut -d: -f1 > $SLF && echo "Files"; uniq -c $SLF; echo "Total" `cat $SLF | wc -l`; rm $SLF
(defn mapper-map [this ^Text key ^ArchiveReader warc-value ^MapContext context]
(let [i (.iterator warc-value)]
(loop []
(when (.hasNext i)
(let [^ArchiveRecord l (.next i)]
(println "got " (.available l))
(recur)))))