Tuesday, January 30, 2018

Admin email notifications with firebase database write queries (JavaScript)

Prerequisites:
  •  NodeJS with NPM installed.  
  •  Google Firebase Account
    With your favorite web app framework you can configure your web app to auto generate emails based on site user feedback.

I've used ReactJS in this case for a generic contact us model form submission.  A quick tutorial on getting started with React JS and setting up this model can be found at:

https://www.codementor.io/yurio/all-you-need-is-react-firebase-4v7g9p4kf



   In this project I adapted recipes given for firebase user authenticated additions... from sites:

https://www.menubar.io/firebase-functions-sending-emails/

and

https://github.com/firebase/functions-samples/tree/master/quickstarts/email-users

Follow the quickstart tutorial in the functions-samples link.  Namely, in setting up your gmail account to send emails via node mailer.
Once say you have your react project or whatever project using firebase set up.  You'd need to go to that particular folder and initialize firebase functions...to do this actually will require potentially a couple of proceeding console commands at the root of your project directory:

npm install firebase-functions@latest firebase-admin@latest --save
npm install -g firebase-tools
then

firebase init functions

Go into the functions directory (via command prompt or console/terminal) and type:

npm install nodemailer --save

node package manager will initialize the project with the functions folder and install (provided your acceptance) the necessary node packages.  Note:  highly recommend that you double check your git ignore file and configure the ignore for the functions folder if you are using git.

An adapted code (from the above links), for instance, in sending email notifications looks like this:

const functions = require('firebase-functions');

const nodemailer = require('nodemailer');
// Configure the email transport using the default SMTP transport and a GMail account.
// For Gmail, enable these:
// 1. https://www.google.com/settings/security/lesssecureapps
// 2. https://accounts.google.com/DisplayUnlockCaptcha
// For other types of transports such as Sendgrid see https://nodemailer.com/transports/
// TODO: Configure the `gmail.email` and `gmail.password` Google Cloud environment variables.
const gmailEmail = `****@gmail.com`;
const gmailPassword = `*****`;
const mailTransport = nodemailer.createTransport({
  service: 'gmail',
  auth: {
    user: gmailEmail,
    pass: gmailPassword
  }
});

// // Create and Deploy Your First Cloud Functions
// // https://firebase.google.com/docs/functions/write-firebase-functions
//
// exports.helloWorld = functions.https.onRequest((request, response) => {
//  response.send("Hello from Firebase!");
// });
const APP_NAME = 'Cloud Storage for Firebase quickstart';
exports.sendFEmail = functions.database.ref('messages/{uid}').onWrite(event => {

    // only trigger for new users [event.data.previous.exists()]
    // do not trigger on delete [!event.data.exists()]
    if (!event.data.exists() || event.data.previous.exists()) {
      return
    }
  
    var user = event.data.val()
    console.log(user);
    var {email} = user

      const mailOptions = {
        from: `${APP_NAME} `,
        to: `****@gmail.com`
      };
    
      // The user subscribed to the newsletter.
      mailOptions.subject = `**** Contact Notice!`;
      mailOptions.text = `${user.name} sent a message!. Here is the message:  ${user.message}.  This is the sender's email address:  ${user.email}`;
      return mailTransport.sendMail(mailOptions).then(() => {
        console.log('message sent!');
      });
    })

You'll put this code say in an index.js file in the functions directory...just replace the existing default code set.

Now you can easily deploy this up to firebase...
In your project's root directory in console just type:

firebase deploy --only functions

This pushes the function up as firebase function...what does this code do?

Reading the line  "functions.database.ref('messages/{uid}').onWrite(event..."

This is an event handler set on the database called when ever a write event occurs on the database 'messages' database key.  When a post request is created on the firebase database writing a new database entry, the event handler function is called.

The event handler in this case, if you are doing further reading, refers the database entry set as 'user'.
The object 'mailOptions' is passed in turn to the mailTransport inside the method sendMail...noting for nodemailer this is parameter nature of sending mail.

Suggested reading for further firebase api documentation as related to real time database event handling:
https://firebase.google.com/docs/functions/database-events


Sunday, January 21, 2018

