Skip to content

Instantly share code, notes, and snippets.

View u2386's full-sized avatar
:octocat:
Code Addict

u2386 u2386

:octocat:
Code Addict
View GitHub Profile
@alexandrnikitin
alexandrnikitin / install-systemtap-on-centos-7.sh
Created August 11, 2017 14:06
Install systemtap on Centos 7
sudo yum install -y systemtap systemtap-runtime
sudo yum install kernel-debuginfo kernel-debuginfo-common
sudo yum install yum-utils
debuginfo-install kernel-3.10.0-514.21.2.el7.x86_64
sudo yum install -y kernel-devel-$(uname -r)
sudo yum install -y kernel-debuginfo-$(uname -r)
sudo yum install -y kernel-debuginfo-common-$(uname -m)-$(uname -r)
@sunaku
sunaku / fizzbuzz.exs
Last active July 14, 2020 18:10
A functional FizzBuzz (without any integer modulus or division) in Elixir. See https://pragprog.com/magazines/2012-08/thinking-functionally-with-haskell
# A functional FizzBuzz (without any integer modulus or division) in Elixir
# https://pragprog.com/magazines/2012-08/thinking-functionally-with-haskell
nums = Stream.iterate(1, &(&1 + 1))
fizz = Stream.cycle ["", "", "Fizz"]
buzz = Stream.cycle ["", "", "", "", "Buzz"]
fizzbuzz = Stream.zip(fizz, buzz) |> Stream.zip(nums) |> Stream.map(fn
{{"", "" }, number} -> number
{{fizzword, buzzword}, _number} -> fizzword <> buzzword
end)
fizzbuzz |> Stream.take(100) |> Enum.each(&IO.puts/1)
@p7k
p7k / gist:4238388
Created December 8, 2012 03:02
greenlet throttling decorator | rate limiting gevent | with semaphores
from functools import wraps
from timeit import default_timer
import gevent
from gevent.queue import Queue
def gevent_throttle(calls_per_sec=0):
"""Decorates a Greenlet function for throttling."""
interval = 1. / calls_per_sec if calls_per_sec else 0
def decorate(func):
blocked = [False] # has to be a list to not get localised inside the while loop