Skip to content

Instantly share code, notes, and snippets.

@sharow
sharow / csdinfo
Last active February 6, 2024 15:40
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
@sharow
sharow / monitoroff.py
Last active February 24, 2023 04:13
win: sleep monitor immediately
# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; coding: utf-8; -*-
from ctypes import *
user32 = WinDLL('User32')
DISPLAY_ON = -1
DISPLAY_OFF = 2
HWND_BROADCAST = 0xffff
WM_SYSCOMMAND = 0x0112
SC_MONITORPOWER = 0xf170
@sharow
sharow / loader.lua
Last active July 1, 2018 18:23
lua: module reloader
-- -*- Mode: lua; tab-width: 2; lua-indent-level: 2; indent-tabs-mode: nil; -*-
local loader = {}
local package = require "package"
loader.last_err = false
loader.last_err_msg = nil
function loader.load(module)
return require(module)
@sharow
sharow / rust_bmfont.rs
Created October 11, 2017 13:40
Rust code fragment. load BMFont xml geometries.
extern crate xml;
use std::path::Path;
use std::fs::File;
use xml::reader::EventReader;
use xml::reader::events::*;
#[derive(Clone)]
struct GlyphGeometry {
pub rect: Rect,
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sharow
sharow / linear_regression.ipynb
Last active May 23, 2016 04:28
Machine Learning by Andrew Ng: II. Linear Regression with One Variable (Week 1)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sharow
sharow / isarchival.py
Created February 21, 2016 12:45
windows::FILE_ATTRIBUTE_ARCHIVE scanner
#!/usr/bin/env python
# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; coding: utf-8; -*-
import sys
import ctypes
from pathlib import Path
from contextlib import suppress
# https://msdn.microsoft.com/ja-jp/library/windows/desktop/gg258117%28v=vs.85%29.aspx
@sharow
sharow / 81-C# Script-NewBehaviourScript.cs
Created November 27, 2013 14:23
for Unity\Editor\Data\Resources\ScriptTemplates\
using UnityEngine;
//using UnityEditor;
using System.Collections;
using System.Collections.Generic;
//[ExecuteInEditMode]
//[AddComponentMenu("Transform/Foo")]
//[RequireComponent(typeof(Foo))]
//[System.Serializable]