Skip to content

Instantly share code, notes, and snippets.

@dagron
dagron / factories.py
Created March 24, 2021 14:29
django hypothesis factory boy
import string
import factory
from django.contrib.auth import get_user_model
from hypothesis import strategies as st
UserModel = get_user_model()
DEFAULT_PASSWORD = 'default_password'
class UserFactory(factory.django.DjangoModelFactory):
@dagron
dagron / GetNameAndTitleOfActiveWindow.scpt
Created September 28, 2020 16:14 — forked from timpulver/GetNameAndTitleOfActiveWindow.scpt
[AppleScript] Get Name of active window | Returns the name / title of the active (frontmost) window
# taken from user Albert's answer on StackOverflow
# http://stackoverflow.com/questions/5292204/macosx-get-foremost-window-title
# tested on Mac OS X 10.7.5
global frontApp, frontAppName, windowTitle
set windowTitle to ""
tell application "System Events"
set frontApp to first application process whose frontmost is true
set frontAppName to name of frontApp
@dagron
dagron / readme.md
Created May 3, 2020 06:20 — forked from noahcoad/readme.md
Code Minecraft with Python on Mac OSX

Code Minecraft with Python on Mac OSX

Here's a step-by-step to get started scripting Minecraft with Python on Mac OSX

@dagron
dagron / README.md
Created August 15, 2019 14:50 — forked from tmilos/README.md
Modified Preorder Tree Traversal

Modified Preorder Tree Traversal

Hierarchical data metrics that allows fast read operations on tree like structures.

Based on Left and Right fields that are set during tree traversal. When entered into node value is set to it's Left, when exiting node value is set to it's Right.

Sample implementation

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dagron
dagron / specfn.clj
Created May 31, 2019 07:52 — forked from borkdude/specfn.clj
Use a spec for defining function arguments and get validation automatically
(ns specfn.core
(:require [clojure.spec :as s]
[clojure.spec.test :as t]))
(defn- spec-symbols [s]
(->> s
(drop 1)
(partition-all 2)
(map first)
(map name)
@dagron
dagron / CustomPropertyAccessor.php
Created February 13, 2019 21:40 — forked from boekkooi/CustomPropertyAccessor.php
Using a custom property path for symfony forms set / get path
<?php
use Symfony\Component\PropertyAccess\PropertyAccessor;
use Symfony\Component\PropertyAccess\PropertyPath;
/**
* A property accessor that allows you to rewrite a property path for setters and getters.
*/
class CustomPropertyAccessor extends PropertyAccessor
{
/**
@dagron
dagron / clj_spec_playground.clj
Created February 7, 2019 14:24 — forked from ghoseb/clj_spec_playground.clj
Examples of Clojure's new clojure.spec library
(ns clj-spec-playground
(:require [clojure.string :as str]
[clojure.spec :as s]
[clojure.test.check.generators :as gen]))
;;; examples of clojure.spec being used like a gradual/dependently typed system.
(defn make-user
"Create a map of inputs after splitting name."
([name email]
@dagron
dagron / handler.clj
Created February 7, 2019 09:54 — forked from weissjeffm/handler.clj
An error handler for Clojure
(ns com.redhat.qe.handler
(:import [javax.naming NamingException]))
(def *handlers* [])
(def *error* nil)
(defn- e-to-map [e]
{:msg (.getMessage e) :type (class e) :exception e})
(defn- wrapped? [e]
@dagron
dagron / jxmls.clj
Created December 14, 2018 07:54 — forked from krisleech/jxmls.clj
JXLS in Clojure
:dependencies [[org.clojure/clojure "1.8.0"]
[org.jxls/jxls "2.4.2"]
[org.jxls/jxls-poi "1.0.13" :exclusions [org.jxls/jxls]]])
(import [org.jxls.util JxlsHelper])
(import [org.jxls.common Context])
(require '(clojure.java [io :as io]))
;; http://jxls.sourceforge.net/xls/object_collection_template.xls