Skip to content

Instantly share code, notes, and snippets.

View jippi's full-sized avatar

Christian Winther jippi

View GitHub Profile
require 'yaml'
require 'active_record'
require 'active_record/connection_adapters/mysql_adapter'
class MysqlRaw
attr_accessor :connection
def initialize
@config = YAML::load(File.open("#{Rails.root}/config/database.yml"))["mysql_#{Rails.env}"]
@connection = ActiveRecord::Base.mysql_connection(@config)
@loonies
loonies / 1_phpunit-api.md
Last active January 19, 2024 07:34
PHPUnit Cheat Sheet

PHPUnit API reference

  • version 3.6

TODO

Check those constraints:

$this->anything()
@ziadoz
ziadoz / awesome-php.md
Last active July 13, 2024 05:29
Awesome PHP — A curated list of amazingly awesome PHP libraries, resources and shiny things.
<?php
function safemode() { // jacked from Syrian Shell
$safe_mode = ini_get("safe_mode");
if (!$safe_mode) {
$safe_mode = 'off';
}
else {
$safe_mode = 'on'; // ...fuck
}
return $safe_mode;
@jippi
jippi / 1_interface.php
Created September 13, 2012 16:02
GearmanD => StatsD class
$GearmanStatus = new GearmanStatus();
$GearmanStatus->setStatsdConfig(array('host' => '127.0.0.1', 'port' => 8125, 'prefix' => 'gearmand', 'rate' => 1));
$GearmanStatus->setGearmanConfig(array('host' => '127.0.0.1', 'port' => 4730));
$GearmanStatus->setDebug(true || false);
$GearmanStatus->reset();
$GearmanStatus->getCounters();
$GearmanStatus->getStatus();
$GearmanStatus->getWorkers();
$GearmanStatus->getRawStatus();
$GearmanStatus->transmitCountersToStatsD();
@jalaziz
jalaziz / graphite.nginx
Created October 12, 2012 03:24
uWSGI and nginx configuration for Graphite (assumes /opt/graphite/conf/graphite.wsgi.example has been renamed to /opt/graphite/conf/wsgi.py)
server {
listen 8080 default_server deferred;
charset utf-8;
access_log /var/log/nginx/graphite.access.log;
error_log /var/log/nginx/graphite.error.log;
root /opt/graphite/webapp;
location /static/admin/ {
@codepunkt
codepunkt / rm-corrupt.sh
Created November 19, 2012 16:48
find/delete corrupt whisper-files
#!/bin/bash
options=('find' 'delete')
PS3='state your wish: '
echo -e "\nfind/delete corrupt whisper-files"
select opt in "${options[@]}"; do
case $REPLY in
[12] ) option=$opt; break;;
* ) exit;;
@petehamilton
petehamilton / metric_apps.md
Last active May 22, 2017 19:14
Useful Metric Dashboard Research Links

Dashboards

Charting

@plentz
plentz / nginx.conf
Last active July 25, 2024 09:38
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@hgfischer
hgfischer / benchmark+go+nginx.md
Last active April 11, 2024 22:09
Benchmarking Nginx with Go

Benchmarking Nginx with Go

There are a lot of ways to serve a Go HTTP application. The best choices depend on each use case. Currently nginx looks to be the standard web server for every new project even though there are other great web servers as well. However, how much is the overhead of serving a Go application behind an nginx server? Do we need some nginx features (vhosts, load balancing, cache, etc) or can you serve directly from Go? If you need nginx, what is the fastest connection mechanism? This are the kind of questions I'm intended to answer here. The purpose of this benchmark is not to tell that Go is faster or slower than nginx. That would be stupid.

So, these are the different settings we are going to compare:

  • Go HTTP standalone (as the control group)
  • Nginx proxy to Go HTTP
  • Nginx fastcgi to Go TCP FastCGI
  • Nginx fastcgi to Go Unix Socket FastCGI