Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Software License Agreement (BSD License)
#
# Copyright (c) 2016, Martin Guenther
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@deepaknverma
deepaknverma / 10 Tips for Optimizing NGINX and PHP-fpm for High Traffic Sites
Created October 20, 2014 01:22
10 Tips for Optimizing NGINX and PHP-fpm for High Traffic Sites
Please take a look at the original article (http://www.softwareprojects.com/resources/programming/t-optimizing-nginx-and-php-fpm-for-high-traffic-sites-2081.html) as it includes excellent configuration file examples.
1. Switch from TCP to UNIX domain sockets:
When communicating to processes on the same machine UNIX sockets have better performance the TCP because there's less copying and fewer context switches.
2. Adjust Worker Processes:
Set the worker_processes in your nginx.conf file to the number of cores your machine has and increase the number of worker_connections.
3. Setup upstream load balancing:
Multiple upstream backends on the same machine produce higher throughout than a single one.
@sindresorhus
sindresorhus / esm-package.md
Last active April 18, 2024 06:02
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@DiGyt
DiGyt / probabilistic_poker_bots_i.ipynb
Last active April 18, 2024 06:01
Probabilistic_Poker_Bots_I.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import socket
import struct
import json
def unpack_varint(s):
d = 0
for i in range(5):
b = ord(s.recv(1))
d |= (b & 0x7F) << 7*i
if not b & 0x80:
@afresh1
afresh1 / openbsd-httpd-fastcgi-notes.md
Created July 12, 2020 21:26
Notes on how OpenBSD's httpd handles its FastCGI parameters. Debugging it with slowcgi.

These examples all live in a default server block in your httpd.conf(5).

server "default" {
	listen on * port 80
	... # all the location blocks can together right here
}

We'll be using slowcgi(8) as the example, because with the -d flag it helpfully spits out the FastCGI environment it got from httpd(8) and what it's planning to do with that.

@jshaw
jshaw / byobuCommands
Last active April 18, 2024 05:59
Byobu Commands
Byobu Commands
==============
byobu Screen manager
Level 0 Commands (Quick Start)
------------------------------
<F2> Create a new window
@perlguy99
perlguy99 / Xcode_Variables.txt
Created July 10, 2017 18:07
Xcode Environment variables
ACTION=build
AD_HOC_CODE_SIGNING_ALLOWED=NO
ALTERNATE_GROUP=staff
ALTERNATE_MODE=u+w,go-w,a+rX
ALTERNATE_OWNER=brent
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES=NO
ALWAYS_SEARCH_USER_PATHS=NO
ALWAYS_USE_SEPARATE_HEADERMAPS=NO
APPLE_INTERNAL_DEVELOPER_DIR=/AppleInternal/Developer
APPLE_INTERNAL_DIR=/AppleInternal
@rahularity
rahularity / work-with-multiple-github-accounts.md
Last active April 18, 2024 05:53
How To Work With Multiple Github Accounts on your PC

How To Work With Multiple Github Accounts on a single Machine

Let suppose I have two github accounts, https://github.com/rahul-office and https://github.com/rahul-personal. Now i want to setup my mac to easily talk to both the github accounts.

NOTE: This logic can be extended to more than two accounts also. :)

The setup can be done in 5 easy steps:

Steps:

  • Step 1 : Create SSH keys for all accounts
  • Step 2 : Add SSH keys to SSH Agent
@fernandoaleman
fernandoaleman / mysql2-m1.md
Last active April 18, 2024 05:53
How to install mysql2 gem on m1 Mac

Problem

Installing mysql2 gem errors on Apple silicon M1, M2 or M3 Mac running macOS Sonoma.

Solution

Make sure mysql-client, openssl and zstd are installed on Mac via Homebrew.

Replace mysql-client with whichever mysql package you are using