Future Speculations for future devs

    Toss out the notion of "experience" or being "experienced"...this will be a malinger to outmoded industry practice.  It isn't what we know anymore that matters.  Your mastery is less regarded by specialty to anyone thing, but given to new things.  New Frameworks will emerge as old one's die, though an ecology settles into more common practices.  There is too much to learn with little time for a given dev industry to claim expert.  Pay attention to your communication or lack thereof...the future is about hand holding given so much flux!  No one is interested in stable industry practice...they are interested in disruptive practices!  AI handles the rest!  The future is dizzying with new technologies and scary at that!  You will have switched to one framework after another in a given days pace! And having exposed your self to a new language all the same on a daily basis!

Saturday, January 20, 2018

The Self Paradigm

   The essence of being is always accounted for in ways given constraints.   Mythology of the self.  Apparently given rise of a new dangerous youth...that we are likely fragmented in a way by technology that imperils our connectivity to others around us, yet seems conspicuously born of a similar fantasy that has alongside plagued civilization since its inception.  Neither is it so easy to say that our minds haven't changed.  The self paradigm is given by the paradox of something that has long been unsettled, always mutable and shifting as easily.  What is healthy of our behavioral patterns in such question, one might ask?  That we persist in asking the same questions of ourselves while insular indoctrination abounds beyond the conspiracy of tethering mobile devices? 
More than the smartphone alone is responsible in rewiring the self as we have perceived it...what do we admit of the mythology of the self paradigm?

We start at the premise of my invented country and we start at the premise of my invented self.   

Sunday, December 31, 2017

DIY Audio self publication starting out


   I recommend having a modest exploratory budget in mind if you intend to seek out a niche in the self publishing world of music and are a newcomer. 

   Gear requirements for a modest (non smartphone setup): 
   -Microphone(s)
   -DAW (Digital Audio Workstation) software (e.g. Ableton Live 9 or Protools) or some DAW platform  (e.g.  Tascam and a number of manufacturers can be found providing gear through places like sweetwater.com).
   -USB interface (if using DAW software option).
   -Laptop or Desktop or possibly Tablet (check your DAW software hardware requirements to make sure both USB interface and hardware meet software specifications).
 
That's technically about it to get started.

A little primer on mics:

Shure microphones have been a nice versatile gig and studio recording microphone.  While home studio recording budgets are more easily fashioned using any number of condenser mics now on the market.  A basic setup will require likely a laptop/desktop/tablet if you want decent audio recording though the reality of smartphone recordings are equally here to stay.  Native smartphone recordings are likely going to be very rudimentary for room recordings relative to home studio setups.  Unless you know what you are looking for in a microphone...I highly recommend entry level stuff if you are new to the business.

DAW software...I recommend going with larger scale suite options that provide unlimited track options and studio effects packages.  At least this allows you to in house much of your track mastering and studio effects needs for audio production purposes.

