Skip to content

Instantly share code, notes, and snippets.

View tungd's full-sized avatar
🐳
Back to normal

Tung Dao tungd

🐳
Back to normal
View GitHub Profile
@dive
dive / fix-emacs-permissions-catalina.el
Created September 29, 2019 09:55
Fix Emacs permissions on macOS Catalina
;;; package --- Fix permissions for Emacs.app on macOS Catalina
;;; Author: Artem Loenko
;;; Mail-To: <artyom.loenko@mac.com>
;;; Commentary:
;;; Code:
(defconst _default-emacs-app-plist-path "/Applications/Emacs.app/Contents/Info.plist")
(defconst _temp-buffer-name "*fixing Emacs permissions*")
(defconst _temp-buffer (get-buffer-create _temp-buffer-name))
(with-current-buffer _temp-buffer (erase-buffer))
@parsonsmatt
parsonsmatt / no-thanks-acid-state.md
Created December 17, 2018 18:46
acid state antirecommendation

Someone asked whether or not acid-state was production ready. I shared my experiences:

parsonsmatt [11:32 AM] @nikolap it's used by cardano-wallet and Hackage. Based on my experience with acid-state, I'd say it is not a good choice for production data storage. For local desktop apps, SQLite is a much better choice, and for real production apps, Postgresql is king.

parsonsmatt [11:44 AM] acid-state did not have a test suite, at all, until I implemented the very first tests (for TemplateHaskell code generation) earlier this year. It has picked up some tests since then, but I'm still not confident in it's correctness.

It claims to be resilient to unplugging the power cord, but I doubt that, as it's not resilient to Ctrl-C: acid-state/acid-state#79

Time Travel Debugging

Time Travel refers to the ability to record a tab and later replay it ([WebReplay][wrr]). The technology is useful for local development, where you might want to:

  • pause and step forwards or backwards
  • pause and rewind to a prior state
  • rewind to the time a console message was logged
  • rewind to the time an element had a certain style or layout
  • rewind to the time a network asset loaded
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@alpmestan
alpmestan / redirect.hs
Created October 17, 2017 12:10
servant redirects, new generation
{-
$ curl -X POST localhost:9876/dog -v
* Connected to localhost (127.0.0.1) port 9876 (#0)
> POST /dog HTTP/1.1
> Host: localhost:9876
> User-Agent: curl/7.55.1
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Transfer-Encoding: chunked
@mchubby
mchubby / ddc-ci-u2713hm.py
Last active July 7, 2023 04:12 — forked from Fr6jDJF/ddc-ci.py
Python script for adjusting the settings of my monitor, by using DDC/CI
#!/usr/bin/env python3
"""
Show and adjust display parameters on a Dell U2713HM monitor
Requirements:
- mentioned monitor (27' should also work) with DDC/CI setting on
- Windows Vista+ (dxva2.dll)
- Python 3
@agnaldo4j
agnaldo4j / crawler_example.md
Last active October 15, 2016 11:20
Crawler example with mochiweb_html and mochiweb_xpath.

Elixir simple crawler example

This example uses thease projects:

  1. mochiweb
  2. mochiweb_xpath

The HtmlPageReader goes to html's page and transform that content with mochiweb_html.parse

defmodule Usecase.HtmlPageReader do
@btroncone
btroncone / rxjs_operators_by_example.md
Last active July 16, 2023 14:57
RxJS 5 Operators By Example
@sevaine
sevaine / VMWare-Fusion-OSX-Yosemite-default-VM-Path-change.md
Created September 19, 2015 09:10
Changing the default VM Path in VMWare Fusion on OSX Yosemite

Changing the default VM Path in VMWare Fusion on OSX Yosemite:

I had a little trouble figuring this out - so making a note of it. The VMWare Fusion default location for VMs is ~/Documents/Virtual Machines.localized, which doesnt work well for me as I typically have Documents symbolically linked to my Dropbox directory and prefer to move the default VM location rather than manage exclusions on every Dropbox install I have.

It's relatively straightforward on VMWare Workstation, and Oracle VirtualBox - but for some reason

@Grokzen
Grokzen / Symmetrical ManyToMany Filter Horizontal in Django Admin.py
Last active March 12, 2024 17:55
Symmetrical ManyToMany Filter Horizontal in Django Admin
# Based on post from: https://snipt.net/chrisdpratt/symmetrical-manytomany-filter-horizontal-in-django-admin/#L-26
# Only reposting to avoid loosing it.
"""
When adding a many-to-many (m2m) relationship in Django, you can use a nice filter-style multiple select widget to manage entries. However, Django only lets you edit the m2m relationship this way on the forward model. The only built-in method in Django to edit the reverse relationship in the admin is through an InlineModelAdmin.
Below is an example of how to create a filtered multiple select for the reverse relationship, so that editing entries is as easy as in the forward direction.
IMPORTANT: I have no idea for what exact versions of Django this will work for, is compatible with or was intended for.