Skip to content

Instantly share code, notes, and snippets.

View danielrmeyer's full-sized avatar

Daniel Meyer danielrmeyer

View GitHub Profile
@danielrmeyer
danielrmeyer / gist:212d6b4e622605878544b33927592e66
Created March 22, 2024 01:27
Dependencies to build python on ubuntu
sudo apt-get install libbz2-dev
sudo apt-get install libncurses5-dev libncursesw5-dev
sudo apt-get install libffi-dev
sudo apt-get install libreadline-dev
sudo apt-get install libssl-dev
sudo apt-get install liblzma-dev
sudo apt-get install libsqlite3-dev
sudo apt-get install tk-dev
import smile.cas.{Var, cot, pimpDouble}
@main
def symbolicDemoApp() =
println("Let do math")
val x = Var("x")
val y = Var("y")
val e = x ** 2 + y ** 3 + x ** 2 * cot(y ** 3)
@danielrmeyer
danielrmeyer / polar_plot.py
Created January 18, 2024 17:55
Demo how we could build a realtime polar plot with matplotlib
# pip install matplotlib
# pip install PyQt5
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
# Function to update the polar plot
def update(frame):
# Your streaming data source logic goes here
@danielrmeyer
danielrmeyer / calculate_pi.py
Last active April 22, 2018 23:32
Stochastic estimation of pi using dask
import dask.bag as db
import random
NUM_SAMPLES=100
def inside(p):
x, y = random.random(), random.random()
return x*x + y*y < 1
@danielrmeyer
danielrmeyer / configure.sh
Created July 31, 2017 18:07
build emacs in your home dir on minimal server without X and stuff
make
./configure --prefix=/home/<yourhome>/ --with-x-toolkit=no --with-xpm=no --with-jpeg=no --with-png=no --with-gif=no --with-tiff=no
make install
@danielrmeyer
danielrmeyer / libimobiledevice_ifuse_Ubuntu.md
Created April 2, 2017 15:28 — forked from samrocketman/libimobiledevice_ifuse_Ubuntu.md
On Ubuntu 16.04, since iOS 10 update, libimobiledevice can't connect to my iPhone. This is my attempt to document a fix.

Why this document?

I upgraded my iPhone 5s to iOS 10 and could no longer retrieve photos from it. This was unacceptable for me so I worked at achieving retrieving my photos. This document is my story (on Ubuntu 16.04).

The solution is to compile libimobiledevice and ifuse from source.

Setup environment

Don't forget to set up your environment before building. I typically build and install packages to my local user at $HOME/usr.

import sqlite3
import os
from itertools import cycle, product
DB_FILE = "data.sqlite3"
num_rows = 100000000
elements = cycle(product(["name1", "name2", "name3"], [1,2,3]))
conn = sqlite3.connect(DB_FILE)
curs = conn.cursor()
#include <stdio.h>
#include <sqlite3.h>
#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
#define MAX_THREADS 100
@danielrmeyer
danielrmeyer / chunk_and_flatten.py
Created September 9, 2016 20:16
chunk and flatten lists
def chunks(l,n):
return [l[i:i+n] for i in range(0, len(l), n)]
def flatten(l):
return [val for sublist in l for val in sublist]
@danielrmeyer
danielrmeyer / sum2target.py
Created June 30, 2016 20:48
find all pairs in a list that add to a target number
def sum2target(l, t):
"""
:param l: list of positive itegers
:param t: a target number
:return: set of pairs of numbers in l that sum to t
"""
d = {t-x: x for x in l}
return {frozenset((x, d[x])) for x in l if x in d.keys()}