Skip to content

Instantly share code, notes, and snippets.

@ssokolow
ssokolow / x11_watch_active_window.py
Last active February 6, 2024 22:50
python-xlib example which reacts to changing the active window
#!/usr/bin/env python
"""python-xlib example which reacts to changing the active window/title.
Requires:
- Python
- python-xlib
Tested with Python 2.x because my Kubuntu 14.04 doesn't come with python-xlib
for Python 3.x.
@pratos
pratos / condaenv.txt
Created November 30, 2016 07:01
To package a conda environment (Requirement.txt and virtual environment)
# For Windows users# Note: <> denotes changes to be made
#Create a conda environment
conda create --name <environment-name> python=<version:2.7/3.5>
#To create a requirements.txt file:
conda list #Gives you list of packages used for the environment
conda list -e > requirements.txt #Save all the info about packages to your folder
@tasdikrahman
tasdikrahman / python_tests_dir_structure.md
Last active May 9, 2024 19:46
Typical Directory structure for python tests

A Typical directory structure for running tests using unittest

Ref : stackoverflow

The best solution in my opinion is to use the unittest [command line interface][1] which will add the directory to the sys.path so you don't have to (done in the TestLoader class).

For example for a directory structure like this:

new_project

├── antigravity.py

@markrendle
markrendle / explanation.md
Last active July 3, 2022 07:56
Why I was previously not a fan of Apache Kafka

Update, September 2016

OK, you can pretty much ignore what I wrote below this update, because it doesn't really apply anymore.

I wrote this over a year ago, and at the time I had spent a couple of weeks trying to get Kafka 0.8 working with .NET and then Node.js with much frustration and very little success. I was rather angry. It keeps getting linked, though, and just popped up on Hacker News, so here's sort of an update, although I haven't used Kafka at all this year so I don't really have any new information.

In the end, we managed to get things working with a Node.js client, although we continued to have problems, both with our code and with managing a Kafka/Zookeeper cluster generally. What made it worse was that I did not then, and do not now, believe that Kafka was the correct solution for that particular problem at that particular company. What they were trying to achieve could have been done more simply with any number of other messaging systems, with a subscriber reading messages off and writing

@xuwei-k
xuwei-k / jol-example
Last active April 9, 2016 12:13
jol sample
$ screpl org.openjdk.jol%jol-core%0.2
[info] Loading global plugins from /Users/user/.sbt/0.13/plugins
[info] Set current project to ivy-console (in build file:/Users/user/.sbt/boot/ivy-console/)
Welcome to Scala version 2.11.4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_25).
Type in expressions to have them evaluated.
Type :help for more information.
scala> println(org.openjdk.jol.info.ClassLayout.parseClass(classOf[Vector[Int]]).toPrintable)
scala.collection.immutable.Vector object internals:
OFFSET SIZE TYPE DESCRIPTION VALUE
@guizmaii
guizmaii / GithubHelper.scala
Last active February 18, 2017 00:03
Helper object that help to parse the "Link" header of the Github API v3, in Scala
object GithubHelper {
/**
* Parse the Github Link HTTP header used for pagination
*
* http://developer.github.com/v3/#pagination
*
* Original code found here : https://gist.github.com/niallo/3109252
*
* @param linkHeader
@agemooij
agemooij / 1. README.md
Last active September 26, 2018 13:19
Quick spray-routing authentication example

Extremely bare example of Spray routing authentication using session cookies and XSRF tokens

This code was quickly ripped out of an active project to serve as an example. It will not compile in any way!

Any questions? Add them to the comments!

Notes

  • the application uses a version of the cake pattern to compose the Spray routing application together from various traits
  • a lot of those traits should be pretty self-explaining based on their name but if requested I can paste them into this Gist
@jessitron
jessitron / stayingDead.scala
Created March 19, 2014 15:23
Akka testing: it's a good idea to tell your actor system to leave a dead top-level actor dead. See: http://blog.jessitron.com/2014/03/testing-in-akka-sneaky-automatic.html
// In real life, it's great that stuff gets restarted when it fails.
// In testing, we'd rather know that it failed.
import akka.actor._
class DyingActor extends Actor {
def receive = { case "die" => throw new Exception("poo") }
}
// Default config, everything restarts automatically
val system = ActorSystem("ordinary")
@davepape
davepape / LeapPyglet-udp.py
Last active December 9, 2021 21:19
Pyglet program to receive hand & finger data from the hacked "LeapSample.py" program (via UDP) and render it in 2D
#
# Receive hand & finger data from "LeapSample.py" via UDP and render it in 2D
#
from pyglet.gl import *
# Create a UDP socket to receive the data
import socket
insock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# Listen to port 5000
insock.bind(('',5000))
@tavisrudd
tavisrudd / links.txt
Created March 23, 2013 04:55
some links related to my voice coding talk at #pycon