Skip to content

Instantly share code, notes, and snippets.

View mnn's full-sized avatar

monnef mnn

View GitHub Profile
@ryleu
ryleu / linuxoverwatch.md
Last active May 31, 2023 07:44
OW 2 on Linux

This guide is completely irrelevant! You no longer need to follow anything here—doing so may actually harm performance rather than helping it. Please tell whoever linked you here that they need to maintain their own guide, if they want to help people set up newer versions of DXVK / etc.

@tsjnachos117
tsjnachos117 / gist:8231f9f8ed08968cc5f1a7f4d3e06b0e
Last active January 9, 2024 01:43
Get KDE Connect battery info (from desktop/laptop)

I find the ability to get my android devices' battery info on my desktops via cli to be extremely convenient. I used to be able to this with KDE Connect easily, but things have just changed. Since I can't find any documentation on how to do this, and since I just stumbled on the answer myself, I though I might share what I know here. Please note that in the examples below, I will be using {device-id} as a placeholder for the string that KDE Connect uses to identify to my devices.

That said, I used to be able to get my various devices' battery status through gdbus through the following:

    gdbus call --session --dest org.kde.kdeconnect --object-path /modules/kdeconnect/devices/{device-id} --method org.kde.kdeconnect.device.battery.charge

However on Arch, I now get the following error: Error: GDBus.Error:org.freedesktop.DBus.Error.UnknownInterface: No such interface 'org.kde.kdeconnect.device.battery' at object path '/modules/kdeconnect/devices/b04294f19e8767f5'. I don't get this message on Ubuntu 2

@graninas
graninas / haskeller_competency_matrix.md
Last active April 25, 2024 20:48
Haskeller competency matrix

Haskeller Competency Matrix

See also List of materials about Software Design in Haskell

Junior Middle Senior Architect
Haskell level Basic Haskell Intermediate Haskell Advanced Haskell Language-agnostic
Haskell knowledge scope Learn you a Haskell Get programming with Haskell Haskell in Depth Knows several languages from different categories
Get programming with Haskell Haskell in Depth Functional Design and Architecture
[Other books on Software Engineering in Haskell](https://github.com/graninas/software-design-in-haskell#B
#!/usr/bin/python3
from bluepy import btle
import sys
class DiscoLH(btle.DefaultDelegate):
def __init__(self):
self.devices = []
btle.DefaultDelegate.__init__(self)
@Programie
Programie / pa-app-sink-switcher.py
Last active December 24, 2022 08:57
Toggle PulseAudio output sink for the active application
#! /usr/bin/env python3
# This script toggles the PulseAudio output sink of the currently active application (guessed by the currently active X window) between the given output sink and the default output sink.
# The output sink is passed as first argument to the script.
#
# Requirements:
#
# xdotool (on Ubuntu install via "sudo apt install xdotool")
# pulsectl ("sudo pip3 install pulsectl")
@VictorTaelin
VictorTaelin / promise_monad.md
Last active April 28, 2024 13:28
async/await is just the do-notation of the Promise monad

async/await is just the do-notation of the Promise monad

CertSimple just wrote a blog post arguing ES2017's async/await was the best thing to happen with JavaScript. I wholeheartedly agree.

In short, one of the (few?) good things about JavaScript used to be how well it handled asynchronous requests. This was mostly thanks to its Scheme-inherited implementation of functions and closures. That, though, was also one of its worst faults, because it led to the "callback hell", an seemingly unavoidable pattern that made highly asynchronous JS code almost unreadable. Many solutions attempted to solve that, but most failed. Promises almost did it, but failed too. Finally, async/await is here and, combined with Promises, it solves the problem for good. On this post, I'll explain why that is the case and trace a link between promises, async/await, the do-notation and monads.

First, let's illustrate the 3 styles by implementing

@Bunyod
Bunyod / Entities.scala
Created October 27, 2016 07:27
Slick one to many and grouping
object Entities {
case class Review(txt: String, userId: Long, id: Long)
case class User(name: String, id: Long)
case class ReviewEvent(event: String, reviewId: Long)
case class FullReview(r: Review, user: User, evts: Seq[ReviewEvent])
}
@ikhoon
ikhoon / must-watch-talks.md
Last active April 14, 2020 10:46
Must watch talks - reddit /r/scala
@evincarofautumn
evincarofautumn / InlineDoBind.md
Last active April 20, 2023 21:16
Thoughts on an InlineDoBind extension

Thoughts on an InlineDoBind extension

An expression beginning with a left arrow (<-) inside a do block statement is desugared to a monadic binding. This is syntactically a superset of existing Haskell, including extensions. It admits a clean notation that subsumes existing patterns and comes with few downsides.

Examples

do
  f (<- x) (<- y)
-- ===

10 Scala One Liners to Impress Your Friends

Here are 10 one-liners which show the power of scala programming, impress your friends and woo women; ok, maybe not. However, these one liners are a good set of examples using functional programming and scala syntax you may not be familiar with. I feel there is no better way to learn than to see real examples.

Updated: June 17, 2011 - I'm amazed at the popularity of this post, glad everyone enjoyed it and to see it duplicated across so many languages. I've included some of the suggestions to shorten up some of my scala examples. Some I intentionally left longer as a way for explaining / understanding what the functions were doing, not necessarily to produce the shortest possible code; so I'll include both.

1. Multiple Each Item in a List by 2

The map function takes each element in the list and applies it to the corresponding function. In this example, we take each element and multiply it by 2. This will return a list of equivalent size, compare to o