Skip to content

Instantly share code, notes, and snippets.

@szaydel
szaydel / dummyprog.go
Created September 11, 2015 19:03
Access StdIn of Exec'd process with Golang
package main
import (
"fmt"
)
func main() {
fmt.Println("Hello, What's your favorite number?")
var i int
fmt.Scanf("%d\n", &i)
# pip install hidapi
import hid
import time
# Define the vendor ID and product ID for the PlayStation 1 controller
VENDOR_ID = 0x054C
PRODUCT_ID = 0x05C4
# Define the bit masks for each button
@paulund
paulund / example-wp-list-table.php
Last active May 20, 2024 05:29
An example code of using the WP_List_Table class. With Pagination.
<?php
/*
* Plugin Name: Paulund WP List Table Example
* Description: An example of how to use the WP_List_Table class to display data in your WordPress Admin area
* Plugin URI: http://www.paulund.co.uk
* Author: Paul Underwood
* Author URI: http://www.paulund.co.uk
* Version: 1.0
* License: GPL2
*/
const BUTTONS = {
'TRIANGLE': 0x1000,
'CIRCLE': 0x2000,
'CROSS': 0x4000,
'SQUARE': 0x8000
};
function isButtonPressed(state, button) {
return (state.buttons & button) === 0;
}
@logan2611
logan2611 / DeckforEnthusiasts.md
Last active May 20, 2024 05:25
Deck for Enthusiasts Guide
@pocka
pocka / hand-detection.js
Created May 18, 2018 05:38
OpenCV.js hand detection (for my learning opencv.js)
try {
let src = cv.imread('canvasInput')
let imgHLS = new cv.Mat()
cv.cvtColor(src, imgHLS, cv.COLOR_BGR2HLS)
// 画像の中心点
const cx = Math.floor(src.cols / 2)
const cy = Math.floor(src.rows / 2)
// sudo apt-get install libhidapi-dev
// On macOS: bash brew install hidapi
// Compile: g++ -o ps1_controller ps1_controller.cpp -lhidapi-hidraw
#include <iostream>
#include <hidapi/hidapi.h>
#define VENDOR_ID 0x054C // Replace with your controller's vendor ID
#define PRODUCT_ID 0x05C4 // Replace with your controller's product ID
import hid
# Replace these with your controller's vendor ID and product ID
VENDOR_ID = 0x054C # Example: Sony vendor ID
PRODUCT_ID = 0x05C4 # Example: PlayStation controller product ID
def is_button_pressed(data, button_mask):
# Data is typically an array of bytes. The exact format depends on your device.
# Here, we assume data[5:7] contains the 16-bit button state.
button_state = (data[5] << 8) | data[6]
@ygrenzinger
ygrenzinger / CleanArchitecture.md
Last active May 20, 2024 05:21
Summary of Clean Architecture by Robert C. Martin

Summary of book "Clean Architecture" by Robert C. Martin

Uncle Bob, the well known author of Clean Code, is coming back to us with a new book called Clean Architecture which wants to take a larger view on how to create software.

Even if Clean Code is one of the major book around OOP and code design (mainly by presenting the SOLID principles), I was not totally impressed by the book.

Clean Architecture leaves me with the same feeling, even if it's pushing the development world to do better, has some good stories and present robust principles to build software.

The book is build around 34 chapters organised in chapters.

@wojteklu
wojteklu / clean_code.md
Last active May 20, 2024 05:21
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules