Skip to content

Instantly share code, notes, and snippets.

View ganeshan's full-sized avatar

Ganeshan Venkataraman ganeshan

  • Sterling,MA
View GitHub Profile
import pandas as pd
import numpy as np
def get_dataset(size):
# Create Fake Dataset
df = pd.DataFrame()
df['size'] = np.random.choice(['big','medium','small'], size)
df['age'] = np.random.randint(1, 50, size)
df['team'] = np.random.choice(['red','blue','yellow','green'], size)
df['win'] = np.random.choice(['yes','no'], size)
@ganeshan
ganeshan / AutowiringSpringBeanJobFactory.java
Created February 12, 2022 14:44 — forked from jeffsheets/AutowiringSpringBeanJobFactory.java
Configuring Quartz 2.1.7 with Spring 3.1.3 in clustered mode
/**
* Autowire Quartz Jobs with Spring context dependencies
* @see http://stackoverflow.com/questions/6990767/inject-bean-reference-into-a-quartz-job-in-spring/15211030#15211030
*/
public final class AutowiringSpringBeanJobFactory extends SpringBeanJobFactory implements ApplicationContextAware {
private transient AutowireCapableBeanFactory beanFactory;
public void setApplicationContext(final ApplicationContext context) {
beanFactory = context.getAutowireCapableBeanFactory();
}
@ganeshan
ganeshan / ssl-config-generation-localhost.md
Created February 12, 2022 12:47 — forked from d3vAdv3ntur3s/ssl-config-generation-localhost.md
SSL TLS certificate generation instructions using mkcert for Java / Spring Boot apps

SSL Certificate Generation

Keystore & mkcert

  • PKCS12 is the industry standard, however, java has a proprietary format specific for Java called JKS, we will stick with PKC12 for our keystore.
  • Managing the generation of certs and trust store system wide, mkcert is an incredibly useful tool

Install mkcert

brew install mkcert
import com.jcraft.jsch.SftpProgressMonitor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
@RequiredArgsConstructor
public class CustomSftpProgressMonitor implements SftpProgressMonitor {
private final long totalbytes;
@ganeshan
ganeshan / .NET6Migration.md
Created September 25, 2021 10:16 — forked from davidfowl/.NET6Migration.md
.NET 6 ASP.NET Core Migration

OSRM North America route server on EC2

Overview

OSRM route server is an extremely useful tool for getting the driving distance/time through multiple locations. The route server requires data that has to be downloaded and processsed before it can be used to serve routes from.

Processing OSRM data for large region like North America can be a real challenge due to memory and disk size requirements. It's also really time consuming. If you cut and try from scratch, you will repeatedly run into some constraints and fail after hours of running.

The following are summary notes from trying this with eventual success.

@ganeshan
ganeshan / pagination_without_count.py
Created June 30, 2021 23:08 — forked from gaganpreet/pagination_without_count.py
Flask SQLAlchemy Pagination without count query
def optimised_pagination(query, per_page, page):
'''A more efficient pagination for SQLAlchemy
Fetch one item before offset (to know if there's a previous page)
Fetch one item after limit (to know if there's a next page)
The trade-off is that the total items are not available, but if you don't need them
there's no need for an extra COUNT query
'''
offset_start = (page - 1) * per_page
query_offset = max(offset_start - 1, 0)
@ganeshan
ganeshan / 0-spatial-sql-postgis.md
Created June 7, 2021 19:02 — forked from pramsey/0-spatial-sql-postgis.md
Spatial SQL and PostGIS
@ganeshan
ganeshan / 10 - ORACLE tricks.sql
Created May 4, 2021 21:15 — forked from rmorenobello/10 - ORACLE tricks.sql
ORACLE DB - snippets, tips, best practices
-- ¡¡¡¡Resumenes con ejemplos de cada tema!!!!
http://www.morganslibrary.org/library.html
https://lalitkumarb.wordpress.com/2014/05/31/oracle-explain-plan/
-- EXPLAIN PLAN FOR
-- per consultar resultat:
set linesize 132;
SELECT * FROM TABLE(dbms_xplan.display);
@ganeshan
ganeshan / README.md
Created May 4, 2021 20:42 — forked from cedricvidal/README.md
Optimized Oracle pagination

Where :

  • FIRST_ROWS(N) tells the optimizer, "Hey, I'm interested in getting the first rows, and I'll get N of them as fast as possible."
  • :MAX_ROW_TO_FETCH is set to the last row of the result set to fetch—if you wanted rows 50 to 60 of the result set, you would set this to 60.
  • :MIN_ROW_TO_FETCH is set to the first row of the result set to fetch, so to get rows 50 to 60, you would set this to 50.

Source https://blogs.oracle.com/oraclemagazine/on-rownum-and-limiting-results