Skip to content

Instantly share code, notes, and snippets.

View jonasbits's full-sized avatar

Jonas Anton Östman jonasbits

View GitHub Profile
@jonasbits
jonasbits / csdinfo
Created March 31, 2022 09:36 — forked from sharow/csdinfo
SD card CSD register formatter (for Raspberry Pi)
#!/usr/bin/env python2
# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; coding: utf-8; -*-
# usage:
# $ cat /sys/devices/platform/mmc_host/mmcXXXX/mmcYYYY/csd | csdinfo
#
# reference:
# 'Physical Layer Simplified Specification Version 3.01'
# https://www.sdcard.org/downloads/pls/simplified_specs/Part_1_Physical_Layer_Simplified_Specification_Ver_3.01_Final_100518.pdf
@jonasbits
jonasbits / libserialport example.c
Last active December 17, 2018 12:49 — forked from ntd/libserialport example.c
libserialport example
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <unistd.h> // for sleep function
#include <libserialport.h> // cross platform serial port lib
//#include "protocol.h"
//const char* desired_port = "COM8";
@jonasbits
jonasbits / dualshock-research
Created January 11, 2017 00:09 — forked from johndrinkwater/dualshock-research
I’m interested in writing (or helping to spec out the protocol so someone else can write) the linux kernel driver for Sony’s DualShock 4 (PS4’s lovely controller) Currently using the output of HID RAW from a USB connected dualshock 4… For the gyro/touchpad discovery, I’ve just been using some terrible c code to throw numbers on the screen and it…
TADA, it’s `hexdump -v -e '64/1 "%02x" "\n"' < /dev/hidraw3`
No idea what the first byte is… but I’m going to assume its for device ID for the many users that are connected, but it probably has to be set by the connected machine?
01ff777f7f0800aa0000435dfdf1ff14000200c5ff0721150300000000001b000001fc9133a32990880428008000000080000000008000000080000000008000
↑↑↑↑
left stick, value, first field is horz (00 left), second field is vertical (00 top)
017f80ff61080064000059f2fdfffffbff0e00d107081e9bf600000000001b0000018e94b1b00690880428008000000080000000008000000080000000008000
↑↑↑↑
javascript:var s=document.createElement('script');s.setAttribute('src', 'https://github.com/Khan/tota11y/releases/download/0.1.3/tota11y.min.js');document.getElementsByTagName('body')[0].appendChild(s);void(s);
@jonasbits
jonasbits / Export Notes.AppleScript
Created October 2, 2016 16:44
Export Apple Notes via AppleScript
tell application "TextEdit"
activate
make new document
end tell
tell application "Notes"
if folder "Archive" exists then
set output to ""
repeat with aNote in notes in folder "Archive"
# This file provides a long_running decorator to indicate that a function needs a long amount of time to complete and
# the computer should not enter standby. This file currently only works on Windows and is a no-op on other platforms.
import ctypes
import platform
ES_CONTINUOUS = 0x80000000
ES_SYSTEM_REQUIRED = 0x00000001
@jonasbits
jonasbits / HowToOTGFast.md
Created July 12, 2016 20:43 — forked from gbaman/HowToOTGFast.md
Simple guide for setting up OTG modes on the Raspberry Pi Zero, the fast way!

###Setting up Pi Zero OTG - The quick way (No USB keyboard, mouse, HDMI monitor needed)
More details - http://blog.gbaman.info/?p=791

For this method, alongside your Pi Zero, MicroUSB cable and MicroSD card, only an additional computer is required, which can be running Windows (with Bonjour, iTunes or Quicktime installed), Mac OS or Linux (with Avahi Daemon installed, for example Ubuntu has it built in).
1. Flash Raspbian Jessie full or Raspbian Jessie Lite onto the SD card.
2. Once Raspbian is flashed, open up the boot partition (in Windows Explorer, Finder etc) and add to the bottom of the config.txt file dtoverlay=dwc2 on a new line, then save the file.
3. Finally, open up the cmdline.txt. Be careful with this file, it is very picky with its formatting! Each parameter is seperated by a single

@jonasbits
jonasbits / runtastic-export-all-activities.md
Created June 12, 2016 14:10
Download all activities from Runtastic.com (as .gpx)

Download all activities from Runtastic 🏃

With this script you can download all your activities from www.runtastic.com in .gpx format. Runtastic removed this feature wich makes it very difficult to change your tracking service, thanks for that.

❗ Only tested in Google Chrome 41.0+

How does it work

Login to your runtastic account and go to the page where all your activities are listed. Then open the developer tools of Chrome with CMD + OPTION + I and go to the console tab. Now copy and paste the following script in the console line and press enter. The usually content should disapear and the downloads should start. I used it to export around 290 activities and it worked fine.

@jonasbits
jonasbits / 00-button
Created April 14, 2016 05:24 — forked from jefferyto/00-button
Switching network configurations on a TP-Link TL-MR3020 with OpenWrt (12.09 Attitude Adjustment) using the sliding switch. Based on the sample scripts at: https://forum.openwrt.org/viewtopic.php?pid=172111#p172111 and https://forum.openwrt.org/viewtopic.php?pid=172110#p172110
# based on
# https://dev.openwrt.org/browser/trunk/target/linux/atheros/base-files/etc/hotplug.d/button/00-button
# https://forum.openwrt.org/viewtopic.php?pid=172110#p172110
. /lib/functions.sh
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
do_button () {
local button
@jonasbits
jonasbits / Remove di.se top bar (Greasemonkey)
Created October 31, 2015 11:29 — forked from lmonilsson/Remove di.se top bar (Greasemonkey)
Greasemonkey script for hiding the top frame on di.se
// ==UserScript==
// @name Remove di.se top frame
// @namespace http://www.di.se
// @include http://www.di.se/*
// @noframes
// @version 1
// @grant none
// ==/UserScript==
var frameset = top.document.getElementsByTagName("frameset")[0];