Skip to content

Instantly share code, notes, and snippets.

View divyanshu013's full-sized avatar
:shipit:
Ship it

Divyanshu Maithani divyanshu013

:shipit:
Ship it
View GitHub Profile
@divyanshu013
divyanshu013 / games.md
Created October 7, 2018 17:19
single player games

Mass Effect

BioShock

Black Ops

Modern Warfare

Starcraft

@divyanshu013
divyanshu013 / styles.css
Created October 7, 2018 10:22
My VScode style overrides
.mtki {
font-family: 'flottflott';
font-style: normal;
font-weight: 400;
font-size: 1.6em;
}
.send-feedback.mask-icon {
display: none;
}
@divyanshu013
divyanshu013 / gif.css
Created May 28, 2018 12:44
CSS to make GIF play/pause
.fix-nav {
// the container for static image and gif
.gif-container {
// the play icon
.fa-play {
color: #333;
font-size: 2.3rem;
position: absolute;
top: calc(50% - 2.5rem);
left: calc(50% - 2.5rem);
@divyanshu013
divyanshu013 / convert_gif_to_png.sh
Created March 20, 2018 13:37
Convert the first frame of gifs in a directory to png images
for f in *.gif; do
convert $f'[0]' $f'.png'
done
@divyanshu013
divyanshu013 / index.js
Created March 19, 2018 08:48
Server side for todos native auth app
const express = require('express');
const cors = require('cors');
const bodyParser = require('body-parser');
const morgan = require('morgan');
const jwt = require('express-jwt');
const jwksRsa = require('jwks-rsa');
const Appbase = require('appbase-js');
// middlewares
const app = express();
@divyanshu013
divyanshu013 / todos.js
Last active March 19, 2018 08:40
APIs to handle CUD operations in the todos native auth app
import CONFIG from './../constants/Config';
const getHeaders = (accessToken) => ({
'Content-Type': 'application/json',
'Authorization': `Bearer ${accessToken}`
});
const logger = message => console.log(message);
class TodoModel {
@divyanshu013
divyanshu013 / TodoItem.js
Created March 19, 2018 07:48
Passing screenProps in TodoItem for todos native auth app
class TodoItem extends Component {
onTodoItemToggle = (todo, propAction) => {
propAction({
...todo,
completed: !todo.completed,
}, this.props.screenProps); // pass screenProps here
};
render() {
const { todo, onUpdate, onDelete } = this.props;
@divyanshu013
divyanshu013 / TodosContainer.js
Created March 16, 2018 18:25
TodosContainer component for todos native auth app
...
// create auth0 service first here
import Auth0 from 'react-native-auth0';
const auth0 = new Auth0({ domain: 'divyanshu.auth0.com', clientId: '6ZR8Jgj6Gzy1onJhrO0egEbfudIBVZNP' });
...
export default class TodosContainer extends React.Component {
...
@divyanshu013
divyanshu013 / RootComponent.js
Created March 16, 2018 15:21
RootComponent for todos native auth app
...
// create auth0 service here
import Auth0 from 'react-native-auth0';
const auth0 = new Auth0({ domain: 'divyanshu.auth0.com', clientId: '6ZR8Jgj6Gzy1onJhrO0egEbfudIBVZNP' });
...
export default class RootComponent extends React.Component {
state = {
accessToken: null,
@divyanshu013
divyanshu013 / index.js
Created February 19, 2018 14:28
Utils file for merging streaming todos
class Utils {
static mergeTodos(todos, streamData) {
// generate an array of ids of streamData
const streamDataIds = streamData.map(todo => todo._id);
return (
todos
// consider streamData as the source of truth
// first take existing todos which are not present in stream data
.filter(({ _id }) => !streamDataIds.includes(_id))