Skip to content

Instantly share code, notes, and snippets.

View cuiwm's full-sized avatar
🎯
Focusing

cuiwm cuiwm

🎯
Focusing
  • UK
View GitHub Profile

Enable macOS Server Performance Mode

Performance mode changes the system parameters of your Mac. These changes take better advantage of your hardware for demanding server applications.

A Mac with macOS Server that needs to run high-performance services can turn on performance mode to dedicate additional system resources for server applications. Note, however, that performance mode can be enabled even without macOS Server being installed to achieve similar benifits for other high-performance services.

sudo nvram boot-args="serverperfmode=1 $(nvram boot-args 2>/dev/null | cut -f 2-)"
sudo reboot

Reference: https://support.apple.com/en-us/HT202528.

@cuiwm
cuiwm / gist:d33acbfaeddf89e117fd12662771f0e5
Created November 30, 2019 14:24 — forked from jovimon/gist:524e116471f249626fd2ccd141f3fe05
compile realtek network driver for pfsense 2.4.x

How to compile and install latest realtek network driver in pfSense 2.4.x (FreeBSD 11.1)

  1. Download FreeBSD 11.1 VMDK and create a VM with it as HDD.

  2. Get FreeBSD source tree for your exact FreeBSD version and uncompress it to /usr/src:

    fetch -o /tmp ftp://ftp.freebsd.org/pub/`uname -s`/releases/`uname -m`/`uname -r | cut -d'-' -f1,2`/src.txz
    tar -C / -xvf /tmp/src.txz
    
  3. Download latest Realtek network driver (you need to input an email address).

# basic pfctl control
# ==
# Related: http://www.OpenBSD.org
# Last update: Tue Dec 28, 2004
# ==
# Note:
# this document is only provided as a basic overview
# for some common pfctl commands and is by no means
# a replacement for the pfctl and pf manual pages.
@cuiwm
cuiwm / stdlib_h_file_not_found.sh
Created October 18, 2019 10:33
fix:fatal error: 'stdlib.h' file not found
#!/bin/bash
echo "diagnose tool for problem: \"fatal error: 'stdlib.h' file not found\""
echo "by AndrewChoe(xgod@163.com)"
# reason:
# System header dir /usr/include has gone forever.
# However, some software may fail to build correctly against the SDK and require macOS headers to be installed in the base system under /usr/include
cat >/tmp/hello.c <<-"EOF"
#include <stdlib.h>
int main() {
@cuiwm
cuiwm / test_mmap_ios.m
Created October 12, 2019 02:55 — forked from piaoger/test_mmap_ios.m
mmap on ios
// It's tested on ios 8.2 ..
// Apple document about virtual memory:
// Both OS X and iOS include a fully-integrated virtual memory system that you cannot turn off; it is always on.
// https://developer.apple.com/library/mac/documentation/Performance/Conceptual/ManagingMemory/Articles/AboutMemory.html
// Discussing mmap on ios:
// http://stackoverflow.com/questions/13425558/why-does-mmap-fail-on-ios
// http://stackoverflow.com/questions/9184773/is-there-a-practical-limit-on-the-number-of-memory-mapped-files-in-ios
#include <sys/mman.h>
@cuiwm
cuiwm / nginx.conf
Created April 4, 2019 09:44 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@cuiwm
cuiwm / tcp_timeout.go
Created March 22, 2019 07:44 — forked from hongster/tcp_timeout.go
Golang example on handling TCP connection and setting timeout.
package main
import (
"fmt"
"net"
"time"
"bufio"
)
func handleConnection(conn net.Conn) {
@cuiwm
cuiwm / hnl.mobileConsole.js
Created January 30, 2019 12:20 — forked from c-kick/hnl.mobileConsole.js
hnl.mobileConsole.js - extends JavaScript's console to display a visual console inside the webpage. Very usefull for debugging JS on mobile devices with no real console. Info and demo: http://www.hnldesign.nl/work/code/mobileconsole-javascript-console-for-mobile-devices/
/*!
* hnl.mobileConsole - javascript mobile console - v1.3.4 - 6/9/2018
* Adds html console to webpage. Especially useful for debugging JS on mobile devices.
* Supports 'log', 'trace', 'info', 'warn', 'error', 'group', 'groupEnd', 'table', 'assert', 'clear'
* Inspired by code by jakub fiala (https://gist.github.com/jakubfiala/8fe3461ab6508f46003d)
* Licensed under the MIT license
*
* Original author: @hnldesign
* Further changes, comments: @hnldesign
* Copyright (c) 2014-2016 HN Leussink
@cuiwm
cuiwm / tiny_uploader.js
Last active January 29, 2019 10:36 — forked from alediaferia/tiny_uploader.js
A tiny snippet for reading files chunk by chunk in plain JavaScript
/*
* Valid options are:
* - chunk_read_callback: a function that accepts the read chunk
as its only argument. If binary option
is set to true, this function will receive
an instance of ArrayBuffer, otherwise a String
* - error_callback: an optional function that accepts an object of type
FileReader.error
* - success: an optional function invoked as soon as the whole file has been
read successfully
to check if the server works - https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice
stun:
stun.l.google.com:19302,
stun1.l.google.com:19302,
stun2.l.google.com:19302,
stun3.l.google.com:19302,
stun4.l.google.com:19302,
stun.ekiga.net,
stun.ideasip.com,