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 August 30, 2025 20:18
PHPUnit Cheat Sheet

PHPUnit API reference

  • version 3.6

TODO

Check those constraints:

$this->anything()
@ziadoz
ziadoz / awesome-php.md
Last active May 8, 2025 07:37
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 March 3, 2026 06:56
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
@josephzidell
josephzidell / route_paths.php
Last active January 3, 2016 17:59
Pathify CakePHP routes
<?php
function root_path() {
return '/';
}
function pathify() {
foreach ( Router::$routes as $route ) {
$parts = [];
if ( isset( $route->defaults['prefix'] ) && !is_null( $route->defaults['prefix'] ) ) {
$parts[] = $route->defaults['prefix'];