Skip to content

Instantly share code, notes, and snippets.

@lmcro
lmcro / wp-increase-timeout.php
Created January 19, 2024 09:54 — forked from sudar/wp-increase-timeout.php
Increase the curl timeout in WordPress
<?php
Copied from http://fatlabmusic.com/blog/2009/08/12/how-to-fix-wp-http-error-name-lookup-timed-out/
//adjustments to wp-includes/http.php timeout values to workaround slow server responses
add_filter('http_request_args', 'bal_http_request_args', 100, 1);
function bal_http_request_args($r) //called on line 237
{
$r['timeout'] = 15;
return $r;
}
@lmcro
lmcro / cmd.sh
Created February 6, 2019 22:12 — forked from kelvinn/cmd.sh
Example of using Apache Bench (ab) to POST JSON to an API
# post_loc.txt contains the json you want to post
# -p means to POST it
# -H adds an Auth header (could be Basic or Token)
# -T sets the Content-Type
# -c is concurrent clients
# -n is the number of requests to run in the test
ab -p post_loc.txt -T application/json -H 'Authorization: Token abcd1234' -c 10 -n 2000 http://example.com/api/v1/locations/
@lmcro
lmcro / purge-cloudstack.sh
Created June 9, 2016 13:08 — forked from CrackerJackMack/purge-cloudstack.sh
PEW PEW reset cloudstack as a fresh install
/etc/init.d/cloud-management stop
mysql -ppassword -e 'drop database cloud'
mysql -ppassword -e 'drop database cloud_usage'
cloud-setup-databases cloud:password@localhost --deploy-as=root:password
rm -rf /var/log/cloud/management/*
cloud-setup-management
/etc/init.d/cloud-management start
#!/bin/bash
# define the name or IP address of the machine that will receive the files
HOST=foo
# define the user you are running as on both machines
USER=bar
# define a link to tmpfs where there is plenty of RAM free
# by default /tmp is mounted with 1/2 physical memory and this test as written below
@lmcro
lmcro / install-asterisk-32.sh
Created March 27, 2016 16:45 — forked from andrius/install-asterisk-32.sh
Install Asterisk with OPUS support on top of FreePBX distro (CentOS 6.5 32-bit!!! + FreePBX 2.1.1)
amportal stop
yum -y update
yum -y groupinstall core && yum install -y tmux patch screen gcc gcc-c++ lynx bison mysql-devel mysql-server sqlite-devel sqlite libsqlite3x-devel php php-mysql php-pear php-mbstring tftp-server httpd make ncurses-devel libtermcap-devel sendmail sendmail-cf caching-nameserver sox newt-devel libxml2-devel libtiff-devel audiofile-devel gtk2-devel subversion kernel-devel git subversion kernel-devel php-process crontabs cronie cronie-anacron wget odbc-devel unixODBC unixODBC-devel mysql-connector-odbc libtool libtool-ltdl libtool-ltdl-devel libcurl-devel libogg-devel libvorbis-devel speex-devel freetds-devel net-snmp-devel corosynclib-devel popt-devel lua-devel portaudio-devel libresample-devel neon-devel libical-devel openldap-devel gmime22-devel sqlite2-devel libedit-devel libuuid-devel openssl-devel doxygen kernel-headers-`uname -r` kernel-devel-`uname -r` glibc-headers
cp -R /etc/asterisk /etc/asterisk-backup
yum remove asterisk11*
# yum install libsrtp-devel
cd /usr/src
@lmcro
lmcro / install-asterisk-64.sh
Created March 27, 2016 16:45 — forked from andrius/install-asterisk-64.sh
Install Asterisk with OPUS support on top of FreePBX distro (CentOS 6.5 64-bit!!! + FreePBX 2.1.1)
amportal stop
# install epel repo
yum instll iksemel-devel srtp-devel libsrtp-devel spandsp-devel
yum -y update
yum -y groupinstall core && yum install -y tmux patch screen gcc gcc-c++ lynx bison mysql-devel sqlite-devel sqlite libsqlite3x-devel php php-mysql php-pear php-mbstring tftp-server httpd make ncurses-devel libtermcap-devel sendmail sendmail-cf caching-nameserver sox newt-devel libxml2-devel libtiff-devel audiofile-devel gtk2-devel subversion kernel-devel git subversion kernel-devel php-process crontabs cronie cronie-anacron wget odbc-devel unixODBC unixODBC-devel mysql-connector-odbc libtool libtool-ltdl libtool-ltdl-devel libcurl-devel libogg-devel libvorbis-devel speex-devel freetds-devel net-snmp-devel corosynclib-devel popt-devel lua-devel portaudio-devel libresample-devel neon-devel libical-devel openldap-devel gmime22-devel sqlite2-devel libedit-devel libuuid-devel openssl-devel doxygen kernel-headers-`uname -r` kernel-devel-`uname -r` glibc-headers
cp -R /etc/asterisk /etc/asterisk-backu
@lmcro
lmcro / nginx.conf
Created February 28, 2016 12:49 — 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
@lmcro
lmcro / fixperms.sh
Created February 2, 2016 11:50 — forked from webspectyler/fixperms.sh
Fix permissions in cPanel when getting 500 errors and Forbidden 403 errors
#! /bin/bash
#
# Date: Jan 26th 2012
# Author: Colin R.
# Revisions: Jacob "Boom Shadow" Tirey (boomshadow.net)
# Fixperms script for ServInt
#
# Fixperms script for cPanel servers running suPHP or FastCGI.
# Written for ServInt.net
# Copyright (C) 2012 Colin R.
@lmcro
lmcro / url_slug.js
Created November 9, 2015 20:43 — forked from sgmurphy/url_slug.js
URL Slugs in Javascript (with UTF-8 and Transliteration Support)
/**
* Create a web friendly URL slug from a string.
*
* Requires XRegExp (http://xregexp.com) with unicode add-ons for UTF-8 support.
*
* Although supported, transliteration is discouraged because
* 1) most web browsers support UTF-8 characters in URLs
* 2) transliteration causes a loss of information
*
* @author Sean Murphy <[email protected]>
@lmcro
lmcro / url_slug.php
Created November 9, 2015 20:07 — forked from sgmurphy/url_slug.php
URL Slugs in PHP (with UTF-8 and Transliteration Support)
<?php
/**
* Create a web friendly URL slug from a string.
*
* Although supported, transliteration is discouraged because
* 1) most web browsers support UTF-8 characters in URLs
* 2) transliteration causes a loss of information
*
* @author Sean Murphy <[email protected]>
* @copyright Copyright 2012 Sean Murphy. All rights reserved.