Skip to content

Instantly share code, notes, and snippets.

View sandiprb's full-sized avatar
🏠
Working from home

Sandip B sandiprb

🏠
Working from home
View GitHub Profile
@sandiprb
sandiprb / useful_pandas_snippets.py
Created August 30, 2017 18:19 — forked from bsweger/useful_pandas_snippets.md
Useful Pandas Snippets
# List unique values in a DataFrame column
pd.unique(df.column_name.ravel())
# Convert Series datatype to numeric, getting rid of any non-numeric values
df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True)
# Grab DataFrame rows where column has certain values
valuelist = ['value1', 'value2', 'value3']
df = df[df.column.isin(valuelist)]
{
"workbench.colorTheme": "Material Theme Palenight",
"window.zoomLevel": -1,
"editor.insertSpaces": true,
"editor.wordWrap": "on",
"workbench.sideBar.location": "right",
"editor.fontSize": 15,
"files.exclude": {
"**/.git": true,
"**/.svn": true,
const fs = require('fs');
const util = require('util');
const readFile = util.promisify(fs.readFile);
async function getFileLines() {
try {
const args = process.argv.slice(2)
if (!args.length) {
console.warn('>> Please pass file name as argument <<')
@sandiprb
sandiprb / .postcssrc.js
Created October 26, 2018 13:23
postcss rc for vue js
const path = require('path')
module.exports = {
plugins: {
"postcss-import": {
resolve(id, basedir) {
// resolve alias @css, @import '@css/style.css'
// because @css/ has 5 chars
if (/^@css/.test(id)) {
return path.resolve('./src/assets/css', id.slice(5))
trailingComma: es5
printWidth: 120
tabWidth: 2
useTabs: true
semi: false
bracketSpacing: true
jsxBracketSameLine: false
parser: typescript
singleQuote: true
requirePragma: false
@sandiprb
sandiprb / slugify.js
Created November 13, 2018 20:07 — forked from mathewbyrne/slugify.js
Javascript Slugify
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}
@sandiprb
sandiprb / googlesheets-to.json.js
Created May 28, 2020 12:16
Node JS script to fetch Google Sheets data as json
const { GoogleSpreadsheet } = require('google-spreadsheet');
const fs = require('fs');
const JSON_FILE_NAME = 'data.json'
const FILE_PATH = `/data/${JSON_FILE_NAME}`
const GOOGLE_SHEET_ID = ''
/* Create google credentials and save the credentials json file */
const creds = require('./credentials.json')
@sandiprb
sandiprb / admin.py
Last active June 6, 2020 13:54
Django admin register all models of an app dynamically
from django.contrib import admin
from django.apps import apps
from django.contrib.auth.admin import UserAdmin as DjUserAdmin
from . import models
# Register your models here.
@admin.register(models.User)
class UserAdmin(DjUserAdmin):
pass
@sandiprb
sandiprb / Dockerfile
Created June 17, 2020 20:29
Deploy React / Vue / Front-end node projects with nginx Docker image
# Use a lighter version of Node as a parent image
FROM node:10 as project-build
# Set the working directory to /frontend
WORKDIR /project
COPY package*.json /project/
RUN npm install
@sandiprb
sandiprb / 📊 Weekly development breakdown
Last active October 29, 2020 01:09
Weekly Development Breakdown
Vue.js 5 hrs 29 mins ███████████▍░░░░░░░░░ 54.5%
Python 2 hrs 59 mins ██████▏░░░░░░░░░░░░░░ 29.7%
JavaScript 28 mins █░░░░░░░░░░░░░░░░░░░░ 4.8%
HTML 21 mins ▊░░░░░░░░░░░░░░░░░░░░ 3.6%
GraphQL 14 mins ▍░░░░░░░░░░░░░░░░░░░░ 2.4%