Skip to content

Instantly share code, notes, and snippets.

import numpy as np
import requests
import pylab as plt
URL = 'http://165.227.157.145:8080/api/do_measurement?x={}'
FILENAME = 'results.npy'
def get_value(x):
""" get one value from API """
@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@OllieJones
OllieJones / fullquery
Last active September 25, 2023 14:09
Fast nearest-location finder for SQL (MySQL, PostgreSQL, SQL Server)
SELECT zip, primary_city,
latitude, longitude, distance
FROM (
SELECT z.zip,
z.primary_city,
z.latitude, z.longitude,
p.radius,
p.distance_unit
* DEGREES(ACOS(LEAST(1.0, COS(RADIANS(p.latpoint))
* COS(RADIANS(z.latitude))
@szydan
szydan / gist:b225749445b3602083ed
Last active June 19, 2024 13:13
<U+FEFF> character showing up in files. How to remove them?
1) In your terminal, open the file using vim:
vim file_name
2) Remove all BOM characters:
:set nobomb
3) Save the file:
:wq
@torstello
torstello / gist:9351040
Created March 4, 2014 17:16
17.Karmapa
At a recent event, His Holiness Karmapa Thaye Dorje was asked the following question:
'Your Holiness, what is stopping me from realizing my true nature, the Buddha nature?'
His Holiness' response:
'Perhaps it is a lack of a sense of adventure that is holding us back from realizing our true nature. It is easy to get used to the mundane life, the daily routines. As a result, we don't want to let go of our familiar atmosphere, the life that we are used to. We are missing a sense of adventure.
I think this is rooted in a deep fear: a fear of facing ourselves; a fear of knowing exactly who we are. It is almost like saying we fear looking at ourselves in the mirror and seeing our own reflections.
@gregvish
gregvish / chat.py
Last active February 8, 2025 00:02
Python 3.4 asyncio chat server example
from socket import socket, SO_REUSEADDR, SOL_SOCKET
from asyncio import Task, coroutine, get_event_loop
class Peer(object):
def __init__(self, server, sock, name):
self.loop = server.loop
self.name = name
self._sock = sock
self._server = server
Task(self._peer_handler())