Skip to content

Instantly share code, notes, and snippets.

@hasherezade
hasherezade / main.cpp
Created July 17, 2021 16:35
A native way to enumerate processes (alternative to: EnumProcesses, CreateToolhelp32Snapshot - Process32First - Process32Next)
#include <windows.h>
#include <iostream>
#include "ntddk.h"
bool enum_processes()
{
ULONG retLen = 0;
// check length:
@cbuckowitz
cbuckowitz / README.md
Last active January 21, 2024 21:17
Change Storage Location for Docker Desktop with WSL2 #DockerDesktop #WSL2

Change the Storage Location for Docker Desktop with WSL2

Docker Desktop stores docker data in 2 distros

  • docker-desktop
  • docker-desktop-data

These distros are installed on the system drive by default.

To move them to another drive, these distros can be exported, deleted and imported from the new location.

#define _GNU_SOURCE
#include <errno.h>
#include <sched.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
@cb372
cb372 / riscv.md
Last active March 9, 2024 22:38
Writing an OS in Rust to run on RISC-V

(This is a translation of the original article in Japanese by moratorium08.)

(UPDATE (22/3/2019): Added some corrections provided by the original author.)

Writing your own OS to run on a handmade CPU is a pretty ambitious project, but I've managed to get it working pretty well so I'm going to write some notes about how I did it.

#VIM

kntrl + o //open command line in vim

:colorschema =>press tab and select something
:syntax enable

:set number => show line number

if you want new schema

@zchee
zchee / cgo.md
Last active February 20, 2024 01:42
cgo convert list

See also, http://libraryofalexandria.io/cgo/

Using Go cgo

cgo has a lot of trap.
but Not "C" pkg also directory in $GOROOT/src. IDE's(vim) Goto command not works.

So, Here collect materials.

@co3moz
co3moz / check.js
Last active March 24, 2016 14:48
Small size object type checker for js
var check = function(o) {
return (o == null) ? null : o.constructor == Function ? o.name == "" ? "Callback" : "Class_" + o.name : o.constructor.name;
};
// how can be different check and typeof
// checkfor check result typeof result
check(null); //null "object"
check(undefined); //null "undefined"
check(1); //"Number" "number"
check([]); //"Array" "object"
@mildred
mildred / howto_nat_traversal.md
Last active December 9, 2023 06:59
How To TCP NAT Traversal using Node.js and a STUN Server

How To TCP NAT Traversal using Node.js and a STUN Server

With the scarecity of IPv4 addresses, and IPv6 still not available at large, NAT traversal is becoming a necessity. Especially with the generalisation of Carrier-grade NATs that you can find on mobile connections. Even with IPv6 you may suffer NAT66. Imagine your mobile device that gets only a single Ipv6 address, and you want to share it on your computer.

The solution might be in a decentralized protocol for address attribution such

@aras-p
aras-p / preprocessor_fun.h
Last active February 28, 2024 08:38
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
require 'rubygems'
require 'net/ssh'
# Run this on the machine (node) which needs to tunnel out to forward the UI to the remote system (console)
Net::SSH.start("remote_host", "remote_user") do |ssh|
# since we are running sinatra locally we will forward 43210 on the remote_host to our localhost 4567
# This is effectively the same as:
# ssh -R 4567:localhost:43210 remote_user@remote_host
ssh.forward.remote(4567, "localhost", 43210)
ssh.loop { true }