Skip to content

Instantly share code, notes, and snippets.

View astanin's full-sized avatar

Sergey Astanin astanin

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@astanin
astanin / sigmoid-bench.c
Last active July 6, 2023 16:54
Benchmark various sigmoid functions
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <math.h>
#define M_PI_2 1.57079632679489661923 /* pi/2 */
#define M_PI_2_INV (1.0/M_PI_2)
#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
#define ERF_COEF (1.0/M_2_SQRTPI)

Array abstraction in Clojure

Few days ago Mike Anderson wrote [a proposal][mike] for a generic matrix API in Clojure which could compete with NumPy. I wanted to write a similar post for months, but was reluctant to start. This problem is very dear to me. Basically, it is a matter if I can use Clojure for most of my work, or it remains a toy language for me. Thanks to Mike for bringing the question up. Though, I have a different vision of how we should approach arrays and matrices in Clojure.

"""Counting objects without bias
http://blogs.mathworks.com/steve/2012/12/18/counting-objects-without-bias/
"""
from scipy.misc import imread, imshow
from scipy.ndimage import label
from scipy import asarray, ones, vstack, hstack
from sys import stdout
@astanin
astanin / rmtweets.py
Created November 13, 2012 16:31
Delete tweets older than X days.
#!/usr/bin/env python2
"""Delete tweets older than X days.
Usage:
rmtweets.py [at_least_days_old (default=365)]
"""
# Twitter gives access to only the last 3200 tweets, but if you delete
# more recent tweets, then after some time (a week? a month?) the
@astanin
astanin / indent-blocks.el
Created October 25, 2012 13:41
Move Emacs cursor to the begining and end of the current indentation block
;;; indent-blocks.el ---
;;; move to the begining and end of the current indentation block
;; Indent blocks are defined as a sequence of lines with the same or
;; bigger indent size than that of the current line.
;;
;; Indentat blocks are common in YAML, Python, and Haskell and other
;; markup and programming languages with significant indentation, and
;; in these languages they usually are semantic units.
;;
@astanin
astanin / ipython-plot3d.json
Created September 27, 2012 09:38
test ipython notebook feature
{
"metadata": {
"name": "plot 3D line"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@astanin
astanin / Direct_Links_in_Google_Search.user.js
Created September 25, 2012 14:52
Remove indirections from Google search results on all TLDs (GreaseMonkey script)
@astanin
astanin / Hide_Search_Bar_in_Google_Reader.user.js
Created September 17, 2012 12:39
Hide Search Bar in Google Reader (GreaseMonkey script)
// ==UserScript==
// @name Hide Search Bar in Google Reader
// @namespace https://github.com/astanin
// @include http://www.google.com/reader/view/*
// @include https://www.google.com/reader/view/*
// @version 1.0
// @grant none
// ==/UserScript==
function hideById(barid) {
document.getElementById(barid).style.display = "none";
language github.rank so.tagcount so.rank
elixir 30 73 18
vb.net 60 34949 69
io 34 3319 54
python 85 131042 72
augeas 10 3 2
pure-data 37 0 0
dart 31 219 28
nu 23 3 2
rust 56 21 14