Skip to content

Instantly share code, notes, and snippets.

View den-run-ai's full-sized avatar
🎯
Focusing

Denis Akhiyarov den-run-ai

🎯
Focusing
View GitHub Profile
@karpathy
karpathy / min-char-rnn.py
Last active June 6, 2024 16:51
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tritemio
tritemio / open file dialog
Created June 24, 2015 00:25
Open file dialog for default ipython notebook in Anaconda
def openfile_dialog():
from PyQt4 import QtGui
app = QtGui.QApplication([dir])
fname = QtGui.QFileDialog.getOpenFileName(None, "Select a file...", '.', filter="All files (*)")
return str(fname)
@gdamjan
gdamjan / client.py
Last active November 10, 2019 20:22
Python 3.5 async/await with aiohttp, parallel or sequential
import aiohttp
import asyncio
async def get_body(url):
response = await aiohttp.request('GET', url)
raw_html = await response.read()
return raw_html
async def main():
# run them sequentially (but the loop can do other stuff in the meanwhile)
@filmor
filmor / dynamic.py
Last active March 7, 2024 15:16
Support for DLR types
from System.Dynamic import DynamicObject as _do
from System import Func, Array, Object
from System.Runtime.CompilerServices import CallSite
from Microsoft.CSharp.RuntimeBinder import (
Binder, CSharpBinderFlags, CSharpArgumentInfoFlags,
RuntimeBinderException, CSharpArgumentInfo
)
class _Injected:
@tartakynov
tartakynov / fourex.py
Last active April 23, 2024 02:55
Fourier Extrapolation in Python
import numpy as np
import pylab as pl
from numpy import fft
def fourierExtrapolation(x, n_predict):
n = x.size
n_harm = 10 # number of harmonics in model
t = np.arange(0, n)
p = np.polyfit(t, x, 1) # find linear trend in x
x_notrend = x - p[0] * t # detrended x
Sorry, this is too big to display.
import os
from IPython.qt.console.rich_ipython_widget import RichIPythonWidget
from IPython.qt.manager import QtKernelManager
from IPython.qt.inprocess import QtInProcessKernelManager
from IPython.kernel.zmq.ipkernel import Kernel
from IPython.kernel.inprocess.ipkernel import InProcessKernel
from IPython.lib import guisupport
@Upabjojr
Upabjojr / fullform2sympy.py
Last active February 8, 2018 17:50
A draft to transform some limited subset of Mathematica's FullForm expression into a SymPy expression.
import re
replacements = dict(
Times="Mul",
Plus="Add",
Power="Pow",
)
def parse_full_form(wmexpr):
out = []
@asfaltboy
asfaltboy / clip_magic.py
Last active September 20, 2021 22:23 — forked from nova77/clip_magic.py
"""
Add copy to clipboard from IPython!
To install, just copy it to your profile/startup directory, typically:
~/.ipython/profile_default/startup/
Example usage:
%clip hello world
# will store "hello world"