Skip to content

Instantly share code, notes, and snippets.

Avatar
🔥
Working from home

Pranav Raj S pranavrajs

🔥
Working from home
View GitHub Profile
View sr.js
// datasetConfig
{
dataset
scope
key
appSort
appFilters
url
parentId
viewId
View templateGen.js
const template = require('./template.json');
class TemplateGenerator {
constructor(template, prefix = '') {
if (!template) {
throw new Error('Template is required');
}
this.prefix = prefix;
this.template = template;
@pranavrajs
pranavrajs / travis.yml
Last active Jun 30, 2020
Travis Config to deploy Frontend to S3 , Invalidate Cache
View travis.yml
sudo: required
dist: trusty
language: node_js
node_js:
- "6.9.0"
python:
- "3.5"
cache:
- pip
- yarn
@pranavrajs
pranavrajs / interceptor.js
Created Oct 7, 2017
Response interceptor
View interceptor.js
const parseErrorCode = (error) => {
if (error.response) {
if (error.response.status === 401) {
// If auth failed
} else if (error.response.status === 500) {
// If server failed
} else if (error.response.status === 422) {
// If request params are errored
@pranavrajs
pranavrajs / escapeChar.js
Created Dec 19, 2016
React-Native Escape Character
View escapeChar.js
function escapeCharAndroid(url, body) {
return fetch(url, { // Use your url here
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify(body)
})
.then(response => response.text()) // Convert to text instead of res.json()
View fetch-android-workaround.js
function escapeCharAndroid(promise) {
return promise.then(response => response.text())
.then((text) => {
if (Platform.OS === 'android') {
text = text.replace(/\r?\n/g, '').replace(/[\u0080-\uFFFF]/g, '');
}
return text;
})
.then(response => JSON.parse(response));
}
View docker-compose.yml
version: '2'
services:
web:
build: ./app/
volumes:
- ./app:/app
- /app/node_modules
ports:
- "1337:1337"
@pranavrajs
pranavrajs / Dockerfile
Created Apr 28, 2016
Dockerfile sails application
View Dockerfile
FROM node:argon
# Install Sails globally
RUN npm install -g sails
# Create app directory
RUN mkdir -p /app
# Change Work directory to app
WORKDIR /app