Skip to content

Instantly share code, notes, and snippets.

@xiaolai
xiaolai / jupyter-as-a-desktop-app.md
Last active September 15, 2023 08:37
Run Jupterlab as an desktop app

How to run Jupyterlab as a desktop app on Mac OSX

In Sep, 2021, Jupyterlab Desktop App (electron) was released by Mehmet Bektas (github repo).

brew install --cask jupyterlab

jupyterlab-app-first-opened

@ulope
ulope / 01_implicit_chaining.py
Last active April 13, 2021 14:15
Python exception chaining
def implicit_chaining():
"""
This is the Python 2 style. Just raising another exception from within an except block.
In Python 3 this causes the exceptions to be chained with the message:
During handling of the above exception, another exception occurred:
Which is usually not correct when just re-raising with a more appropriate type.
"""
try:
@gvolpe
gvolpe / di-in-fp.md
Last active April 24, 2024 20:51
Dependency Injection in Functional Programming

Dependency Injection in Functional Programming

There exist several DI frameworks / libraries in the Scala ecosystem. But the more functional code you write the more you'll realize there's no need to use any of them.

A few of the most claimed benefits are the following:

  • Dependency Injection.
  • Life cycle management.
  • Dependency graph rewriting.
@aparrish
aparrish / understanding-word-vectors.ipynb
Last active April 29, 2024 17:57
Understanding word vectors: A tutorial for "Reading and Writing Electronic Text," a class I teach at ITP. (Python 2.7) Code examples released under CC0 https://creativecommons.org/choose/zero/, other text released under CC BY 4.0 https://creativecommons.org/licenses/by/4.0/
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
0
1
2
3
4
5
6
7
8
9
@drorata
drorata / gist:b05bfd59c45eec0470f6
Last active May 9, 2022 14:12
Nice output of pandas.DataFrame in org-mode
import pandas as pd
import numpy as np
from tabulate import tabulate

df = pd.DataFrame(np.random.random((4,3)), columns=['A','B','C'])
print("foo")
return(tabulate(df, headers="keys", tablefmt="orgtbl"))
@davidadamojr
davidadamojr / server.py
Last active June 22, 2021 13:17
Accept CORS requests in Flask
from flask import Flask
from flask.ext import restful
from flask.ext.sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config.from_object('config')
#flask-sqlalchemy
db = SQLAlchemy(app)
@AtlasPilotPuppy
AtlasPilotPuppy / SparkSqlIntro.py
Last active July 28, 2018 10:14
Introduction to spark SQL using python
from pyspark import SparkContext
from pyspark.sql import SQLContext
from pyspark.sql import Row, StructField, StructType, StringType, IntegerType
sc = SparkContext('spark://master:7077', 'Spark SQL Intro')
sqlContext = SQLContext(sc)
dividends = sc.textFile("hdfs://master:9000/user/hdfs/NYSE_dividends_A.csv")
dividends_parsed = dividends.filter(lambda r: not r.startswith('exchange')).map(lambda r: r.split(',')).map(
lambda row: {'exchange': row[0], 'stock_symbol': row[1], 'date': row[2], 'dividends': float(row[3])})
@Superbil
Superbil / talk-org-mode.org
Last active February 12, 2023 07:37
[PyHUG] July: Use Python in Org-mode

[PyHUG] July: Use Python in Org-mode

About