Skip to content

Instantly share code, notes, and snippets.

View jiridanek's full-sized avatar
🍻

Jiri Daněk jiridanek

🍻
View GitHub Profile
@peterhurford
peterhurford / pytest-fixture-modularization.md
Created July 28, 2016 15:48
How to modularize your py.test fixtures

Using py.test is great and the support for test fixtures is pretty awesome. However, in order to share your fixtures across your entire module, py.test suggests you define all your fixtures within one single conftest.py file. This is impractical if you have a large quantity of fixtures -- for better organization and readibility, you would much rather define your fixtures across multiple, well-named files. But how do you do that? ...No one on the internet seemed to know.

Turns out, however, you can define fixtures in individual files like this:

tests/fixtures/add.py

import pytest

@pytest.fixture
@cabbageshop
cabbageshop / AdminDeployment.xml
Created September 12, 2015 09:23
VS2015 AdminDeployment.xml : The stuff that I use
<?xml version="1.0" encoding="utf-8"?>
<AdminDeploymentCustomizations xmlns="http://schemas.microsoft.com/wix/2011/AdminDeployment">
<BundleCustomizations TargetDir="default" NoWeb="default" />
<SelectableItemCustomizations>
<SelectableItemCustomization Id="VC_MFC_Libraries" Hidden="no" Selected="no" />
<SelectableItemCustomization Id="SQL" Hidden="no" Selected="yes" />
<SelectableItemCustomization Id="WebTools" Hidden="no" Selected="yes" />
<SelectableItemCustomization Id="MDDCPlusPlus" Hidden="no" Selected="no" />
<SelectableItemCustomization Id="MDDJS" Hidden="no" Selected="no" />
<SelectableItemCustomization Id="SilverLight_Developer_Kit" Hidden="no" Selected="no" />
@yowu
yowu / HttpProxy.go
Last active March 26, 2025 05:23
A simple HTTP proxy by Golang
package main
import (
"flag"
"io"
"log"
"net"
"net/http"
"strings"
)
@ocornut
ocornut / printf_tips.cpp
Last active March 24, 2023 11:23
C/C++ tips for using printf-style functions
// C/C++ tips for using printf-style functions
// Lots of manipulation can be expressed simply and fast with printf-style formatting
// Also helps reducing the number of temporaries, memory allocations or copies
// ( If you are looking for a simple C++ string class that is printf-friendly and not heap-abusive,
// I've been using this one: https://github.com/ocornut/Str )
// If you are interested in a FASTER implementation of sprintf functions, see stb_sprintf.h
// https://github.com/nothings/stb/blob/master/stb_sprintf.h
// How to concatenate non-zero terminated strings
@andreygursky
andreygursky / Makefile
Created June 21, 2012 22:11
simple test for memory allocation for global variables in dynamically loaded lib
CC=gcc
CFLAGS=-Wall -g
all: libdl_func.so.1.0.0 test_dl
libdl_func.so.1.0.0: dl_func.o
rm -f libdl_func.so
rm -f libdl_func.so.1
$(CC) -o $@ $^ -shared -Wl,-soname,libdl_func.so.1
ln -s libdl_func.so.1.0.0 libdl_func.so
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@bemasher
bemasher / Castle.xml
Created September 18, 2011 03:46
Example of parsing xml in golang.
<?xml version="1.0" encoding="UTF-8" ?>
<Data>
<Series>
<id>83462</id>
<Actors>|Nathan Fillion|Stana Katic|Molly C. Quinn|Jon Huertas|Seamus Dever|Tamala Jones|Susan Sullivan|Ruben Santiago-Hudson|Monet Mazur|</Actors>
<Airs_DayOfWeek>Monday</Airs_DayOfWeek>
<Airs_Time>10:00 PM</Airs_Time>
<ContentRating>TV-PG</ContentRating>
<FirstAired>2009-03-09</FirstAired>
<Genre>|Drama|</Genre>
@jrk
jrk / .profile.functions
Created October 7, 2009 18:13
Tools for easily and automatically initializing/renewing Kerberos tickets with launchd and from command-line scripts on Snow Leopard.
# Initialize or renew Kerberos tickets. Assumes password for the requested principal is stored in the
# keychain, which is now automatically used by Snow Leopard kinit.
# This is useful to define globally in your shell profile, for easy use within other scripts and
# from the command-line.
function ker {
kinit -R 2> /dev/null
if [[ $? = '0' ]]; then
echo "renewed..."
klist
else