Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
🐧

Makc singulared

💭
🐧
View GitHub Profile
@singulared
singulared / prepare-commit-msg
Created Jun 17, 2021
Git hook for adding branch name into the commit message.
View prepare-commit-msg
#!/bin/sh
#
# An example hook script to prepare the commit log message.
# Called by "git commit" with the name of the file that has the
# commit message, followed by the description of the commit
# message's source. The hook's purpose is to edit the commit
# message file. If the hook fails with a non-zero status,
# the commit is aborted.
#
# To enable this hook, rename this file to "prepare-commit-msg".
@singulared
singulared / sway-lock.sh
Created Feb 12, 2020
swaylock with image per-output
View sway-lock.sh
#!/bin/bash
# Dependencies:
# imagemagick
# swaylock
# grim
IMAGE=/tmp/i3lock.png
LOCK=~/.config/sway/lock.png
LOCKARGS=""
@singulared
singulared / playground.rs
Last active Feb 5, 2020 — forked from rust-play/playground.rs
impl From variadic like :D
View playground.rs
#[derive(Debug)]
struct CM {
id: i32,
topic_id: i32,
}
#[derive(Debug)]
struct TM {
id: i32,
}
@singulared
singulared / 99-mali-devices.rules
Created Mar 28, 2013
Set /dev/mali* permission to mali group from udev.
View 99-mali-devices.rules
# From /etc/udev/rules.d/99-mali-devices.rules
# Graphic devices
KERNEL=="mali*" OWNER="root" GROUP="mali" MODE="0660"
@singulared
singulared / prepare-commit-msg
Created Aug 26, 2019
Git hook for adding branch name for each commit message.
View prepare-commit-msg
#!/bin/sh
#
# An example hook script to prepare the commit log message.
# Called by "git commit" with the name of the file that has the
# commit message, followed by the description of the commit
# message's source. The hook's purpose is to edit the commit
# message file. If the hook fails with a non-zero status,
# the commit is aborted.
#
# To enable this hook, rename this file to "prepare-commit-msg".
@singulared
singulared / state.rs
Created May 27, 2019 — forked from dbrgn/state.rs
Custom Text based Diesel type for an enum
View state.rs
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq)]
#[serde(rename_all="snake_case")]
pub enum State {
Pending,
Sending,
Sent,
Failed,
}
impl fmt::Display for State {
@singulared
singulared / futures.rs
Created May 23, 2019
Collecting vector of future's results in rust
View futures.rs
use futures; // 0.1.26
use futures::prelude::*;
use futures::future::{ok, err};
use futures::stream::*;
use futures::future::FutureResult;
fn future_result(x: i32) -> FutureResult<i32, i32> {
match x {
1 => ok(42),
@singulared
singulared / futures.rs
Created May 20, 2019
multiple futures in one function
View futures.rs
use futures::future::*;
fn either(x: Option<i32>) -> impl Future<Item = i32, Error = i32> {
match x {
Some(x) => Either::A(ok(x).map(|x| x)),
None => Either::B(ok(42).and_then(|x| err(x)))
}
}
fn boxed(x: Option<i32>) -> Box<Future<Item = i32, Error = i32>> {
View 50-synaptics.conf
Section "InputClass"
Identifier "touchpad"
Driver "synaptics"
MatchIsTouchpad "on"
Option "TapButton1" "1"
Option "TapButton2" "2"
Option "TapButton3" "3"
Option "VertEdgeScroll" "off"
Option "VertTwoFingerScroll" "on"
Option "HorizEdgeScroll" "off"
@singulared
singulared / ensure_future.py
Created Feb 27, 2018
ensure_future scheduled corotine
View ensure_future.py
import asyncio
async def d():
print('d start')
await asyncio.sleep(2)
print('d stop')
async def f():
print('f start')