Skip to content

Instantly share code, notes, and snippets.

View VinayakBagaria's full-sized avatar
💭
So much to experiment on..

Vinayak Bagaria VinayakBagaria

💭
So much to experiment on..
View GitHub Profile
@debajyotibasak
debajyotibasak / randomOtp.txt
Created May 13, 2018 12:48
Generate 4 digit Random OTP
private String generateOTP() {
int len = 4;
String numbers = "0123456789";
Random random = new Random();
char[] otp = new char[len];
for (int i = 0; i < len; i++) {
otp[i] = numbers.charAt(random.nextInt(numbers.length()));
}
return String.valueOf(otp);
}
@steveluscher
steveluscher / realworld.graphql
Last active June 22, 2018 08:05
The schema for thebergamo/realworld-graphql
type Article {
author: Profile!
body: String!
comments(first: Int, after: String): CommentsConnection
createdAt: String!
description: String!
favorited: Boolean!
favoritesCount: Int!
slug: String!
tags: [String],
@acdlite
acdlite / app.js
Last active January 20, 2023 08:23
Quick and dirty code splitting with React Router v4
// getComponent is a function that returns a promise for a component
// It will not be called until the first mount
function asyncComponent(getComponent) {
return class AsyncComponent extends React.Component {
static Component = null;
state = { Component: AsyncComponent.Component };
componentWillMount() {
if (!this.state.Component) {
getComponent().then(Component => {
@nuc
nuc / plaintext-contenteditable.css
Last active April 18, 2019 01:24 — forked from Schniz/plaintext-contenteditable.css
Plain-Text ContentEditable div for React.js
.comPlainTextContentEditable {
-webkit-user-modify: read-write-plaintext-only;
}
.comPlainTextContentEditable--has-placeholder::before {
content: attr(placeholder);
opacity: 0.5;
color: inherit;
cursor: text;
}
@jcataluna
jcataluna / gist:1dc2f31694a1c301ab34dac9ccb385ea
Created July 8, 2016 17:23
Script to save all images from a docker-compose.yml file
#!/bin/bash
mkdir -p out
for img in `grep image $1| sed -e 's/^.*image\: //g'`;
do
cleanname=${img/\//-}
tag=`docker images | grep $img | awk '{print $2}'`
echo "Exporting image: $img, tag:$tag ($cleanname)..."
docker save $img -o out/$cleanname.tar
@bastman
bastman / docker-cleanup-resources.md
Created March 31, 2016 05:55
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@Schniz
Schniz / plaintext-contenteditable.css
Last active April 8, 2022 17:46
Plain-Text ContentEditable div for React.js
.comPlainTextContentEditable {
-webkit-user-modify: read-write-plaintext-only;
}
.comPlainTextContentEditable--has-placeholder::before {
content: attr(placeholder);
opacity: 0.5;
color: inherit;
cursor: text;
}
@koistya
koistya / App.js
Last active June 8, 2022 09:55
How to add `onscroll` event in ReactJS component
import React from 'react';
let lastScrollY = 0;
let ticking = false;
class App extends React.Component {
componentDidMount() {
window.addEventListener('scroll', this.handleScroll, true);
}
["Life isn’t about getting and having, it’s about giving and being.", "Kevin Kruse"]
["Whatever the mind of man can conceive and believe, it can achieve.", "Napoleon Hill"]
["Strive not to be a success, but rather to be of value.", "Albert Einstein"]
["Two roads diverged in a wood, and I—I took the one less traveled by, And that has made all the difference.", "Robert Frost"]
["I attribute my success to this: I never gave or took any excuse.", "Florence Nightingale"]
["You miss 100% of the shots you don’t take.", "Wayne Gretzky"]
["I’ve missed more than 9000 shots in my career. I’ve lost almost 300 games. 26 times I’ve been trusted to take the game winning shot and missed. I’ve failed over and over and over again in my life. And that is why I succeed.", "Michael Jordan"]
["The most difficult thing is the decision to act, the rest is merely tenacity.", "Amelia Earhart"]
["Every strike brings me closer to the next home run.", "Babe Ruth"]
["Definiteness of purpose is the starting point of all achievement.", "W.