Skip to content

Instantly share code, notes, and snippets.

View pplonski's full-sized avatar
😄
Enjoy programming and writing

Piotr pplonski

😄
Enjoy programming and writing
View GitHub Profile
@pplonski
pplonski / mljar_reading_lightgbm.py
Created October 2, 2017 15:32
Reading models from mljar and using locally
import os
import numpy as np
import lightgbm as lgb
# directory with your models
dir_with_models = './tmp'
# 100 samples of random data (with 70 columns), just for testing
X = np.random.rand(100, 70)
import openml
import pandas as pd
openml.config.apikey = "aaas8a89sd87as87d8as7d98a" # it is some fake API key, please set your key here!
dataset_id = 1590 # Adults data set, see https://www.openml.org/d/1590
# get data directly fom openml
dataset = openml.datasets.get_dataset(dataset_id)
(X, y, categorical, names) = dataset.get_data(
@pplonski
pplonski / read_only_user_in_postgres.sql
Created March 4, 2019 10:42
Read only user in postgres database
-- create a group
CREATE ROLE readaccess;
-- grant access to existing tables
GRANT USAGE ON SCHEMA public TO readaccess;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess;
-- grant access to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess;
import numpy as np
import pandas as pd
from sqlalchemy import create_engine
import psycopg2
import time
host = "host-address-here"
user = "db-user-here"
password = "db-password"
db = "db-name"
@pplonski
pplonski / dashboard_mercury.ipynb
Created February 26, 2022 14:14
Dashboard Notebook with Mercury
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fodra
fodra / electron-packager-extra-resource.md
Created December 18, 2017 06:29
Command to add extra resources in your electron app

This is the example usage of electron-packager that I never found online anywhere else.

To add resource.exe and resource2.dll in the resource folder when you create an installer, this is how you do it with the --extra-resource commandline switch.

--extra-resource

electron-packager . --overwrite --asar --extra-resource="resource1.exe" --extra-resource="resource2.dll" --platform=win32 --arch=ia32 --icon=./frontend/dist/assets/icon.ico --prune=true --out=./build --version-string.ProductName='Hot Pan de sal'

within the backend code you can refer to the files as:

@brazilbean
brazilbean / preprocessors.py
Created March 29, 2017 17:41
Custom Jupyter Notebook Pre-processors
'''Specialized Preprocessors'''
import nbconvert, nbformat, re, sys
from nbconvert.preprocessors import ExecutePreprocessor, Preprocessor
from traitlets import Dict, Unicode
from textwrap import dedent
from warnings import warn
def warn_deprecated(msg):
'''Raise a DeprecationWarning'''
@yangshun
yangshun / docusaurus-copy-button.md
Last active April 4, 2023 07:07
How to add the "Copy" button to code blocks in Docusaurus

Adding "Copy" (to Clipboard) Button

If you would like to add a button to your fenced code blocks so that users may copy the code, you can do so in Docusaurus. You will have to add some code to your Docusaurus project, as seen below.

Under static/js, create a file called code-block-buttons.js with the following:

// Turn off ESLint for this file because it's sent down to users as-is.
/* eslint-disable */
window.addEventListener('load', function() {
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@korakot
korakot / js_link.py
Created August 6, 2018 04:38
Calling python function from JS in Colab