Skip to content

Instantly share code, notes, and snippets.

View pranavrajs's full-sized avatar
🛖
Working from home

Pranav pranavrajs

🛖
Working from home
View GitHub Profile
@pranavrajs
pranavrajs / Dockerfile
Created April 28, 2016 17:50
Dockerfile sails application
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
@pranavrajs
pranavrajs / docker-compose.yml
Created April 28, 2016 17:50
docker-sails-mongo
version: '2'
services:
web:
build: ./app/
volumes:
- ./app:/app
- /app/node_modules
ports:
- "1337:1337"
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));
}
@pranavrajs
pranavrajs / escapeChar.js
Created December 19, 2016 14:09
React-Native Escape Character
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()
@pranavrajs
pranavrajs / interceptor.js
Created October 7, 2017 17:56
Response interceptor
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 / travis.yml
Last active June 30, 2020 17:04
Travis Config to deploy Frontend to S3 , Invalidate Cache
sudo: required
dist: trusty
language: node_js
node_js:
- "6.9.0"
python:
- "3.5"
cache:
- pip
- yarn
@pranavrajs
pranavrajs / templateGen.js
Created October 18, 2017 12:03
Template Generator
const template = require('./template.json');
class TemplateGenerator {
constructor(template, prefix = '') {
if (!template) {
throw new Error('Template is required');
}
this.prefix = prefix;
this.template = template;
// datasetConfig
{
dataset
scope
key
appSort
appFilters
url
parentId
viewId
/* To disable on mobile phone */
@media screen and (max-width: 576px) {
.woot-widget-bubble {
display: none
}
}
/* To disable on iPad/other tablets */
@media screen and (max-width: 992px) {
@pranavrajs
pranavrajs / conversation_update.liquid
Last active July 11, 2022 06:27
Show Conversation details
<p><b>Inbox Name is:</b> {% inbox.name %}</p>
<p><b>Previous messages:</b></p>
{% for chat_message in conversation.recent_messages %}
<div>
<h4 style="margin: 0;">
{% if chat_message.sender == user.available_name %}
You
{% else %}