Skip to content

Instantly share code, notes, and snippets.

View DeepanshKhurana's full-sized avatar
💻
Learning

Deepansh Khurana DeepanshKhurana

💻
Learning
View GitHub Profile
@DeepanshKhurana
DeepanshKhurana / reverse-geolocate.R
Last active February 10, 2019 14:34
A simple function that uses plyr and ggmap along with the Google Maps API to fetch a dataframe of City, Location, State and Country
# @dependency ggmap for the geocode function
# @dependency plyr for ldply
#
#
# @param lat - The latitude value or column using $ notation
# @param long - The longitude value or column using $ notation
# @param api.key - Your Google Geocoding API key.
# You'll need to get one here: https://developers.google.com/maps/documentation/geocoding/start
# The Geocoding API requires you to sign up with payment details. You may get charged for using it in huge volumes.
# Please refer to the official documentation provided by Google on their pages.
@DeepanshKhurana
DeepanshKhurana / TextRank4Keyword.py
Created April 16, 2019 08:07 — forked from BrambleXu/TextRank4Keyword.py
TextRank for Keyword Extraction
from collections import OrderedDict
import numpy as np
import spacy
from spacy.lang.en.stop_words import STOP_WORDS
nlp = spacy.load('en_core_web_sm')
class TextRank4Keyword():
"""Extract keywords from text"""
@DeepanshKhurana
DeepanshKhurana / facebook-birthdays.py
Last active November 10, 2022 11:08
Python script to create a .csv from Facebook's Event Data to list Birthdays.
# Imports
import requests
import re
import pandas as pd
import numpy as np
# Initialising Variables
names = []
@DeepanshKhurana
DeepanshKhurana / reactable_edit.R
Last active June 6, 2024 06:23
Editable Reactable (with Modals)
library(shiny)
library(reactable)
library(dplyr)
ui <- fluidPage(
actionButton(inputId = "edit",
label = "Edit"),
reactableOutput("table")
)
@DeepanshKhurana
DeepanshKhurana / app.R
Created March 25, 2023 08:43
Using Reactable with YAML
# Loading Libraries ----
library(reactable)
library(yaml)
library(shiny)
# Generate Reactable Function ----
generate_reactable <- function(data,
table_type,
@DeepanshKhurana
DeepanshKhurana / price_formatting.R
Last active March 31, 2023 15:23
Format Prices
#' @export
#'
true_round <- function(number, digits) {
number <- as.numeric(number)
posneg <- sign(number)
number <- abs(number) * 10^digits
number <- number + 0.5 + sqrt(.Machine$double.eps)
number <- trunc(number)
number <- number / 10 ^ digits
number * posneg
@DeepanshKhurana
DeepanshKhurana / functions.R
Created March 31, 2023 16:11
Reactable Multi-row Example
#' @export
#'
true_round <- function(number, digits) {
number <- as.numeric(number)
posneg <- sign(number)
number <- abs(number) * 10^digits
number <- number + 0.5 + sqrt(.Machine$double.eps)
number <- trunc(number)
number <- number / 10 ^ digits
number * posneg
@DeepanshKhurana
DeepanshKhurana / reactable.R
Last active October 16, 2024 13:22
Nested Reactable Example in R
# This is just the reactable function; you might have to include this somewhere in a larger R file.
# `::` is used a splitting separator because the data uses a paste() statement to collapse several columns into one.
# This is a _hack_ to have multiple values in one cell of reactable.
reactable(
data = student_data,
searchable = TRUE,
pagination = FALSE,
borderless = TRUE,
details = function(index) {