Skip to content

Instantly share code, notes, and snippets.

View varunon9's full-sized avatar

Varun kumar varunon9

View GitHub Profile
@varunon9
varunon9 / GalleryModule.java
Created January 8, 2018 17:04
An android native module for react-native. It returns an array of all images from gallery with latest images first (sorting based on DATE_TAKEN).
package com.imagecompressor;
import android.content.ContentResolver;
import android.database.Cursor;
import android.net.Uri;
import android.os.AsyncTask;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
@varunon9
varunon9 / app.js
Created May 26, 2018 17:31
app.js file for node.js server using express.
/**
* Created by: Varun kumar
* Date: 23 May, 2018
*/
const express = require('express');
const path = require('path');
//const favicon = require('serve-favicon');
const bodyParser = require('body-parser');
@varunon9
varunon9 / schema.js
Created May 26, 2018 17:36
A simple graphql schema using graphql-tools
/**
* Created by: Varun kumar
* Date: 23 May, 2018
*/
const { makeExecutableSchema } = require('graphql-tools');
const utilityService = require('../services/utilityService');
const userService = require('../services/userService');
@varunon9
varunon9 / verify-token.js
Created May 26, 2018 17:52
Security middleware for authentication using jsonwebtoken. This gist demonstrate its usage in graphql-express server
const jwt = require('jsonwebtoken'); // used to create, sign, and verify tokens
const env = process.env.NODE_ENV || 'development';
const config = require('../config/config.json')[env];
module.exports = {
verifyToken: function(req, res, next) {
// get token from cookies
@varunon9
varunon9 / user-service.js
Created May 26, 2018 18:00
A service object to interact with MySql database using sequelize module.
const env = process.env.NODE_ENV || 'development';
const config = require('../config/config.json')[env];
const validationService = require('./validationService');
const models = require('../models');
const bcrypt = require('bcrypt');
module.exports = {
@varunon9
varunon9 / CalendarDayComponent.js
Created February 24, 2019 19:41
react-native-toggle-calendar- customized calendar built on top of react-native-calendars to support horizontal and grid calendar view
import React from 'react';
import { View, Text, StyleSheet, TouchableOpacity } from 'react-native';
import PropTypes from 'prop-types';
const weekDaysNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
class CalendarDayComponent extends React.Component {
constructor(props) {
super(props);
this.onDayPress = this.onDayPress.bind(this);
@varunon9
varunon9 / CalendarDayComponent.js
Created March 19, 2019 17:02
Sample Calendar Day and Header components for react-native-toggle-calendar
import React from 'react';
import { View, Text, StyleSheet, TouchableOpacity, Image } from 'react-native';
import PropTypes from 'prop-types';
const weekDaysNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
class CalendarDayComponent extends React.PureComponent {
constructor(props) {
super(props);
this.onDayPress = this.onDayPress.bind(this);
@varunon9
varunon9 / Category.php
Created January 16, 2018 18:18
Implementing Naive Bayes Classification algorithm into PHP to classify given text as ham or spam. To see complete project visit: https://github.com/varunon9/naive-bayes-classifier
<?php
class Category {
public static $HAM = 'ham';
public static $SPAM = 'spam';
}
?>
@varunon9
varunon9 / graphql-query-client-side.js
Created May 26, 2018 17:41
Querying to graphql server from browser using JQuery Ajax
var globals = {}; // application wide global variable
globals.constants = {
}
globals.showToastMessage = function(heading, message, icon) {
$.toast({
heading: heading,
text: message,
showHideTransition: 'slide',
@varunon9
varunon9 / chat-categories-count.json
Created May 12, 2023 19:52
Insight into chat messages between humans and GPT-3.5-turbo bot. Data has been collected from "Pocket AI" android app - https://play.google.com/store/apps/details?id=me.varunon9.pocket_ai
{
"task_oriented": 1432,
"informational": 1254,
"social": 1006,
"personal_advice_and_self_improvement": 816,
"philosophy_and_morality": 479,
"business_and_finance": 424,
"language_and_communication": 295,
"news_and_current_events": 235,
"technical": 63,