Skip to content

Instantly share code, notes, and snippets.

View ishan123456789's full-sized avatar
🏀

Ishan Mahajan ishan123456789

🏀
  • Earth
View GitHub Profile
@ishan123456789
ishan123456789 / IONIC_commonly_used.md
Last active June 7, 2019 04:48
This gist contains a brief details of a number of required items when developing in IONIC with a number of commonly faced errors as well

Here we go:

Creates a build in www folder which can be directly deployed
npm run build

Run while development

npm run ionic:serve

Android

    `ionic cordova build android`
@ishan123456789
ishan123456789 / geo-query.js
Created February 22, 2019 05:50
MongoDB GEO query with schema defined
var express = require('express');
var router = express.Router();
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var config = require('../../config/dev-config');
/**
* @param {Float} miles Distance that needs to be covered
*/
@ishan123456789
ishan123456789 / calculations.js
Created February 22, 2019 06:15
Mathematical calculation using javascript functions
function zero() {
arg = (arguments && arguments[0]) || '';
return parseInt(eval(0 + arg));
}
function one() {
arg = (arguments && arguments[0]) || '';
return parseInt(eval(1 + arg));
}
function two() {
arg = (arguments && arguments[0]) || '';
@ishan123456789
ishan123456789 / echo-present.sh
Last active April 5, 2019 05:46
Bash script to get the present working directory *absolute path* when sh file present in subfolder
#!/usr/bin/env bash
function getPresentRoot() {
if [ "$(uname -s)" = 'Linux' ]; then
basedir=$(cd $(dirname $(dirname "$(readlink -f "$0" || echo "$(echo "$0" | sed -e 's,\\,/,g')")")) && pwd)
else
basedir=$(cd $(dirname $(dirname "$(readlink "$0" || echo "$(echo "$0" | sed -e 's,\\,/,g')")")) && pwd)
fi
}
getPresentRoot
@ishan123456789
ishan123456789 / example.js
Created April 6, 2019 12:49
Global plugin in mongodb to add simple options to make code simpler when same code is required at multiple schmas
// https://mongoosejs.com/docs/plugins.html
// lastMod.js
module.exports = exports = function lastModifiedPlugin (schema, options) {
schema.add({ lastMod: Date });
schema.pre('save', function (next) {
this.lastMod = new Date();
next();
});
@ishan123456789
ishan123456789 / docker.md
Last active May 20, 2019 12:18
Common Docker commands

Existing docker images can be found at existing images at registry.hub.docker.com/ or Run the command on the terminal docker search linux

The Docker CLI has a command called run which will start a container based on a Docker Image. The structure is docker run .

By default, Docker will run a command in the foreground. To run in the background, the option -d needs to be specified.

By default, Docker will run the latest version available. If a particular version was required, it could be specified as a tag, for example, version 3.2 would be docker run -d redis:3.2

Docker first search the image locally and if not found than it searches the docker registery hub directory.

https://offcloud.com/#/sites Use 10 minute mail to transfer to mega.nz
https://tutsglaxy.com must have tutorials all present use the url above for that.
https://multicloud.com uploads to the google drive
@ishan123456789
ishan123456789 / algo.js
Last active June 29, 2019 06:37
Algorithm for checking win in a tic-tac-toe with 1 D array game
(() => {
let arr = new Array(9).fill().map(i => ({filledWith: 'x'}))
let winLength = Math.sqrt(arr.length);
console.log(arr);
debugger;
let win = checkList(arr, 2, arr.length);
console.log(win);
function checkList(arr, pos, winLength) {
let state = false;
state = checkWin(arr, pos, winLength, 4); // Checks diagnal starting from top left to bottom right
@ishan123456789
ishan123456789 / Readme.md
Last active July 30, 2019 12:00
React Native

Making a build

https://stackoverflow.com/a/36961021/6517383

#React-Native 0.49.0+
react-native bundle --dev false --platform android --entry-file index.js --bundle-output ./android/app/build/intermediates/assets/debug/index.android.bundle --assets-dest ./android/app/build/intermediates/res/merged/debug

#React-Native 0-0.49.0
react-native bundle --dev false --platform android --entry-file index.android.js --bundle-output ./android/app/build/intermediates/assets/debug/index.android.bundle --assets-dest ./android/app/build/intermediates/res/merged/debug