Skip to content

Instantly share code, notes, and snippets.

@mourner
mourner / codility-demo.js
Created January 7, 2012 09:49
Codility demo tests solutions
// 100-score solution for http://codility.com/demo/take-sample-test/
function equi(array) {
var i,
len = array.length,
sum = 0,
leftSum = 0,
rightSum;
for (i = 0; i < len; i++) {
@posemon
posemon / postman_install.sh
Created May 23, 2018 07:58
Postman install Ubuntu 18.04
#!/bin/bash
# Get postman app
wget https://dl.pstmn.io/download/latest/linux64 -O postman.tar.gz
sudo tar -xzf postman.tar.gz -C /opt
sudo ln -s /opt/Postman/Postman /usr/bin/postman
#Create a Desktop Entry
cat > ~/.local/share/applications/postman.desktop <<EOL
[Desktop Entry]
Encoding=UTF-8
@RobThree
RobThree / SoapClientTimeout.class.php
Created April 25, 2012 14:55
PHP SoapClient with timeout
<?php
//Drop-in replacement for PHP's SoapClient class supporting connect and response/transfer timeout
//Usage: Exactly as PHP's SoapClient class, except that 3 new options are available:
// timeout The response/transfer timeout in milliseconds; 0 == default SoapClient / CURL timeout
// connecttimeout The connection timeout; 0 == default SoapClient / CURL timeout
// sslverifypeer FALSE to stop SoapClient from verifying the peer's certificate
class SoapClientTimeout extends SoapClient
{
private $timeout = 0;
private $connecttimeout = 0;
@eliangcs
eliangcs / http-prompt-story.md
Last active June 3, 2020 06:49
How I created HTTP Prompt and got 5000+ stars on GitHub

How I Created HTTP Prompt and Got 5000+ Stars on GitHub

Two months ago, I published an open source project, which went viral by gaining 1200+ stars in the first 24 hours. As of this writing, it has attracted 5000+ stars. The project is called HTTP Prompt:

https://github.com/eliangcs/http-prompt

Here I want to share its development story.

It all began with Vertica. Not long ago, I used Vertica every day for my work. Vertica is a powerful database, but the official client (vsql) is not powerful at all. The GUI alternative, DbVisualizer, is bad as well.

@craigvantonder
craigvantonder / flush-dns.sh
Last active February 3, 2021 04:42
Flushing the DNS in Ubuntu 16.04
#!/bin/bash
# NB: First install nscd with sudo apt-get install nscd
# run this command to flush dns cache:
sudo /etc/init.d/dns-clean restart
# or use:
sudo /etc/init.d/networking force-reload
# Flush nscd dns cache:
sudo /etc/init.d/nscd restart
@esfand
esfand / nginxvarcore.md
Last active May 17, 2021 16:39
Nginx Variables

Embedded Variables

The ngx_http_core_module module supports embedded variables with names matching the Apache Server variables. First of all, these are variables representing client request header fields, such as $http_user_agent, $http_cookie, and so on. Also there are other variables:

  • $arg_name
    argument name in the request line
@hzbd
hzbd / haproxy.config
Created May 4, 2013 17:34
Sample HAProxy config with logging.
global
pidfile /var/run/haproxy.pid
log 127.0.0.1 local0 info
ulimit-n 65536
defaults
mode http
clitimeout 600000 # maximum inactivity time on the client side
srvtimeout 600000 # maximum inactivity time on the server side
@reifman
reifman / default.vcl
Last active September 9, 2021 08:15
Example Varnish VCL Configuration e.g. /etc/varnish/default.vcl
# Default backend definition. Set this to point to your content server.
backend default {
.host = "127.0.0.1";
.port = "8080";
.connect_timeout = 60s;
.first_byte_timeout = 60s;
.between_bytes_timeout = 60s;
.max_connections = 800;
}
@Gazer
Gazer / localhost.conf
Last active October 20, 2021 14:55
Nginx example to redirect users to a "Comming soon portal" if they are not developers.
server {
listen 80;
server_name localhost;
location @until {
# Static "comming soon" directory with index.html and assets
root /var/www/;
index index.html;
}
@thousandlemons
thousandlemons / how-to-setup-shadowsocks-on-your-ubuntu-server.md
Last active November 20, 2021 00:14
How to setup Shadowsocks on your Ubuntu server