Skip to content

Instantly share code, notes, and snippets.

View bhaskar-nair2's full-sized avatar
🏠
Working from home

Bhaskar Nair bhaskar-nair2

🏠
Working from home
View GitHub Profile
// Get File
const getFileBtn = document.getElementById("fs-get")
getFileBtn.onclick = async () => {
const [handle] = await window.showOpenFilePicker();
const file = await handle.getFile();
console.log(file)
}
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:coup/firebase/auth.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_database/firebase_database.dart';
class UserPresence {
static final _app = FirebaseApp.instance;
static final FirebaseDatabase _db = FirebaseDatabase(
app: _app,
databaseURL: 'https://coup-dc26b.firebaseio.com/',
@bhaskar-nair2
bhaskar-nair2 / main.dart
Last active February 14, 2020 17:51
Flutter Neomorphic Button
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Scaffold(
@bhaskar-nair2
bhaskar-nair2 / .editorconfig
Last active November 29, 2019 00:15
My VSCode Settings + Monokai Theme
[*.{js,jsx,ts,tsx,vue}]
indent_style = space
indent_size = 2
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 100
[*.{js,jsx,ts,tsx,vue}]
indent_style = space
@bhaskar-nair2
bhaskar-nair2 / ncStream.sh
Created May 25, 2019 06:27
Stream video from raspberry pi to PC without latency (<150ms)
#!/bin/bash
raspivid -vf -n -w 640 -h 480 -o - -t 0 -b 2000000 | nc <your-pc's-ip> 5777
# This is the code to be run on the raspberry-pi
# Your pc's IP is the client IP which you can get by ifcongif
# Make sure both of these devices are on the same network ex. Home Wifi
# 5777 is the port
@bhaskar-nair2
bhaskar-nair2 / gist:15d21ee5247c988f62bbb532dc47bb36
Created March 5, 2019 10:30
Firebase Channel Creator for VueX: The code makes a VueX store action which modifies the state according to data received from Firebase Firestore
channelBookings({ state, commit }, user_id) {
var book = [];
db.collection("bookings").onSnapshot(res => {
const changes = res.docChanges();
changes.forEach(change => {
switch (change.type) {
case "added":
book.push({
...change.doc.data(),
id: change.doc.id
@bhaskar-nair2
bhaskar-nair2 / flask-uwsgi-nginx-primer.md
Created June 25, 2018 09:55 — forked from mplewis/flask-uwsgi-nginx-primer.md
Flask + uWSGI + nginx Primer. I've been having trouble with serving a Flask app via uWSGI and nginx, so I thought I'd put together some of the basics to help out others.

Flask + uWSGI + nginx Primer

I've been having trouble with serving a Flask app via uWSGI and nginx, so I thought I'd put together some of the basics to help out others.

How this shit works

  • Flask is managed by uWSGI.
  • uWSGI talks to nginx.
@bhaskar-nair2
bhaskar-nair2 / AutofillEntry.py
Created June 23, 2018 09:24
A tkinter code to make auto-filling entries.
from tkinter import *
import re
lista = ['i', 'went', 'through', 'executemany()', 'as', 'well', 'but', 'sorry', 'to', 'say', 'I', 'am', 'quite', 'new', 'to', 'both', 'python', 'and', 'sqlite.', 'My', 'doubt', 'is', 'like', 'if', 'I', 'have,', 'say', 'a', 'list', 'of', 'filenames', 'which', 'I', 'have', 'prepared', 'by', 'appending', 'values', 'inside', 'a', 'list', 'object,', 'then', 'how', 'can', 'I', 'use', 'it', 'with', 'executeMany..', 'is', 'it', 'like', 'simply', 'passing', 'the', 'list', 'object', '(say', 'fileList)', 'to', 'executemany()?..', 'Any', 'code', 'snippet', 'would', 'be', 'really', 'appreciated..', 'thanks']
#Some Random crap, don't judge
class AutocompleteEntry(Entry):
def __init__(self, *args, **kwargs):
Entry.__init__(self, *args, **kwargs)
@bhaskar-nair2
bhaskar-nair2 / SearchAlgorithm.py
Created June 23, 2018 09:11
Search Algorithm
# Hello
# Please read the comments for hints
import re
# These words have to be ignored even if they match
trash = ['tabs', 'inj', 'bottle', 'syp', 'bot', 'bott', 'cap', 'doses', 'with', 'ml', 'mg', 'in', 'methyl', 'containing', 'antibiotic', 'sodium', 'chloride', 'fluoride', 'phosphate', 'without',
'chloride', 'ammonium', 'citrate', 'adrenaline', 'gluconate', 'propionate', 'absorbent', 'unmedicated', 'sulphate', 'eye drops', 'lactate', 'disposable', 'lignocaine']
# If two diffrent words from the same list are in the words, they become contradicting,and are thus not same.
@bhaskar-nair2
bhaskar-nair2 / bash-cheatsheet.sh
Last active June 14, 2018 05:49 — forked from ashish192/bash-cheatsheet.sh
Bash CheatSheet for UNIX Systems --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
#!/bin/bash
#####################################################
# Name: Bash CheatSheet for Mac OSX
#
# A little overlook of the Bash basics
#
# Usage:
#
# Author: J. Le Coupanec
# Date: 2014/11/04