Skip to content

Instantly share code, notes, and snippets.

@jonfk
jonfk / bookmarklet_image_dwl.js
Last active October 26, 2022 18:20 — forked from lucidBrot/bookmarklet_image_dwl.js
Bookmarklet to download some images on a page
// as one-liner for bookmarklet
javascript:;(function(){var images=document.querySelector('#background.player').children;try{for (let img of images) {downloadResource(img.src)}}catch(e){alert("Download failed.");console.log('Download failed.',e)}function forceDownload(blob,filename){var a=document.createElement('a');a.download=filename;a.href=blob;a.click()}function downloadResource(url,filename){if(!filename)filename=url.split('\\').pop().split('/').pop();fetch(url,{headers:new Headers({'Origin':location.origin}),mode:'cors'}).then(response=>response.blob()).then(blob=>{let blobUrl=window.URL.createObjectURL(blob);forceDownload(blobUrl,filename)}).catch(e=>console.error(e))}}).call(window);
@jonfk
jonfk / hollow_knight_fix_dualsense.txt
Last active February 13, 2024 13:44
Fix to use dualsense controller in hollow knight on linux
# This fixes the issue of swapped buttons and Triggers in the dualsense controller opening the pause menu
# The issue is caused by the SDL version used by hollow knight not recognizing the dualsense controller and
# mapping buttons properly. It is also not helped by steam input not disabling the native controller support
# when used in hollow knight. The issue cannot be fixed by simple mapping in steam input.
# Disable Steam Input
# Set the following as launch option
SDL_GAMECONTROLLERCONFIG="050000004c050000e60c000000810000,Sony DualSense ,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux," %command%
@jonfk
jonfk / template.sh
Created January 6, 2020 16:55
Default header for bash scripts
#!/bin/bash
# abort on nonzero exitstatus
set -o errexit
# abort on unbound variable
set -o nounset
# don't hide errors within pipes
set -o pipefail
# Print each command for debugging
# set -o xtrace
fn pig_latin_word(word: &str) -> String {
let mut chars_iter = word.chars();
let mut first_last = if let Some(first) = chars_iter.next() {
let mut rest: String = chars_iter.collect();
rest.push(first);
rest
} else {
"".to_owned()
};
@jonfk
jonfk / keybase.md
Created March 12, 2018 21:10
keybase.md

Keybase proof

I hereby claim:

  • I am jonfk on github.
  • I am jonfk (https://keybase.io/jonfk) on keybase.
  • I have a public key ASA_ts-tV6nov6vpEaScVpWVIoZo-5PE4F2EdZxKoeip5wo

To claim this, I am signing this object:

@jonfk
jonfk / websocket_server.rs
Created September 26, 2016 04:28
Trying to link rust-websocket and tokio-core
extern crate websocket;
extern crate tokio_core;
extern crate futures;
use websocket::{Server, Message, Sender, Receiver};
use websocket::message::Type;
use websocket::header::WebSocketProtocol;
use futures::Future;
use futures::stream::Stream;
@jonfk
jonfk / Makefile
Created July 22, 2015 03:49
python c ffi
all:
gcc -shared -Wl,-soname,testlib -o testlib.so -fPIC testlib.c
clean:
rm testlib.so
@jonfk
jonfk / virtualenv.adoc
Last active February 28, 2023 02:22
Python Virtualenv Cheatsheet

Virtualenv Cheatsheet

  1. Create a virtualenv

    $ virtualenv env
  2. Activate

@jonfk
jonfk / git_cheatsheet.adoc
Last active September 19, 2016 18:08
git_cheatsheet

Git Cheatsheet

Table of Contents

Git Branches

  • view all branches including remote

change to postgres user and open psql prompt

sudo -u postgres psql postgres

or

psql -U postgres

list databases