Skip to content

Instantly share code, notes, and snippets.

@tcz
tcz / mysqlqps.php
Created February 24, 2014 13:50
Check MySQL queries per second periodically from PHP
<?php
$mysqli = new mysqli("db", "user", "pass", "db");
/* check connection */
if ($mysqli->connect_errno) {
printf("Connect failed: %s\n", $mysqli->connect_error);
exit();
}
@tcz
tcz / nginxrps.php
Created February 24, 2014 13:51
Check request per seconds on Nginx with PHP
<?php
while (true)
{
$query_start = microtime(true);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "http://127.0.0.1/nginx_status");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
@tcz
tcz / guessgame_loop.py
Last active August 29, 2015 14:01
Benedek python practice
import random
import sys
enter = "Please Press Enter To Continue..."
print "Hello! Welcome to a Guessing game!"
print "Please Guess A number between 1 - 100!"
computernum = random.randint(1, 100)
computernum = str(computernum)
guesses = 3
@tcz
tcz / designer.html
Created June 3, 2014 15:47
designer
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../google-map/google-map.html">
<polymer-element name="my-element">
@tcz
tcz / MainActivity.java
Created April 16, 2015 16:55
Android bug OpenGLRenderer﹕ Layer exceeds max. dimensions supported by the GPU
package com.example.gpulayerbug;
import android.app.Activity;
import android.os.Bundle;
import android.transition.Fade;
import android.transition.Transition;
import android.transition.TransitionManager;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
@tcz
tcz / signal_test.c
Created October 31, 2011 19:07
Parent process killing zombies
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <signal.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <stdlib.h>
// Array of childen's PIDs.
pid_t children[10];
@tcz
tcz / gist:1654175
Created January 21, 2012 21:51
Supervisord to init, RHEL
#!/bin/sh
#
# /etc/rc.d/init.d/supervisord
#
# Supervisor is a client/server system that
# allows its users to monitor and control a
# number of processes on UNIX-like operating
# systems.
#
# chkconfig: - 64 36
@tcz
tcz / gist:1746180
Created February 5, 2012 15:50
MySQL backup with innobackupex and s3cmd
#!/bin/bash
INNOBACKUP="/root/percona-xtrabackup/innobackupex"
INNOBACKUP_OPTIONS="--defaults-file=/etc/my.cnf --ibbackup=/root/percona-xtrabackup/mysql-5.5/storage/innobase/xtrabackup/xtrabackup_innodb55 --parallel=4 --user=root --password=XXXXXXX"
BACKUPDIR="/var/sqlbackup/"
S3BUCKET="db_backup"
echo "Removing old local backups"
cd $BACKUPDIR
<?php
class DrinkingGame
{
const TAIL = 'tail';
const DRUNKEST = 'zoltan';
public function __construct(array $names, Coin $coin = null) {
$this->names = array_fill_keys($names, 0);
$this->coin = $coin;
@tcz
tcz / SphinxClient.php
Created July 3, 2012 19:46
PHP API for Sphinx 2.0.4
<?php
//
// $Id: sphinxapi.php 3087 2012-01-30 23:07:35Z shodan $
//
//
// Copyright (c) 2001-2012, Andrew Aksyonoff
// Copyright (c) 2008-2012, Sphinx Technologies Inc