Skip to content

Instantly share code, notes, and snippets.

@jehoshua02
jehoshua02 / color_code.php
Created October 27, 2011 20:57
Disecting the product color attribute to get the color code
<?php
$string = 'Black-BLK';
$separator = '-';
// here's what I got!
$code = implode($separator, array_slice(explode($separator, $string), 1));
@jehoshua02
jehoshua02 / README.md
Created November 12, 2011 16:02
feels good to get it right...
@jehoshua02
jehoshua02 / indefero_php_fatal.txt
Created November 13, 2011 02:48
Indefero installation problem...
gitadmin@GITSRV:/home/www/indefero/src$ sudo php $INSTALL/pluf/src/migrate.php --conf=IDF/conf/idf.php -a -i -d -u
PHP include path: .:/usr/share/php:/usr/share/pear:/home/www/pluf/src
Install all the apps
Pluf_Migrations_Install_setup
IDF_Migrations_Install_setup
gitadmin@GITSRV:/home/www/indefero/src$ sudo php $INSTALL/pluf/src/migrate.php --conf=IDF/conf/idf.php -a -i -d
PHP include path: .:/usr/share/php:/usr/share/pear:/home/www/pluf/src
Install all the apps
Pluf_Migrations_Install_setup
PHP Fatal error: Uncaught exception 'Exception' with message '1 - Can't create/write to file '/var/lib/mysql/indefero/flexcis_schema_info.MYI' (Errcode: 2) - CREATE TABLE `flexcis_schema_info` (
@jehoshua02
jehoshua02 / _error_cp
Created November 13, 2011 07:35
mount onto existing mysql datadir...
root@GITSRV:/home/gitadmin# cp -Rp /tmp/mysql_data/ /var/lib/mysql/
cp: cannot create directory `/var/lib/mysql/mysql_data': Protocol error
@jehoshua02
jehoshua02 / app_url.php
Created November 27, 2011 02:22
determining the app url
<?php
function app_url()
{
$protocol = (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') ? 'https' : 'http';
$host = $_SERVER['HTTP_HOST'];
$path = str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
$url = $protocol . '://' . $host . $path;
return $url;
}
@jehoshua02
jehoshua02 / redmine_dependencies.md
Created December 1, 2011 07:17
Installing redmine dependencies

In #ruby IRC, ryanf, who likes penguins (according to shevy), recommended using rvm to install all the ruby junk. Taking care of rvm prerequisites, rvm installation is like so:

apt-get install curl git-core subversion
bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )

According to Redmine's tedious compatibility requirements, for Redmine 1.2.x install a) Ruby 1.8.7, b) Rails 2.3.11, c) RubyGems 1.5.3 (recommended by ryanf), d) Rack 1.1.1, e) Rake 0.8.7, f) I18n 0.4.2, g) MySQL C bindins for Ruby:

# install ruby 1.8.7
rvm install 1.8.7

switch gems to the version desired

@jehoshua02
jehoshua02 / chmod_opt_gitosis.md
Created December 3, 2011 13:19
Ubuntu 10.04 LTS setfacl problems

Ka-ching

Redmine needs x-powers on /opt/gitosis:

projectadmin@projectsrv:~$ sudo chmod 777 /opt/gitosis/
projectadmin@projectsrv:~$ sudo -u redmine cat ~redmine/apps/redmine/vendor/plugins/redmine-gitosis/extra/ssh/private_key
-----BEGIN DSA PRIVATE KEY-----
...
-----END DSA PRIVATE KEY-----
@jehoshua02
jehoshua02 / redmine_gantt_png_error.md
Created December 6, 2011 00:10
Redmine Gantt PNG error...

Redmine Gantt PNG Error

When I go to https://mydomain.com/projects/myproject/issues/gantt.png?month=12&months=2&year=2011&zoom=2, I get see the following:

Internal error

An error occurred on the page you were trying to access.
If you continue to experience problems please contact your Redmine administrator for assistance.

If you are the Redmine administrator, check your log files for details about the error.

@jehoshua02
jehoshua02 / monkey_paste.php
Created December 9, 2011 11:28
Just monkeying around...
<?php
// this is an example paste
class Monkey {
public $banana;
private $hp;
private $tummy;
@jehoshua02
jehoshua02 / build_insert.php
Created December 19, 2011 11:24
I know PHP. I know SQL. But I'd rather write a function in PHP to write SQL and put it in my Database class.
public function build_insert($fields_count, $values_count)
{
$indent = str_repeat(' ', 2);
$ph = '?';
$ph_tick = "`{$ph}`";
$ph_table = $ph_tick;
$ph_field = $ph_tick;
$ph_fields = implode(",\n{$indent}", array_fill(0, $fields_count, $ph_field));