Skip to content

Instantly share code, notes, and snippets.

View scarnecchia's full-sized avatar

D. Scarnecchia scarnecchia

View GitHub Profile
#!/bin/sh
#call with sudo ./ec2_deploy.sh
apt-get update -y
apt-get upgrade -y
apt-get install -y xfce4 xrdp chromium-browser xfce-terminal git
service xrdp start
passwd ubuntu
@scarnecchia
scarnecchia / copy_30.sh
Created September 23, 2015 20:43
Get every 30th file from a directory. Useful for culling video stills down to one per second.
#!/bin/bash
cp $(ls | awk '{nr++; if (nr % 30 == 0) print $0}') input/ output/
@scarnecchia
scarnecchia / GDAL_Commands.txt
Created October 9, 2015 20:32
Doesn't do anything as a script, but I don't want to lose these commands
#!/bin/bash
#GDAL
gdal_translate -strict -of GTiff -co TILED=YES -co COMPRESS=LZW in.tif out.tif
gdalwarp -overwrite -cutline ../clippingShapes/enroute/ENR_L33.shp -crop_to_cutline -r lanczos -dstalpha -co ALPHA=YES -co TILED=YES -multi -wo NUM_THREADS=ALL_CPUS -wm 512 --config GDAL_CACHEMAX 512 "ENR_L33-2.tif" "ENR_L33-3UN.tif"
rm -r ENR_L33-2.tif
echo "*** Compress --- gdal_translate"
@scarnecchia
scarnecchia / README.md
Last active January 14, 2016 19:21
Getting swipe between layers working with layergroups

Mapbox's demo of swiping between layers has no example of how to implement the effect with L.LayerGroup. [layerGroup].eachLayer() would be the obvious call, but I couldn't get it to work. Fortunately, it was a simple matter of determining the length of the layer group, and iterating through.

var droneArray = droneLayers.getLayers();

function clip() {
  var nw = map.containerPointToLayerPoint([0, 0]),
      se = map.containerPointToLayerPoint(map.getSize()),
      clipX = nw.x + (se.x - nw.x) * range.value;
@scarnecchia
scarnecchia / # r - 2017-06-16_00-59-35.txt
Created June 16, 2017 12:39
r (homebrew/science/r) on macOS 10.12.5 - Homebrew build logs
Homebrew build logs for homebrew/science/r on macOS 10.12.5
Build date: 2017-06-16 00:59:35
@scarnecchia
scarnecchia / # r - 2017-06-16_08-55-14.txt
Created June 16, 2017 13:07
r (homebrew/science/r) on macOS 10.12.5 - Homebrew build logs
Homebrew build logs for homebrew/science/r on macOS 10.12.5
Build date: 2017-06-16 08:55:14
@scarnecchia
scarnecchia / church_of_england.md
Last active February 18, 2019 15:32
Eddie Izzard's Church of England Bit

"Mr. Pope! I'm going to marry my first wife, and then I'm going to divorce her. Now, I know what you're going to say but stick with me, my story gets better. I'm going to marry my second wife and then I'm gong to kill her, cut her head off! Ah, not expecting that, are ya? Third wife, gonna shoot her. Fourth wife, put her into a bag. Fifth wife, into outer space. Sixth wife, on a Rotissimat. Seventh wife, made out of jam. Eighth wife…” ( makes sound similar to putting babies on spikes )

And the Pope's going,

( Italian accent )"You crazy bugger! You can't do all this! What are you, a Mormon? You can't marry all these people! It's illegal! You can't do all this! I am the Pope, I am the head of the Church, I have to keep up… ciao! I have to keep up standards. What have you been reading, the gospel according to St. Bastard?"

So Henry VIII, who was Sean Connery for this film, said:

( imitating Sean Connery ) "Well then, I will set up a new religion in this country. I will set up the Psychotic Bastard religion."

from __future__ import print_function
import tweepy
import json
from pymongo import MongoClient
from http.client import IncompleteRead
MONGO_HOST= 'mongodb://path/to/mongodb' # assuming you have mongoDB installed locally
WORDS = ['drone', 'drones']
@scarnecchia
scarnecchia / MongoDBissue.md
Last active January 19, 2020 20:44
MongoDB's tools for subsetting document collections are not working.

This properly subsets a collection of documents in MongoDB Compass Community:

{ 'created_at': { $gte: 'Sat Dec 21 00:00:00 +0000 2019', $lte: 'Thu 31 Dec 05:00:00 +0000 2019'}}

This does not, in Python 3.6, and returns the entire collection

`df = pd.DataFrame(list(collection.find({ 'created_at': { '$gte': 'Sat Dec 21 00:00:00 +0000 2019', '$lte': 'Thu 31 Dec 05:00:00 +0000 2019'

Quick notes regarding WSL 2 and Hugo

  1. Install Hugo through Homebrew for Linux
  2. Create a firewall rule exposing Hugo's default port (1313)
  3. Run hugo serve --bind=0.0.0.0 -b http://$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1):1313/ or just ifconfig and paste the IP for eth0.