Skip to content

Instantly share code, notes, and snippets.

View akimboyko's full-sized avatar
🙃

Akim Boyko akimboyko

🙃
View GitHub Profile
@aras-p
aras-p / preprocessor_fun.h
Last active April 28, 2024 15:25
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@akimboyko
akimboyko / Nat.fs
Created October 17, 2013 05:47
Quiz from Functional Programming Principles in Scala by Martin Odersky, lecture 4.2 implemented on F# with unittests
//Provide an implementation of the abstract class Nat that represents non-negative integers
//
//Do not use standard numerical classes in this implementation.
//Rather, implement a sub-object and sub-class:
//
//class Zero : Nat
//class Succ(n: Nat) : Nat
//
//One of the number zero, then other for strictly positive numbers.
namespace Nat
@simon-weber
simon-weber / logutil.py
Created December 8, 2013 03:48
A context manager to temporarily disable all logging in Python that supports previous calls to logging.disable.
from contextlib import contextmanager
import logging
@contextmanager
def all_logging_disabled(highest_level=logging.CRITICAL):
"""
A context manager that will prevent any logging messages
triggered during the body from being processed.
:param highest_level: the maximum logging level in use.
@controlflow
controlflow / gist:8072635
Last active January 1, 2016 01:28
Primary ctors
class ReverseForLookupItem : ForLookupItemBase
{
public ReverseForLookupItem([NotNull] PrefixExpressionContext context,
[NotNull] LiveTemplatesManager templatesManager,
[CanBeNull] string lengthPropertyName)
: base("forR", context, templatesManager, lengthPropertyName) { }
protected override IForStatement CreateStatement(CSharpElementFactory factory, ICSharpExpression expression)
{
...
@debasishg
debasishg / gist:8172796
Last active March 15, 2024 15:05
A collection of links for streaming algorithms and data structures

General Background and Overview

  1. Probabilistic Data Structures for Web Analytics and Data Mining : A great overview of the space of probabilistic data structures and how they are used in approximation algorithm implementation.
  2. Models and Issues in Data Stream Systems
  3. Philippe Flajolet’s contribution to streaming algorithms : A presentation by Jérémie Lumbroso that visits some of the hostorical perspectives and how it all began with Flajolet
  4. Approximate Frequency Counts over Data Streams by Gurmeet Singh Manku & Rajeev Motwani : One of the early papers on the subject.
  5. [Methods for Finding Frequent Items in Data Streams](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.187.9800&rep=rep1&t
@mausch
mausch / gist:8227399
Created January 2, 2014 21:37
Erik Meijer quotes in Reactive Programming Coursera. I did not gather them, I merely copied this from https://class.coursera.org/reactive-001/forum/thread?thread_id=1356 to make them public.
"Hopefully the third answer is right; but who knows, maybe I made a mistake; I’m just a human, I can throw exceptions as well."
"I am waving my hands on purpose here, this is very spaghetti like code. And spaghetti is great as food, but not good as code."
"flatMap will allow us to focus on the happy path. flatMap will take care of all the noise. flatMap is the dolby for programmers."
"Great programmers write baby code"
"it's obviously correct"
# You should have pswatch installed (http://psget.net/directory/pswatch/)
# You need small modification to the FSharpKoans/PathToEnlightenment.fs to make sure that you will not need to press any key
# Comment out
# printf "Press any key to continue..."
# System.Console.ReadKey() |> ignore
# 1. Open separate powershell window
# 2. Make sure you are in FSharpKoans solution folder
# 3. Run watch_fsharpkoans.ps1
# 4. Make both your visual studio and powershell window visitble at the same time
# 5. Enjoy!
@palladin
palladin / gist:8577661
Last active September 25, 2021 17:51
F# style LINQ programming with tuples
public static class EnumerableEx
{
public static IEnumerable<R> Select<T1, T2, R>(this IEnumerable<Tuple<T1, T2>> source, Func<T1, T2, R> f)
{
return source.Select(t => f(t.Item1, t.Item2));
}
}
Enumerable.Range(1, 10)
.Select(x => Tuple.Create(x, x))
процедура MergeSort (мод a: t) це
процедура Merge(арг a: t; Size: нат; рез b: t) це
змін i, j, k, r1, r2: нат;
поч
k <- 1;
поки k<=n повт
{визначення границь підмасивів}
i <- k; r1 <- i+Size-1;
якщо r1>n то r1 <- n кр;
j <- r1+1; r2 <- j+Size-1;
#Example for the kaggle forums.
library(FNN)
library(stats)
train <- read.csv("data/train.csv", header=TRUE, comment.char="")
test <- read.csv("data/test.csv", header=TRUE, comment.char="")
N <- 30000
set.seed(20140202)
trainingSet <- train[sample(1:nrow(train), N), ]