Skip to content

Instantly share code, notes, and snippets.

View mfurlend's full-sized avatar

Mikhail Furlender mfurlend

  • WeatherBELL Analytics
  • New York, NY
View GitHub Profile
const query = datastore
.createQuery('Task')
.filter('done', '=', false)
.filter('priority', '=', 4);
@mfurlend
mfurlend / firebase-gcs-imagemagik-index.js
Created February 6, 2018 02:36
#firebase #google #cloud storage #cloud functions #imagemagik
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
const gcs = require('@google-cloud/storage')();
const exec = require('child-process-promise').exec;
const LOCAL_TMP_FOLDER = '/tmp/';
/**
* When an image is uploaded in the Storage bucket the information and metadata of the image (the
@mfurlend
mfurlend / firebase-gcs-thumbnail-index.js
Created February 6, 2018 02:33
#google #cloud functions #cloud storage #gcs #firebase
'use strict';
const admin = require('firebase-admin');
const functions = require('firebase-functions');
const gcs = require('@google-cloud/storage')({keyFilename:
'adotapet-476b5-firebase-adminsdk-p67hf-60281ac514.json'});
const spawn = require('child-process-promise').spawn;
admin.initializeApp(functions.config().firebase);
exports.generateThumbnail = functions.storage.object()
@mfurlend
mfurlend / helloGCS-index.js
Created February 6, 2018 02:25
#cloud functions #trigger #cloud storage
exports.helloGCS = (event, callback) => {
const file = event.data;
if (file.resourceState === 'not_exists') {
console.log(`File ${file.name} deleted.`);
} else if (file.metageneration === '1') {
// metageneration attribute is updated on metadata changes.
// on create value is 1
console.log(`File ${file.name} uploaded.`);
} else {
@mfurlend
mfurlend / cloud-storage-index.js
Created February 6, 2018 02:24
#cloud storage #cloud functions #google #word-count-read
const Storage = require('@google-cloud/storage');
const readline = require('readline');
// Instantiates a client
const storage = Storage();
// [END functions_word_count_setup]
function getFileStream (file) {
if (!file.bucket) {
throw new Error('Bucket not provided. Make sure you have a "bucket" property in your request');
@mfurlend
mfurlend / datastore-index.js
Created February 6, 2018 02:19
#cloud functions #datastore #google
'use strict';
const Datastore = require('@google-cloud/datastore');
// Instantiates a client
const datastore = Datastore();
/**
* Gets a Datastore key from the kind/key pair in the request.
*
@mfurlend
mfurlend / bash-argument-shortcuts.md
Last active October 24, 2019 21:24
Bash CLI re-use last line's arguments
shortcut description
!^ first argument
!$ last argument
!* all arguments
!:2 second argument
!:2-3 second to third arguments
!:2-$ second to last arguments
!:2* second to last arguments
!:2- second to next to last arguments
@mfurlend
mfurlend / conda_cheatsheet.md
Last active November 29, 2017 20:36
conda cheatsheet
Task Conda command Pip command Virtualenv command
Install a package conda install $PACKAGE_NAME pip install $PACKAGE_NAME X
Update a package conda update --name $ENV_NAME $PACKAGE_NAME pip install --upgrade $PACKAGE_NAME X
Update package manager conda update conda Linux/macOS: pip install -U pip Win: python -m pip install -U pip X
Uninstall a package conda remove --name $ENV_NAME $PACKAGE_NAME pip uninstall $PACKAGE_NAME X
Create an environment conda create --name $ENV_NAME python=3.6 X cd $ENV_BASE_DIR; virtualenv $ENV_NAME
Activate an environment source activate $ENV_NAME X source $ENV_BASE_DIR/$ENV_NAME/bin/activate
Deactivate an environment source deactivate X deactivate
Search available packages conda search $SEARCH_TERM pip search $SEARCH_TERM X
@mfurlend
mfurlend / Mysql.c
Created June 2, 2017 23:05
wgrib2's Mysql.c fix
/******************************************************************************************
Copyright (C) 2008 Niklas Sondell, Storm Weather Center
This file is part of wgrib2 and could be distributed under terms of the GNU General Public License
Example of mysql table structure for use with this script:
create table wgrib2 (rt datetime, vt datetime, lat double, lon double, param varchar(80), level varchar(30), value double);
v1.0 5/2008
10/2009 Jerry Stueve, tmpnam -> mkstemp, "LOAD DATA <<LOCAL>>" added
@mfurlend
mfurlend / git-selective-merge.md
Created January 28, 2017 22:46 — forked from katylava/git-selective-merge.md
git selective merge

Example: You have a branch refactor that is quite different from master. You can't merge all of the commits, or even every hunk in any single commit or master will break, but you have made a lot of improvements there that you would like to bring over to master.

Note: This will not preserve the original change authors. Only use if necessary, or if you don't mind losing that information, or if you are only merging your own work.

On master:

> git co -b temp