Los Angeles, CA

Category: Code

How do I convert an existing callback API to promises?

function isIt(){ let someOp = true if(someOp) return ‘its true’ else return ‘no bueno’ } //becomes function isIt() { return new Promise(function(resolve, reject) { let someOp = true if(someOp) resolve(‘its true’) else reject(‘no bueno’) }); }

react-s3-uploader 403 error

react-s3-uploader 403 error

While looking at react-s3-uploader’s npm documentation it seemed really cool and the fastest way to get the job done so on the react side all we had to add was <ReactS3Uploader className={‘uploader’} signingUrl=”/s3/sign” signingUrlMethod=”GET” accept=”.doc,.docx,.pdf” s3path=”/uploads/” onProgress={this.onProgress} onError={this.onError} onFinish={this.onFinish} uploadRequestHeaders={{ ‘x-amz-acl’: ‘public-read’ }} ref={fileInput => (this.fileInput = fileInput)} contentDisposition=”auto” /> and on the node side…
Read more

JSON array of US states

JSON array of US states

Every form we build we are looking for a JSON or a JS array of US states that we can export from a constant file export const states = [ { text: ‘Alabama’, value: ‘AL’, }, { text: ‘Alaska’, value: ‘AK’, }, { text: ‘American Samoa’, value: ‘AS’, }, { text: ‘Arizona’, value: ‘AZ’, },…
Read more

JSON array of countries

JSON array of countries

Almost every form we build we are looking for a JS array of all countries. Here it is export const countries = [ { text: ‘United States’, value: ‘US’ }, { text: ‘Afghanistan’, value: ‘AF’ }, { text: ‘Åland Islands’, value: ‘AX’ }, { text: ‘Albania’, value: ‘AL’ }, { text: ‘Algeria’, value: ‘DZ’ },…
Read more

How to setup ESLint to use AirBnB’s React rules with a React application

How to setup ESLint to use AirBnB’s React rules with a React application

Setting up ESLint can seem daunting but luckily we can help  We hope you know why you are doing it but if not in short ESLint and Prettier can help your team maintain code quality and same formatting throughout the project. If your company has more than 1 frontend developer you will realize different developers…
Read more

Sample Code – Send Texts using Python

Send a Text Message using Python in 15 seconds

So you are a Python guru or maybe just getting started and you want to do something out of the ordinary by allowing your app to communicate with users real time. You could build an app that sends texts, maybe for an event promoter, they usually want to promote events on the weekend. Let’s say…
Read more

How to send text using c#.net

To send a text programmatically your code needs to make an XHR request to an SMS gateway that will read the text details from your request and then initiate a text to the recipient’s phone number PureText offers a Texting/SMS gateway to which you can make an HTTP GET/POST request with details such as recipient…
Read more

Sample Code – Send Text using PHP

So you are a PHP guru or maybe just getting started and you want to do something out of the ordinary by allowing your app to communicate with users real time. You could build an app for an event promoter that sends texts every Friday/Saturday evening promoting an event and even handle text responses or…
Read more

Sample Code – Send Text using C#.Net

using System; using System.Collections.Generic; using System.Net.Http; public class Program { public static void Main() { String URI = “https://api.puretext.us/service/sms/send”; String resultContent; using (var client = new HttpClient()) { var values = new Dictionary < string, string > { // To Number is the number you will be sending the text to { “toNumber”, “+X-XXX-XXX-XXXX” },…
Read more

Send text using Javascript

/* for demo and quick start place this code in your app.js or server.js please run ‘npm install puretext –save’ in terminal */ const puretext = require(‘puretext’); require(‘request’); let text = { // To Number is the number you will be sending the text to. toNumber: ‘+X-XXX-XXX-XXXX’, // From number is the number you will…
Read more