Skip to content

Instantly share code, notes, and snippets.

@calvin2021y
calvin2021y / centos_nspawn.md
Created June 14, 2021 06:16 — forked from bhouse/centos_nspawn.md
Centos 7.2.1511 via systemd-nspawn

Make a directory to install CentOS 7.2.1511 in

[root@localhost ~]# mkdir /centos_chroot

Make a directory for the rpm database

[root@localhost ~]# mkdir -p /centos_chroot/var/lib/rpm

Create the RPM database

@calvin2021y
calvin2021y / _xcode.sh
Created July 3, 2021 05:47 — forked from dcondrey/_xcode.sh
(macOS Big Sur) Install Xcode from terminal, setup local development with Apache and PHP 8, and other configurations
# Install Command-line tools as dependency for Homebrew
xcode-select --install # Sets the development directory path to /Library/Developer/CommandLineTools
# Install Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install Mas (command-line interface for Mac App Store)
brew install mas
# Search for Xcode showing only the first 5 results
mas search xcode | head -5

How to Download iOS Simulator (Xcode) in Command Line and Install it

For faster connection speed and more flexibility.

Steps

  1. Start Xcode in command line by running this in commandline /Applications/Xcode.app/Contents/MacOS/Xcode
  2. Start downloading of the simulator
  3. Cancel it. YES CANCEL IT!
  4. You will get a message like this:
@calvin2021y
calvin2021y / signapk.sh
Created August 30, 2021 10:06 — forked from TommyLau/signapk.sh
Android sign apk
#!/bin/bash
# Sample usage is as follows;
# ./signapk myapp.apk debug.keystore android androiddebugkey
#
# param1, APK file: Calculator_debug.apk
# param2, keystore location: ~/.android/debug.keystore
# param3, key storepass: android
# param4, key alias: androiddebugkey
USER_HOME=$(eval echo ~${SUDO_USER})
@calvin2021y
calvin2021y / kvm-gpu-passthrough-on-debian-buster.md
Created October 6, 2021 06:34
Setting up KVM with GPU passthrough in Debian Buster

Here's how to set up a Windows 10 virtual machine in KVM with PCI passthrough. The VM will have access to an NVIDIA graphics card while the host machine (running Debian Buster) uses Intel integrated graphics. This is mostly for my own reference so I don't forget how I did it.

Hardware

  • Intel i5 (an old one) with integrated graphics: this will be used as the graphics card for the host machine running Debian Buster
  • NVIDIA Geforce 1070: this will be used as the graphics card for the Windows 10 VM

Step 1: Enable IOMMU

In order to do hardware passthrough with KVM at all, you need to enable the Intel Vt-d virtualization extensions. Edit /etc/default/grub and edit the GRUB_CMDLINE_LINUX_DEFAULT line so that it reads like:

@calvin2021y
calvin2021y / inthash.c
Created November 25, 2021 09:39 — forked from lh3/inthash.c
Invertible integer hash functions
/*
For any 1<k<=64, let mask=(1<<k)-1. hash_64() is a bijection on [0,1<<k), which means
hash_64(x, mask)==hash_64(y, mask) if and only if x==y. hash_64i() is the inversion of
hash_64(): hash_64i(hash_64(x, mask), mask) == hash_64(hash_64i(x, mask), mask) == x.
*/
// Thomas Wang's integer hash functions. See <https://gist.github.com/lh3/59882d6b96166dfc3d8d> for a snapshot.
uint64_t hash_64(uint64_t key, uint64_t mask)
{
key = (~key + (key << 21)) & mask; // key = (key << 21) - key - 1;
@calvin2021y
calvin2021y / network-tuning.conf
Created December 9, 2021 10:23 — forked from pensierinmusica/network-tuning.conf
Linux sysctl configuration file for NginX
## Place this file in "/etc/sysctl.d/network-tuning.conf" and
## run "sysctl -p" to have the kernel pick the new settings up
# Avoid a smurf attack
net.ipv4.icmp_echo_ignore_broadcasts = 1
# Turn on protection for bad icmp error messages
net.ipv4.icmp_ignore_bogus_error_responses = 1
# Turn on syncookies for SYN flood attack protection
@calvin2021y
calvin2021y / db_backup_commands.md
Created December 31, 2021 05:55 — forked from AtulKsol/db_backup_commands.md
Commands to backup & restore database
  1. pg_dump is a nifty utility designed to output a series of SQL statements that describes the schema and data of your database. You can control what goes into your backup by using additional flags.
    Backup: pg_dump -h localhost -p 5432 -U postgres -d mydb > backup.sql

    Restore: psql -h localhost -p 5432 -U postgres -d mydb < backup.sql

    -h is for host.
    -p is for port.
    -U is for username.
    -d is for database.

@calvin2021y
calvin2021y / README-Template.md
Created February 26, 2022 15:06 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

Emscripten as a linker for Zig and C

This shows how to build a nontrivial program using Zig+Emscripten or C+Emscripten. In both cases Emscripten is only used as a linker, that is the frontend is either zig or clang.

"Nontrivial" here means the program uses interesting Emscripten features:

  • Asyncify
  • Full GLES3 support
  • GLFW3 support