Skip to content

Instantly share code, notes, and snippets.

View zzztttkkk's full-sized avatar
🚀
🥱🥱🥱

ztk zzztttkkk

🚀
🥱🥱🥱
View GitHub Profile
@wllmsash
wllmsash / assigning-static-ip-addresses-in-wsl2.md
Last active June 27, 2024 20:56
Assigning Static IP Addresses in WSL2

Assigning Static IP Addresses in WSL2

WSL2 uses Hyper-V for networking. The WSL2 network settings are ephemeral and configured on demand when any WSL2 instance is first started in a Windows session. The configuration is reset on each Windows restart and the IP addresses change each time. The Windows host creates a hidden switch named "WSL" and a network adapter named "WSL" (appears as "vEthernet (WSL)" in the "Network Connections" panel). The Ubuntu instance creates a corresponding network interface named "eth0".

Assigning static IP addresses to the network interfaces on the Windows host or the WSL2 Ubuntu instance enables support for the following scenarios:

@Qix-
Qix- / coro.cpp
Created September 29, 2020 04:16
C++20 coroutines + LibUV sample, v2
// Thank you to the folks at the C++ slack channel,
// along with @lewissbaker for the excellent literature
// (even though it took me a few days to be convinced
// it really was so).
#include <uv.h>
#include <iostream>
#include <experimental/coroutine>
@elialejandro
elialejandro / AutoinstallMYSQL.sh
Last active July 7, 2020 17:08
MySQL 5.7 No directory, logging in with HOME=/
# Install MySQL
mysql_config_file="/etc/mysql/my.cnf"
echo "mysql-server mysql-server/root_password password secret" | sudo debconf-set-selections
echo "mysql-server mysql-server/root_password_again password secret" | sudo debconf-set-selections
apt-get -y install mysql-client mysql-server
sed -i "s/bind-address\s*=\s*127.0.0.1/bind-address = 0.0.0.0/" ${mysql_config_file}
usermod -d /var/lib/mysql/ mysql
@drm343
drm343 / sdl2_text_input_utf8.c
Created July 15, 2017 06:55
SDL2 處理中文輸入
// Use `gcc sdl2_text_input_utf8.c -lSDL2 -lSDL2_ttf -o test_program`.
//
// You must use CJK font for SDL2_ttf and put the same directory with test_program.
// This example use "NotoSansMonoCJKtc-Regular.otf".
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <SDL2/SDL.h>
@eatonphil
eatonphil / functions.c
Last active May 15, 2024 02:12
Introduction to "Fun" C (using GCC)
/**
* This are a collection of examples for C 201.
* These combine concepts you may or may not be
* familiar with and are especially useful for
* students new to C. There is a lot of really
* cool stuff you can do in C without any cool
* languages.
*
* This is file in particular is an introduction
* to fun function usage in C.
@timtadh
timtadh / upsert.py
Created December 5, 2013 19:14
How to compile an INSERT ... ON DUPLICATE KEY UPDATE with SQL Alchemy with support for a bulk insert.
#!/usr/bin/env python
# Copyright (c) 2012, Tim Henderson
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# - Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
@jamiesun
jamiesun / daemon.py
Created July 12, 2012 10:20
一个python守护进程的例子
#! /usr/bin/env python2.7
#encoding:utf-8
#@description:一个python守护进程的例子
#@tags:python,daemon
import sys
import os
import time
import atexit
from signal import SIGTERM
@nzjrs
nzjrs / Makefile
Created May 25, 2011 07:09
Python ctypes example
all: test libtest.so testmodule
libtest.so: libtest.c
$(CC) -Wall -g -fPIC -shared -o $@ $? -lc
test: test_main.c libtest.o
$(CC) -o $@ $?
testmodule: testmodule.c
python setup.py build
@eligrey
eligrey / object-watch.js
Created April 30, 2010 01:38
object.watch polyfill in ES5
/*
* object.watch polyfill
*
* 2012-04-03
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/