USB interface...what are your purposes and needs...if you are a solo musician that need only record yourself and maybe a single instrument at a time, the simplest interfaces likely work (e.g. 2 mic inputs and 2 1/4" stereo inputs) probably will work fine.  If you need to do live session recording work with more than 1 musician, you may want to investigate larger scale interfaces that furnish more simultaneous inputs. 

Laptop and Desktop.  I've used mid line processors for laptops or desktops alike.  Your audio interface will do the Analog to Digital work so really whatever remains necessary for computation in audio is generally pretty well handled for many home studio applications...your audio interface hardware setting will need be set to ASIO for input (which directly has the audio interface) handling (much like a video card has a gpu) audio based computational work. 

Learning to record:
I'll omit particular guides on recording and mastering (beyond scope of what I wanted to cover right now).    If you make time and effort to record, you'll likely be recording something and learning to use your gear.  Otherwise, not.  Anytime spent recording is better than no time or time that need be structured in highly choreographed ways.  The more people that have to be recorded will likely mean tighter and more restrictive scheduling unless you work around this...in other words, do you have to have everybody in a music group there to record at any given time in order to record and the same goes for mastering?  Spend your time doing scratch work to learn.  Plenty of scratch is how you learn to get better at what you are doing.  The best time learning about audio engineering may come in your own company doing this work whenever you can...doing this on your time not others.

Publishing to Video sites.  Many musicians actually use either slideshows or a single photo still for, for example, Youtube publication.  Here are some things to keep in mind:

Windows, Mac, and iOS furnish native movie making programs that allow you to import your audio file.  The simplest self publication  here uses a photo still of your choosing and creating a video length of that still filling out the time span of the audio file being interlaced with that image still.  You can get, of course, more creative and build slideshows or integrating video of your choosing.

More premium video production services:

You can invest in things like Adobe premiere or Adobe Cloud subscription.  Here you can build more complex choreography of video work here.  There is likely a bit more of a learning curve both understanding how to work with animated transitions that weren't template ones.  Though Adobe does provide templates as well if you hadn't wanted to learn the ins and outs of editing timeline curves for animating effects and transitions.  You may want to learn things like audio video synchronization when using separate audio and video recording (non interlaced sources).   

At the moment.  H264 is a common high definition standard for video publication.  Likely your video editor will give you mastering format options for the video type that you want to produce for a given social media platform (at least it should). 

Self publications to sites like Google Play, Amazon, Apple Store and Spotify:

Sites like DistroKid  allow you to publish your music by handling all legal work necessary to get your music copyright recognized...you pay a yearly subscription fee (entry level is a small annual fee) and you keep royalties on your music sales.

Self marketing: 

Uploading your music to Youtube, or getting yourself setup for any given market online or otherwise, isn't a likely guarantee to music sales, and unfortunately, even marketing online may not be either.  Far from quality audio recordings can actually be quite successful and mostly this relates to how any recording artist(s) sell themselves in a social way.  If you are niched in a collector's market, you may have decent odds depending on the media type that you are selling (e.g., vinyl and CD may provide better returns than by mp3).  Though as I've read, you likely want to avoid being excessive with twitter, facebook or any other social media spam when engaging with people socially.  Positives would include getting reviewed and featured in zines, music journals and so forth, and potentially having higher levels of exposure through sites with larger scale traffic.  Word of mouth and festivals are likely a bigger positive to social exposure.  Having someone's ear is different than having hoped they stumbled upon you in a vast sea of audio. 

 Home studios have been liberated with higher quality audio production tools that are more affordable, but the pool of interest in doing such has also increased.  If the acceptance of a culture around poorer quality audio production recordings is a testament that successful social exposure need not correlate to higher quality gear, if you are entry level into this market, I wouldn't bother trying to raise significant money to pay either for a recording or for the gear to do such.  It is a waste unless you know what you are doing. 


Wednesday, December 27, 2017

New Economy part 3 in series

  Given the ever increasing rise of machine intelligence,  humans will increasingly not be able to compete across greater spectrums of machine automated production modes.  This isn't merely in manufacturing or transportation sectors but increasingly affecting service sector economies.  Nonetheless I think we are entering into a new chapter in social and economic history...could we be ready to affirm in our own soon to be social history the birth of the Machine Intelligence Revolution?  This has broad impact to civilization and the ways that we will live in the future.

Questions to consider:  why is there mostly scant thoughts with respect to existing impacts?  And why consideration without so much consideration to social and economic displacements?   Is it sufficient and fair to argue that the luxuries of such revolution should only increase worker productivity while marginally having impact to worker population numbers, for instance? 

New Economy part 2 in series

   Certainly if less permanence were true and that anything were paid by task and template, the notion of employment as worthwhile comes measurably one's effective response and analysis.  Income diversification were arguably present to the degree that a measure of self worth were given less so by the perception of self worth but by the measure of worth.  How many tasks have you completed (for metrics)?  What is your rating (for metrics)?   Answer to be presented...or rather a range of task submissions for a task presented before a contract or even necessary details should be a given.  AI chatbots find ways in abstracting project goals in such a way without compromising proprietary concerns (or that anything of the NDA) need ever be signed.  The creative mind is valued, yes, for its supposedly intangible alchemy, but ever increasingly the template world and all approximation of the creative mind is encroached upon.  Where ever the creative mind?

Left at the base of the artful mind.  How are lives are an artful process has some intrinsic meaning...as it were to the design of self engineering.  What happens to works and so much definition and value is placed to the abstraction of lives relative works...works transcend lives but in the future?  

And while we cling to what we can touch and feel for its value, that alone, drives the future of gold...or that artificial scarcity is replicated by way of the lesser cosmic events creating such elements in the first place or that atoms elsewhere could be so diffuse as to maintain even higher levels of scarcity...future makes arbitrary the alchemical mind which has spun gold from ideas alone!  There is only delusional consensus that anything has value in the future...and that is the future economy.  The notion that we must believe much has value when scarcity no longer exists.  What is the future of desire?  What is the future of wanting?   



Oblivion

 Between the fascination of an upcoming pandemic ridden college football season, Taylor Swift, and Kim Kardashian, wildfires, crazier weathe...