Skip to content

Instantly share code, notes, and snippets.

@FarazPatankar
FarazPatankar / pushNotifications.js
Created April 30, 2020 00:49
Push notification configuration for a bare Expo app
import Constants from 'expo-constants';
import * as Notifications from 'expo-notifications';
let experienceId = undefined;
// This was a little confusing for me from the docs
// Your experience ID is basically your Expo username followed by
// the slug for the app you need the tokens for.
if (!Constants.manifest) experienceId = '@username/slug';
// Another thing to note here is that the token is actually under
@FarazPatankar
FarazPatankar / splashScreen.js
Last active October 27, 2023 09:26
Splash screen configuration for a bare expo app.
import React, { useState, useEffect } from 'react';
import { useFonts } from '@use-expo/font';
import * as SplashScreen from 'expo-splash-screen';
const App = () => {
const [isReady, setIsReady] = useState(false)
const [isLoaded] = useFonts({
'Poppins-Regular': require('./assets/fonts/Poppins-Regular.ttf'),
'Poppins-Medium': require('./assets/fonts/Poppins-Medium.ttf'),
'Poppins-SemiBold': require('./assets/fonts/Poppins-SemiBold.ttf'),
@FarazPatankar
FarazPatankar / Navbar.jsx
Created May 25, 2019 02:23
Dev.to Navbar using TailwindCSS
import React from "react";
export default function Navbar() {
return (
<div className="bg-orange-100 h-12 border-b border-gray-400">
<div className="container flex mx-auto h-full">
<div className="flex w-full items-center mx-2">
<div className="flex">
<svg
className="h-8 w-11 text-white fill-current bg-black p-2 rounded"
@FarazPatankar
FarazPatankar / robin.js
Created April 16, 2019 10:19 — forked from mikeyakymenko/robin.js
Round robin, league matches schedule on javascript
let teams = [
'Tigers',
'Foofels',
'Drampamdom',
'Lakebaka'
]
const roundRobin = (teams) => {
let schedule = []
let league = teams.slice()
@FarazPatankar
FarazPatankar / afterPrepare.js
Last active April 12, 2018 07:58
A Cordova hook to replace a file based on an environment variable.
#!/usr/bin/env node
var fs = require('fs');
var path = require('path');
console.log('Running hook...');
// TARGET is the variable that you have to specify
// If you run TARGET=prod cordova build
// The hook will look for a file named prod.js inside the config directory
if (process.env.TARGET) {

Letter Sequencing

In Ruby create a function that takes in a series of sequential letters, processes it, and returns a new string with the number of occurances of that letter in a row.

For instance: processString("aabbcc") should return 2a2b2c. If a letter has only one occurance, it should only add the letter itself, not 1. For instance processString("abbcc") should return a2b2c.

Letters in non sequential order should be returned as is. For instance processString("aabbccabbc") should return 2a2b2ca2bc.

Assumptions

@FarazPatankar
FarazPatankar / phantomjsPDF_two.js
Created January 8, 2017 19:38
Additional code for the phantomjsPDF_one.js file.
page.paperSize = {
format: 'A4',
orientation: 'portrait',
margin: {top: '10px', right: '25px', bottom: '10px', left: '25px'},
};
page.settings.dpi = 300
page.viewportSize = {
height: 800,
width: 2200
@FarazPatankar
FarazPatankar / phantomjs.log
Created January 8, 2017 19:23
Log file on generating a chart using PhantomJS
Page Opened
Waiting...
Waiting...
Waiting...
Waiting...
Waiting...
Waiting...
Waiting...
Waiting...
Waiting...
@FarazPatankar
FarazPatankar / phantomjsPDF_one.js
Last active January 8, 2017 19:17
PhantomJS configuration to get the entire chart to render.
var webpage = require('webpage');
var system = require('system');
var input = system.args[1];
var output = system.args[2];
var page = webpage.create();
var capture = function (page, input, callback) {
page.open(input, function (status) {
console.log('Page Opened');
var interval, allDone;
interval = setInterval(function () {
@FarazPatankar
FarazPatankar / options.js
Last active January 7, 2017 18:00
Options section for the chart configuration.
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero:true
}
}]
},
animation: {
onComplete: function () {