Skip to content

Instantly share code, notes, and snippets.

View ostrokach's full-sized avatar

Alexey Strokach ostrokach

View GitHub Profile
import torch
import torch.utils.dlpack
import jax
import jax.dlpack
# A generic mechanism for turning a JAX function into a PyTorch function.
def j2t(x_jax):
x_torch = torch.utils.dlpack.from_dlpack(jax.dlpack.to_dlpack(x_jax))
return x_torch
@Zsailer
Zsailer / draw_networkx_nodes_ellipses.py
Last active July 27, 2020 14:52
Drawing NetworkX plots with ellipses for nodes
import networkx as nx
def draw_networkx_nodes_ellipses(G, pos,
nodelist=None,
node_height=1,
node_width=2,
node_angle=0,
node_color='r',
node_shape='o',
alpha=1.0,
@jmrr
jmrr / mysql2parquet.scala
Last active June 23, 2022 20:04
MySQL tables to parquet files on the Spark shell
val sqlContext = new org.apache.spark.sql.SQLContext(sc) // optional
val df = sqlContext.load("jdbc", Map(
"url" -> "jdbc:mysql://<ip.address.your.db>/<table>?user=<username>&password=<pwd>",
"dbtable" -> "<tablename>"))
df.select("<col1>","<col2>","<col3>").save("</path/to/parquet/file.parquet>","parquet")
//Alternatively, to save all the columns:
@pwyliu
pwyliu / dl5110cn.ppd
Created November 2, 2013 00:36
PPD file for Dell 5110cn. Extracted from the Dell Windows driver vA07. Works on Ubuntu.
*PPD-Adobe: "4.3"
*% Adobe Systems PostScript(R) Printer Description File
*% Copyright 1987-1996 Adobe Systems Incorporated.
*% All Rights Reserved.
*% Permission is granted for redistribution of this file as
*% long as this copyright notice is intact and the contents
*% of the file is not altered in any way from its original form.
*% End of Copyright statement
*FileVersion: "1.0"
*FormatVersion: "4.3"
@rcalsaverini
rcalsaverini / Singleton.py
Created October 8, 2012 00:16
A Singleton metaclass in python:
class Singleton(type):
""" This is a Singleton metaclass. All classes affected by this metaclass
have the property that only one instance is created for each set of arguments
passed to the class constructor."""
def __init__(cls, name, bases, dict):
super(Singleton, cls).__init__(cls, bases, dict)
cls._instanceDict = {}
def __call__(cls, *args, **kwargs):
@eddarmitage
eddarmitage / InstallingGitUsingYum.md
Created March 8, 2012 14:03
Installing git on CentOS 5 using yum

Installing git on CentOS 5 using yum

Since you're using CentOS 5, the default package manager is yum, not apt-get. To install a program using it, you'd normally use the following command:

$ sudo yum install <packagename>

However, when trying to install git this way, you'll encounter the following error on CentOS 5: