Skip to content

Instantly share code, notes, and snippets.

View demitas1's full-sized avatar

DEMI demitas1

View GitHub Profile
@demitas1
demitas1 / find_raspberry_pi.sh
Created February 9, 2024 11:09
Find Raspberry Pi
#!/bin/bash
# ifconfigの出力から接続可能なインターフェースを取得する関数
get_available_interfaces() {
ifconfig -a | awk '/^[a-zA-Z0-9]/ {gsub(":$", "", $1); print $1}'
}
# 使用可能なインターフェースを取得
available_interfaces=$(get_available_interfaces)
@demitas1
demitas1 / generate_keytop.sh
Created November 12, 2023 10:49
Generate keyboard top texture by ImageMagick
#!/bin/bash
if [ "$#" -ne 3 ]; then
echo "Usage: $0 <character_top> <character_buttom> <output_filename>"
exit 1
fi
character_top="$1"
character_bottom="$2"
output_filename="$3"
@demitas1
demitas1 / LycheeSlicer.desktop
Created November 6, 2023 13:37
Ubuntu desktop link example
#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=/home/demitas/Downloads/lychee-slicer/LycheeSlicer-5.4.0.appimage
Name=Lychee Slicer
Icon=/home/demitas/Downloads/lychee-slicer/Logo_lychee.png
@demitas1
demitas1 / helloworld.cpp
Created September 24, 2023 09:36
Lua from C++
#include <iostream>
#include <string>
#include <cstring>
extern "C" {
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
}
@demitas1
demitas1 / mainwindow.cpp
Created September 5, 2023 02:36
Qt dock widget
// very basic code to make docking widget
#include "mainwindow.h"
#include "./ui_mainwindow.h"
#include "dockform1.h" // custom DockForm1 class made by Qt Creator (with a set of ui/h/cpp)
#include <QDockWidget>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
@demitas1
demitas1 / y.js
Created November 6, 2022 00:29
yargs simple example
// yargs simple example
const argv = require('yargs/yargs')(process.argv.slice(2))
.scriptName("parse_something")
.usage('$0 <filename> [options]')
.options({
'verbose': {
describe: 'Verbose output',
type: 'boolean'
}
@demitas1
demitas1 / open2ch_table.js
Last active October 20, 2022 22:33
open2ch !table command to compress pixel art
const Jimp = require('jimp');
const LZString = require('lz-string');
function toHex(i, len, upperCase) {
let strHex = i.toString(16);
if (upperCase) {
strHex = strHex.toUpperCase();
}
@demitas1
demitas1 / jimp_example.js
Created October 19, 2022 12:43
Jimp example with async/await
const Jimp = require('jimp');
const main = async () => {
let img = await Jimp.read('lenna.png');
img = img.resize(256, 256) // resize
.quality(60) // set JPEG quality
.greyscale() // set greyscale
.write('lenna-small-bw.jpg');
};
main();
@demitas1
demitas1 / hex_dump.js
Last active October 19, 2022 11:11
Hexadecimal dump of binary file
const fs = require('fs');
function toHex(i, len) {
let strHex = i.toString(16);
while (strHex.length < len) {
strHex = '0' + strHex;
}
return strHex;
}
@demitas1
demitas1 / movie2gif.sh
Created September 29, 2022 01:18
use ffmepg to make gif from movie files (*.mp4 etc)
#!/bin/bash
echo $1
in_file=$1
ffmpeg -i $in_file -r 12 -vf scale=640:-1 ${in_file%.*}.gif