Skip to content

Instantly share code, notes, and snippets.

View LiHRaM's full-sized avatar

Hilmar Gústafsson LiHRaM

View GitHub Profile
// using Quickpay;
// using RestSharp;
public object GetPayment(Invoice invoice)
{
Action<RestRequest> prepareRequest = (RestRequest request) =>
{
request.Method = Method.POST;
request.AddParameter("order_id", invoice.Id);
request.AddParameter("currency", "DKK");
for line in lines {
match Indentation::parse_line(&line) {
Ok(Some(Indentation::Spaces(size))) => { *spaces.entry(size).or_insert(0) += 1; }, // Derp
Ok(Some(Indentation::Tabs)) => tabs = true,
Ok(None) => continue,
Err(e) => return Err(e),
}
}
fn extract_count(spaces: HashMap<usize, usize>) -> Result<usize, String> {
if spaces.len() < 3 {
return Err(String::from("Couldn't guess: Too few lines."))
}
let mut result: [(usize, usize); 3] = [(0, 0); 3];
for (key, value) in spaces.iter() {
if value > &result[0].1 {
result[0] = (*key, *value);
}
@LiHRaM
LiHRaM / pulp_fiction.sql
Created April 5, 2019 19:22
Which actors from pulp fiction never acted with any other actors from pulp fiction before or after
SELECT p.name, COUNT(m.movieid)
FROM person p JOIN involved i ON p.id = i.personid
JOIN (
SELECT i.personid
FROM involved i
JOIN movie m ON m.id = i.movieid
WHERE i.role = 'actor'
AND m.title = 'Pulp Fiction'
) pulp ON pulp.personid = i.personid
LEFT JOIN (
import Data.HashMap.Strict (fromList)
import Data.Hashable (Hashable)
valid :: (Eq i, Hashable i) => [(i, o)] -> Bool
valid l = length l == length (fromList l)
{- Loading the lib via ghci:
[1 of 1] Compiling Lib ( Lib.hs, interpreted )
• Could not deduce (hashable-1.2.6.1:Data.Hashable.Class.Hashable

Keybase proof

I hereby claim: * I am lihram on github. * I am lihram (https://keybase.io/lihram) on keybase. * I have a public key ASBm3i-WTV8_OlpV9VJKSyq3Xa9Asg9AJdtuj_lmG-fhgwo To claim this, I am signing this object:

{   "body": {     "key": {       "eldest_kid": "0120c6160591df2673d4b7f63e5c2be877f9eb961765619c1f89dc85aa073ab5aa370a",       "host": "keybase.io",       "kid": "012066de2f964d5f3f3a5a55f5524a4b2ab75daf40b20f4025db6e8ff9661be7e1830a",       "uid": "7b64447b8ce04926e33a3f179f7b9819",       "username": "lihram"     },     "merkle_root": {       "ctime": 1579611268,       "hash": "862f6176cd640d7858e6b29af8c8ebe459cad1e45748704c7142a06102a6af9013be400bdb1301010cb9a20cf36ae504d841fb1bfad59c7730c0f4ce4eb517fd",       "hash_meta": "f17680c71635830d53dac466428c950477e76abd1e0036908b52bd5182345b72",       "seqno": 14308158     },     "service": {       "entropy": "PWBzpotG0SLusZihz4ztWSEG",       "name": "github",       "username": "lihram"     },     "type": "web_service_bindin
# Maintainer: lihram <hilmargustafs@gmail.com>
pkgname=dust-bin
pkgver=v0.5.1
pkgrel=1
arch=('i686' 'x86_64')
pkgdesc="A more intuitive version of du in rust"
conflicts=('dust')
source=("$pkgname-$pkgver.tar.gz::https://github.com/bootandy/dust/releases/download/$pkgver/dust-$pkgver-$CARCH-unknown-linux-gnu.tar.gz")
url="https://github.com/bootandy/dust"
license=('Apache-2.0')
~
λ loginctl
SESSION UID USER SEAT TTY
11 1000 lihram seat0 tty3
3 1000 lihram seat0 tty1
9 1001 greeter seat0 tty1
3 sessions listed.
@LiHRaM
LiHRaM / journalctl
Created July 10, 2020 14:57
journalctl output for greetd and logind
# Greetd
-- Reboot --
Jul 10 07:49:15 pop-os systemd[1]: Started Greeter daemon.
Jul 10 07:49:15 pop-os greetd[1706]: warning: PAM 'greetd' service missing, falling back to 'login'
Jul 10 07:49:15 pop-os greetd[1710]: pam_unix(login:session): session opened for user greeter by (uid=0)
Jul 10 07:49:18 pop-os greetd[2135]: pam_unix(login:auth): Couldn't open /etc/securetty: No such file or directory
Jul 10 07:49:20 pop-os greetd[2135]: pam_unix(login:auth): Couldn't open /etc/securetty: No such file or directory
Jul 10 07:49:21 pop-os greetd[2135]: pam_unix(login:session): session opened for user lihram by (uid=0)
Jul 10 08:22:11 pop-os greetd[9140]: pam_unix(login:session): session opened for user greeter by (uid=0)
Jul 10 16:50:31 pop-os greetd[136262]: pam_unix(login:auth): Couldn't open /etc/securetty: No such file or directory
@LiHRaM
LiHRaM / repos.sh
Last active December 10, 2020 00:21
Find git repos fast
#! /usr/bin/env sh
# Fuzzy search git repos, starting at at $HOME/git,
# unless the path argument is provided.
function repos() {
# Start the search at $1, or, if that is null, $HOME/git.
local path=${1-~/git}
# First use `fd` to search for the hidden `.git` folder.
# Remove the trailing `.git` to show the parent folder instead (the actual repository)