Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@xwiz
xwiz / sysctl.conf
Created February 11, 2023 23:19 — forked from chetth/sysctl.conf
TCP stack tuning for high traffic server.
net.ipv4.ip_forward=0
net.ipv4.tcp_fin_timeout = 60
net.ipv4.tcp_retries1 = 3
net.ipv4.tcp_keepalive_probes = 9
net.ipv4.tcp_keepalive_time = 7200
net.ipv4.tcp_syn_retries = 5
kernel.sem = 250 32000 100 128
kernel.shmall = 209715200
kernel.shmmax = 214748364800
@xwiz
xwiz / setup.sh
Created September 15, 2022 23:16
Setup Laravel 9 + Octane (Swoole) on Alpine box
#install all necessary stuff
wget https://php.hernandev.com/key/php-alpine.rsa.pub -O /etc/apk/keys/php-alpine.rsa.pub
#if you encounter dns errors, replace php.hernandev with 50.116.12.38
apk --update-cache add ca-certificates && \
echo "https://php.hernandev.com/v3.15/php-8.1" >> /etc/apk/repositories
apk add --update-cache php=8.1
@xwiz
xwiz / nginx_pagespeed.sh
Last active September 12, 2021 15:51
Easy install/setup of nginx + pagespeed and basic config settings.
#if nginx already installed consider stopping service first, you can still reserve running this command until the actual build stage
#sudo service nginx stop
#assume you already have git libssl installed, otherwise uncomment
#sudo apt install libssl-dev
#sudo apt install git
cd ~
git clone https://github.com/google/ngx_brotli.git
cd ngx_brotli
git submodule update --init --recursive
@xwiz
xwiz / upgradebionic18.sh
Last active September 12, 2021 15:28
Upgrading Ubuntu 16 (Xenial)
#Make enough swap space if you have less than 2Gb memory
sudo swapoff -a
sudo fallocate -l 6G /swapfile
sudo chmod 0600 /swapfile
sudo mkswap /swapfile
@xwiz
xwiz / gradient_random.php
Last active August 15, 2021 11:33
Random gradient color by weight
/**
* @param mixed $color1 The first hex/rgb array gradient color
* @param mixed $color2 The second hex/rgb array gradient color
* @param mixed $weight Weight of color 1 against color 2. Should be a float between 0 and 1
* @return string A hex color mix of the two gradient colors based on weight
*/
function pick_hex($color1, $color2, $weight) {
$w1 = $weight;
$w2 = 1 - $w1;
if (is_string($color1)) {
@xwiz
xwiz / 0_reuse_code.js
Created August 22, 2014 08:49
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
#!/usr/bin/python
import flac.encoder as encoder
import pyaudio
import sys
import requests
import random
from threading import Thread
from Queue import Queue, Empty
using System;
using System.Collections.Generic;
using System.Web.Mvc;
using System.Web.Security;
using Facebook;
using MyFacebookSite3434.Models;
namespace MyFacebookSite3434.Controllers
{
public class AccountController : Controller
select 'replacewithtablename' into @table;
select 'replacewithdatabasename' into @schema;
select concat('public class ',@table,'{')
union
select concat('public ',tps.dest,' ',column_name,'{get;set;}')
from information_schema.columns c
join (
select 'char' as orign ,'string' as dest union all
<?php
/**
* Grab Images from Wikipedia via thier API
*
* @author http://techslides.com
* @link http://techslides.com/grab-wikipedia-pictures-by-api-with-php
*/
//curl request returns json output via json_decode php function