Skip to content

Instantly share code, notes, and snippets.

@jiaaro
jiaaro / _INSTRUCTIONS.md
Last active January 17, 2025 17:46
Using Swift libraries in Python

Using Swift libraries in Python

So... this is obviously totally, 100%, like for. real. not. supported. by. Apple. …yet?

But still... I thought it was pretty badass. And, seeing how there's already a Swift buildpack for Heroku you could move some slow code into Swift can call it as a library function. But, you know, not in production or anything. That would be silly, right?

Now, having said that, the actual Python/Swift interop may have bugs. I'll leave that as an exercise to the reader.

How to get Python code calling Swift functions:

@astrojuanlu
astrojuanlu / pybonacci.mplstyle
Last active January 23, 2016 12:18
Estilo de matplotlib para Pybonacci
axes.facecolor : eeeeee
axes.edgecolor : bcbcbc
axes.linewidth : 1
axes.grid : True
axes.labelcolor : 555555
axes.axisbelow : True
axes.prop_cycle : cycler('color', ['204a87', 'cc0000', 'c88a00', '4e9a06', '7a68a6', 'cf4457', '188487'])
xtick.major.size : 0
xtick.minor.size : 0
@ramnathv
ramnathv / Makefile
Last active January 16, 2021 13:47
R Markdown to IPython Notebook
example.md: example.Rmd
./knit
example.ipynb: example.md
notedown example.md | sed 's/%%r/%%R/' > example.ipynb
@jonathansp
jonathansp / sptrans.py
Created November 15, 2013 20:50
Um cliente python para a API Olho Vivo da SPTrans de São Paulo
#!/usr/local/bin/python
# -*- coding: utf-8 -*-
""" Um cliente python para a API Olho Vivo """
import requests
class SPTransClient(object):
""" Um cliente python para a API Olho Vivo """
@danieljfarrell
danieljfarrell / odesolver.py
Last active December 22, 2015 13:59
Fleshing out a ode solver interface for scipy.
# Instantiation.
# Make a solver object, created automatically with default options. The solve is instantiated
# only with the variables that are common to all of the solvers. This means 1) the r.h.s. of
# function to solve, 2) a start time, 3) initial conditions, 4) Jacobian function. Strictly
# speaking the Jacobian is optional here because only some solvers will require it. As a
# compromise lets pass it as a keyword argument, this also gets around any awkward 'use_jac'
# options because the solver either has a Jacobian function at init time or it does not.
solver = odesolver("cvodes", ode_function, time_start, initial_conditions, jacobian_function=None)
# Solver options.
@josef-pkt
josef-pkt / scipy_parse_special_fortran_0.py
Last active December 22, 2015 05:49
parsing Fortran docstrings
# -*- coding: utf-8 -*-
"""Parsing the Fortran files to create raw docstrings
Created on Tue Sep 03 10:11:10 2013
Author: Josef Perktold
open problems
cumnor.f doesn't define segment headers besides "Function"
@chemacortes
chemacortes / gist:5713746
Created June 5, 2013 13:13
Forget about #Unicode problems on ANY Version of #Python !
# put this after the imports on your .py files
try: # py2
str, range, input = unicode, xrange, raw_input # lint:ok
except NameError: # py3
buffer, long = memoryview, int # lint:ok
@kikocorreoso
kikocorreoso / ipynp2wp.py
Created December 1, 2012 23:58
Publish an ipynb directly in wordpress.com (proof of concept)
# -*- coding: utf-8 -*-
## Basado en el script originalmente publicado en
## http://www.jansipke.nl/using-python-to-add-new-posts-in-wordpress/
import datetime
import xmlrpclib
from xml.sax.saxutils import escape
import json
import markdown
@javisantana
javisantana / fall.js
Created October 15, 2012 09:51
redbull stratos fall simulation
// redbull stratos fall simulation
// node fall.js > fall.json
//
// port to js from python by @pybonacci
// more info: http://pybonacci.wordpress.com/2012/10/15/el-salto-de-felix-baumgartner-en-python/
//
// >> [ std_atm.alt2density(h, alt_units='m', density_units='kg/m**3') for h in xrange(0, 43000, 1000)]
// air density each 1000 meters
var AIR_DENSITY = [1.225, 1.1116425767380347, 1.0064902527218418, 0.9091220810460088, 0.8191294202172186, 0.7361158590983954, 0.6596971404886504, 0.5895010832794331, 0.5251675031230921, 0.4663481315454516, 0.41270653342889785, 0.3639180227868754, 0.3108281589022067, 0.2654832635841079, 0.22675346883692057, 0.19367373647373748, 0.16541981206327336, 0.14128768681425868, 0.1206760556449457, 0.10307133434187116, 0.08803486247736621, 0.07487366111494297, 0.06372734460638993, 0.05428027105802167, 0.046267360336640966, 0.039465817649795336, 0.03368824062938579, 0.02877687388504317, 0.024598816068418232, 0.021042018277291016, 0.018011940446444, 0.01542875529531276, 0.0132250083
@sgillies
sgillies / geo_interface.rst
Last active October 20, 2025 13:07
A Python Protocol for Geospatial Data

Author: Sean Gillies Version: 1.0

Abstract

This document describes a GeoJSON-like protocol for geo-spatial (GIS) vector data.

Introduction