Skip to content

Instantly share code, notes, and snippets.

View 50n1cd347h9's full-sized avatar

sonicdeath9 50n1cd347h9

  • Japan
View GitHub Profile
@50n1cd347h9
50n1cd347h9 / test.c
Created January 31, 2024 20:58
test
#include <stdio.h>
int main(void)
{
printf("Hello, world!!\n");
return 0;
}
@50n1cd347h9
50n1cd347h9 / disable mac to sleep
Created February 20, 2024 04:49
How to stop a MacBook from sleeping with the lid closed
sudo pmset -a disablesleep 1
@50n1cd347h9
50n1cd347h9 / soinsuu.lsp
Last active April 29, 2024 09:07
素因数分解
(defun bunkai (n)
(let ((limit (floor (sqrt n))))
(labels ((f (n divisor acc)
(if (and (not (= 1 n))
(<= divisor limit))
(if (zerop (mod n divisor))
(f (/ n divisor)
divisor
(cons divisor acc))
(f n
@50n1cd347h9
50n1cd347h9 / waybar_error_resolution.md
Last active June 11, 2024 07:25
Resolving Waybar not starting issue
sudo apt remove xdg-desktop-portal

Resolving Waybar not starting issue

host: Kubuntu 24.04LTS

Encountered an error Error calling StartServiceByName for org.freedesktop.portal.Desktop: Timeout was reached when trying to start Waybar, which prevented it from showing up. Resolved the issue with the following steps:

Solution:

@50n1cd347h9
50n1cd347h9 / spawn_process.zig
Created July 24, 2024 15:44
How to spawn a process
const std = @import("std");
const Child = std.process.Child;
const ArrayList = std.ArrayList;
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
const allocator = gpa.allocator();
defer {
const deinit_status = gpa.deinit();
_ = deinit_status;
const std = @import("std");
const c = std.c;
const fs = std.fs;
const Child = std.process.Child;
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
const allocator = gpa.allocator();
const fd = try fs.cwd().createFile("hoge", .{});
defer {
const std = @import("std");
const debugPrint = std.debug.print;
const Thread = std.Thread;
const Mutex = Thread.Mutex;
fn hoge(m: *Mutex, val: *u32) void {
const ret: u32 = val.* * 2;
{
m.lock();
defer m.unlock();
const std = @import("std");
const c = std.c;
fn ahi(val: ?*anyopaque) callconv(.C) ?*anyopaque {
const p = @as(*u32, @ptrCast(@alignCast(val)));
std.debug.print("val 0x{x}\n", .{p.*});
return p;
}
pub fn main() !void {
const std = @import("std");
const fmt = std.fmt;
const debugPrint = std.debug.print;

pub fn main() !void {
    const src = "hogehgoehgoe";
    const ch = 'A';
    var dst = [_]u8{0} ** 0x20;
$ zig version
0.14.0-dev.1392+37df6ba86
const std = @import("std");
const fmt = std.fmt;
const debugPrint = std.debug.print;