Counterpoint API (quick notes)

Looks like first you would grab the counterpoint ID from here: https://counterpointapp.herokuapp.com/api/v1/counterpoints
EERC is counterpoint_id 606. Could select by bounding box (lat/long) too. This includes a list of counts (just labeled “id”) but no actual counts, so you could do time/date collection stat comparisons from there as well.
Then you can pull up actual counts from https://counterpointapp.herokuapp.com/api/v1/counterpoints/606 where the counterpoint_id is named at the end. This gives you a list of counts, including data.
It looks like minutes start/end on the second that the count was started, so aggregation by minute (not second) should be used.
It looks like minutes without data are excluded, e.g. no 12:51:52 minute is included here (EERC 606):
{"id":281510,"count_session_id":18223,"timestamp":"2016-06-21T12:51:56.000Z","bike_generic":0,"bike_adult":0,"bike_child":0,"bike_baby":0,"bike_cargo":0,"bike_child_trailer":0,"walk_generic":0,"walk_adult":0,"walk_child":0,"walk_stroller":0,"walk_disability":0,"walk_skateboard":0,"walk_visually_impaired":0,"walk_physically_impaired":0,"vehicle_personal":2,"vehicle_car":0,"vehicle_semi":0,"vehicle_moto":0,"vehicle_transit":0,"vehicle_oversized":0,"objectId":null,"gender_m":0,"gender_f":0,"gender_o":0,"onePerson":0,"twoPerson":0,"threePerson":0,"fourPlusPerson":0},{"id":281511,"count_session_id":18223,"timestamp":"2016-06-21T12:53:56.000Z","bike_generic":0,"bike_adult":0,"bike_child":0,"bike_baby":0,"bike_cargo":0,"bike_child_trailer":0,"walk_generic":0,"walk_adult":0,"walk_child":0,"walk_stroller":0,"walk_disability":0,"walk_skateboard":0,"walk_visually_impaired":0,"walk_physically_impaired":0,"vehicle_personal":5,"vehicle_car":0,"vehicle_semi":0,"vehicle_moto":0,"vehicle_transit":0,"vehicle_oversized":0,"objectId":null,"gender_m":0,"gender_f":0,"gender_o":0,"onePerson":0,"twoPerson":0,"threePerson":0,"fourPlusPerson":0}

Resetting read_only in Elasticsearch

Rather than messing with curl, I went the long way and installed Kibana. It takes a little while to unzip. Run it in a very similar way to Elastisearch (bin\kibana.bat). Go to http://localhost:5601/app/kibana#/dev_tools.

Paste in the solution from here:

PUT /<yourindex>/_settings
{
  "index.blocks.read_only_allow_delete": null
}

You may have run into this because you are close to the disk space limits. Rather than modifying those through Kibana, you can add them directly into elasticsearch\config\elasticsearch.yml.

Rainmeter Snow Skin for JohnDee.com

Snow map from JohnDee.com.

JohnDee.com has some pretty neat maps, but the URL structure is dynamic, so this one is a little more complicated than my previous skins. Enjoy!

Update: I’m not sure why this isn’t refreshing automatically, but manually refreshing the skin must reload the variables.

;Shows the 4-day snowfall prediction from JohnDee.com.
;Much help from https://www.reddit.com/r/Rainmeter/comments/2qjbpw/help_build_url_by_concatenating_text_date_time/cn99at7/

[Rainmeter]
Update=3600
;To make this to immediately show up, change value to 0 and refresh.

[MeasureDateY]
Measure=Time
Format=%Y

[MeasureDateM]
Measure=Time
Format=%m

[MeasureDateD]
Measure=Time
Format=%d

[MeasureURL]
Measure=String
String=http://johndee.com/wp-content/uploads/[MeasureDateY]/[MeasureDateM]/MIDSNOW[MeasureDateM][MeasureDateD].jpg
DynamicVariables=1

[MeasureImage]
Measure=Plugin
Plugin=WebParser
MeasureName=MeasureURL
URL=[&MeasureURL]
Download=1

[MeterImage]
Meter=Image
MeasureName=MeasureImage
H=375
W=500

sum() with raster::aggregate() in R

If you try to use sum() directly in raster::aggregate() and have NA values, you’ll get NA as a result. You need to build a tiny function and pass the rm.na=T command to sum(). More succintly:

# Dissolve duplicate geometries and sum OOIP
 fm <- raster::aggregate(fm.raw,
                         by="OilFieldID", 
                         sums=list(list(function(x) sum(x,na.rm=T),
                                        "OOIP_pooltable")))

 

pip3 with Conda (if you still have Python 2.7 in your Windows PATH)

If you want to use pip3 with your Anaconda Python 3 installation, you can copy pip.exe and pip-script.py in [Python 3]/Scripts/ to pip3.exe and pip3-script.py in the same folder. These will then show up in your PATH, so running pip3 install [x] will now work, and running pip install [x] will still work for your Python 2 installation.

It seems like you can do a similar thing with conda, if you are forced to install it for Spyder. Rename conda.exe, conda-env.exe, etc. and add [Python 2 Miniconda]/Scripts to your path.

(Thanks to Neil D. for the tip!)

 

git branching development workflow in Rstudio

  1. open git terminal/cli
  2. git branch new-branch-name (make new branch)
  3. git checkout new-branch-name (switch to new branch)
  4. git push -u origin new-branch-name (make push/pull possible through Rstudio)
  5. make changes and save files
  6. add changes with Rstudio or git add
  7. commit changes with Rstudio or git commit -m “Commit message.”
  8. push changes with Rstudio  or git push origin new-branch-name

Quick Rainmeter Snow Skins

I’m a minor nerd about fresh snow, so I have these Rainmeter skins running on my monitor right now (really just two versions of the same skin). I thought I had them in GitHub or GitLab, but apparently not yet. If you use them, enjoy!

Two snowfall maps in two different Rainmeter skins.

Snow.ini

;Shows the 48-hour snowfall map from Intellicast.
;To customize, go to http://www.intellicast.com/Travel/Weather/Snow/Forecast.aspx?region=brd, navigate to the right region, and get the url of the image.
;Paste that as URL, below.
;
;Help from http://rainmeter.net/forum/viewtopic.php?f=5&t=20018 and http://docs.rainmeter.net/manual/getting-started/creating-skins

[Rainmeter]
Update=3600
;To make this to immediately show up, change value to 0 and refresh.

[MeasureImage]
Measure=Plugin
Plugin=WebParser
URL=http://images.intellicast.com/WxImages/48hrSnowForecast/brd.jpg
Download=1

[MeterImage]
Meter=Image
MeasureName=MeasureImage
H=375
W=500

snow_noaa.ini

;Shows the 3-day snow probability from NOAA.
;To customize, go to http://www.weather.gov/crh/outlooks?sid=fgf#.WF2NTdUrJaR
;Paste that as URL, below.
;
;Help from http://rainmeter.net/forum/viewtopic.php?f=5&t=20018 and http://docs.rainmeter.net/manual/getting-started/creating-skins

[Rainmeter]
Update=3600
;To make this to immediately show up, change value to 0 and refresh.

[MeasureImage]
Measure=Plugin
Plugin=WebParser
URL=http://www.wpc.ncep.noaa.gov/wwd/day3_psnow_gt_04.gif
Download=1

[MeterImage]
Meter=Image
MeasureName=MeasureImage
H=375
W=500

Comparing two lists with R

No, not list() lists.

a <- data.frame(name=old$NAME)
a$status <- "old"
b <- data.frame(name=allfields[allfields$StateAbbre=="ND",]$name)
b$status <- "new"

both<-merge(a,b,by="name",all=T)

Make two data frames, one for each list, create a column identifying each one (new or old), then join on the common column (name).

Output:

Example output from comparing to lists in R using a merge().
Example output from comparing to lists in R using a merge().

See also: http://stackoverflow.com/questions/17598134/compare-two-lists-in-r/17599048#17599048

Use ThemeKey to Test Drupal Themes

Every so often I want to test a new theme on a live Drupal installation, but don’t want to break the website for anyone else. You can use ThemeKey to do this, although it is probably the simplest thing you can do with this module.

Navigate to http://example.com/admin/config/user-interface/themekey.

Create a new rule:

user:name
=
your user name
theme you want to see

You’ll be the only one who sees it. If you want to try out another theme, edit the rule.

Find PDFs that are not OCRed (Windows grep)

 
Works reasonably well, although some files may have font properties without the word “Font” (capitalization matters).
 
Open CMD prompt
dir Desktop (or whatever target directory)
grep -L Font *.pdf > list_of_files.txt
 
-L = only return file names that do not match
-r = Recursive