Skip to content

Instantly share code, notes, and snippets.

View akubera's full-sized avatar

Andrew Kubera akubera

View GitHub Profile
@akubera
akubera / run.py
Last active March 9, 2023 02:27
asyncio queue example
import asyncio
# global queue
queue = asyncio.Queue()
async def main():
server = await asyncio.start_server(on_connection, host='localhost', port=4242)
# ORIGNIAL "SUBWAY" CODE - as long as a task is created in consumer_task, it will run

Keybase proof

I hereby claim:

  • I am akubera on github.
  • I am andrewkubera (https://keybase.io/andrewkubera) on keybase.
  • I have a public key ASA0xlTmHWxFKYGODXc72iUAi6nhJosZYaqadisp1YMEyAo

To claim this, I am signing this object:

#include <TString.h>
#include <TApplication.h>
#include <vector>
#include <iterator>
struct ArgList {
struct Arg {
TString name;
@akubera
akubera / AClass.cxx
Created April 3, 2017 15:06
Forward Declaration
#include "AClass.h"
#include "BClass.h"
A::A(): fB(nullptr)
{
}
@akubera
akubera / getline.cpp
Last active March 27, 2017 17:01
getline
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
void do_stuff_with_file(const std::string &filename);
const std::string DEFAULT_FILELIST_NAME = "rootfiles.txt";
int main(int argc, char **argv)
@akubera
akubera / dispatch_method.py
Last active August 2, 2016 19:17
Add singular dispatch decorator to a class method - skipping the first argument (self)
#
# Version 1 - terse
#
def dispatchmethod(func):
from functools import wraps, singledispatch
# given a function, return function that swaps first two arguments
swapargs = lambda f: lambda a, b, *args, **kw: f(b, a, *args, **kw)
# create dispatched on swapped version of given function
dispatched_method = singledispatch(swapargs(func))
@akubera
akubera / optimizer.md
Last active July 14, 2016 21:21
documented exploration of optimizing c++ code

Optimizer

This is a simple walkthrough looking at how the compiler optimizes various C/C++ code. To use this, go to http://gcc.godbolt.org/ and place the code boxes from this document into the "Code editor" there. You can see the ASM output on the right, and get a feeling for how well your code is optimized.

I'll be referencing the x86 gcc 5.3 compiler, but feel free to change that up to see how different compilers/architectures treat the same code.

@akubera
akubera / CONTRIBUTING.rst
Created May 6, 2016 18:59
GrowlerDraft - CONTRIBUTING

Contributing

Thank you for considering making a contribution to the Growler project!

Growler is a community effort and only will survive with help from people who see the value in the product and want to see that value grow. Being released in a standard open source license, it is free for you to use and improve this software however you see fit, but it'd be great if your improvements were given back to the

#include <TH1F.h>
#include <TObjArray.h>
#include <map>
enum ParticleType {
UnknownType = -1,
ProtonType = 0,
AntiProtonType = 1,
@akubera
akubera / ConfigFemtoAnalysis.C
Created June 3, 2015 11:33
Quick Femto Analysis
//
// ConfigFemtoAnalysis.C
//
AliFemtoManager*
ConfigFemtoAnalysis()
{
const double PionMass = 0.13956995;
//