Skip to content

Instantly share code, notes, and snippets.

<?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 / 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 / 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 / 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
<?php
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
/**
* Session sotrage that avoids using _sf2_attributes subkey
* in the $_SESSION superglobal but instead it uses
* the root variable.
*/
class LegacySessionStorage extends NativeSessionStorage
@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 / 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 / base_convert.php
Last active December 28, 2015 00:39
Convert from any base to any base in PHP
<?php
function convertBases($number, $from_digits, $to_digits)
{
$from_digits = str_split($from_digits, 1);
$to_digits = str_split($to_digits, 1);
$number = str_split($number, 1);
$number_dec = "0";
$ord = 0;
@tcz
tcz / hypem.php
Last active July 26, 2016 02:14
Copy Hypem favorites to Spotify
<?php
if ($argc !== 2)
{
die("Usage: php {$argv[0]} hypem_user_name\n\n");
}
$user = $argv[1];
$page = 1;
$all_songs = array();
@tcz
tcz / README.md
Last active December 25, 2015 15:39
Script to monitor directory and execute command when changes

Script to monitor directory and execute command when changes

This script monitors a specific directory for changes and when it detects any, it executes a command. It is very useful when writing unit tests for example because you don't need to switch windows. With a 2 monitor setup it's la leche.

Installation

# on Debian/Ubuntu use apt-get
yum -y install inotify-tools wget
wget https://gist.github.com/tcz/6999795/raw/auto.sh