Skip to content

Instantly share code, notes, and snippets.

@halferty
halferty / idea.md
Created December 2, 2021 22:52 — forked from motorailgun/idea.md
Installing Windows and Linux into the same partition

Installing Windows and Linux into the same partition

But WHY?

There was a reddit post about installing Arch on NTFS3 partition. Since Windows and Linux doesn't have directories with same names under the /(C:\), I thought it's possible, and turned out it was actually possible.
If you are not familiar to Linux, for example you've searched on Google "how to dualboot Linux and Windos" or brbrbr... you mustn't try this. This is not practical.

Pre-requirements

  • UEFI system
  • Any Linux live-boot CD/DVD/USB... with Linux kernel newer than 5.15
  • Windows installer USB
#include <ncurses.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#define MAX_BRANCH_NAME_LEN 4096
#define MAX_BRANCHES 100
#define COLOR_PAIR_HEADER 1
@halferty
halferty / main.c
Last active July 15, 2022 11:57
init process that draws to framebuffer
#include <errno.h>
#include <fcntl.h>
#include <linux/fb.h>
#include <linux/kd.h>
#include <linux/limits.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#pragma once
#include <iostream>
#include <string>
#include <unordered_map>
std::unordered_map<std::string, std::unordered_map<std::string, std::unordered_map<std::string, std::string>>> synapseConfigs = {
/* FORMAT EXAMPLE:
{ "<game key>", {
{ "<client name 1>", {
@halferty
halferty / killprocs.rb
Created April 10, 2020 19:15
End processes matching string
#!/usr/bin/env ruby
require "io/console"
keywords = ARGV.reject { |arg| arg.length < 4 }
`ps auxww`.split(/\n/)
.reject { |line| line.include?("killify") }
.filter { |line| keywords.any? { |k| line.include?(k) } }
.map { |line| line.split(/\s+/) }
@halferty
halferty / test_fma.scala
Created February 10, 2020 23:38
Test berkeley-hardfloat fused multiply-add
// Test berkeley-hardfloat fused multiply-add
class Stuff(dut: MulAddRecFN2) extends PeekPokeTester(dut) {
val floatToUInt: (Float) => UInt = (f) => f"h${java.lang.Float.floatToIntBits(1.0f)}%08X".U(32.W)
val a = 3.33f
val b = 2.0f
val c = 1.0f
val expected = a * b + c
poke(dut.io.a, floatToUInt(a))
poke(dut.io.b, floatToUInt(b))
poke(dut.io.c, floatToUInt(c))
@halferty
halferty / disassemble-opcode
Created February 10, 2020 23:38
Disassembles a single RISCV opcode in hex string format
#!/usr/bin/env ruby
# opcode = "00162023"
opcode = ARGV[0]
`echo ".text;.word 0x#{opcode}" > ~/tmp/test.S`
`$RISCV/bin/*gcc -c ~/tmp/test.S -o ~/tmp/test.o 2> /dev/null`
res = `$RISCV/bin/*objdump -d ~/tmp/test.o 2> /dev/null`
puts res.split(/\n/).last.split(/\t/)[2..-1].join(" ")
export CLICOLOR=1
source ~/.secretkeys
export PATH="$PATH:$HOME/ruby/bin"
PS1='[[\u@'$(hostname)' \w]] »'
alias docollectstatic="managepy collectstatic"
alias dolint="docker-compose run --rm web ./scripts/lint"
@halferty
halferty / grant_super_admin.php
Last active August 22, 2018 18:14
Wordpress grant super admin
<?php
global $super_admins;
$user1 = get_userdata(get_current_user_id());
$super_admins[] = $user->user_login;
update_site_option('site_admins', $super_admins);
@halferty
halferty / run.sh
Created August 7, 2018 15:49
Compile and Run TypeScript from JS
#!/bin/bash
npm install ts-node
npm install typescript
node test.js