Skip to content

Instantly share code, notes, and snippets.

@p
p / hai.rb
Created December 15, 2015 02:18
Rails 64 bit primary key fix for sqlite
# force load
ActiveRecord::Type::Integer
class ActiveRecord::Type::Integer
def initialize_with_pk_length_fix(options={})
#options = {limit: 8}.update(options)
# apparently we are receiving limit: nil in options, override hard
options = options.merge(limit: 8)
initialize_without_pk_length_fix(options)
end
@p
p / 1 launch command
Created December 8, 2012 01:24
Integrity via Unicorn
exec unicorn -c doc/unicorn.rb -D
@p
p / kill-user.php
Created December 7, 2012 08:27
phpbb kill user script
#!/usr/bin/env php
<?php
if ($_SERVER['argc'] != 2) {
echo "Usage: kill-user user-id\n";
exit(2);
}
require(dirname(__FILE__).'/../lib/phpbb/script_init.php');
(function($) {
var do_stuff = function() {
// ...
};
do_stuff();
})(jQuery);
@p
p / timestamp-asset-urls.py
Created January 20, 2012 05:22
Asset url timestamping for phpbb
#!/usr/bin/env python
# Current timestamp can be obtained by, e.g.:
#
# perl -e 'print time'
import os, os.path, re, sys
if len(sys.argv) != 2:
print >>sys.stderr, "Usage: timestamp-asset-urls timestamp"
@p
p / 1
Created November 25, 2011 19:30
Executing phar files
(14:23:02) nn-: (13:36:13) naderman: you can easily install the phar extension - not that easy really
(14:23:16) nn-: i still cannot get php to execute phar files
(14:23:28) nn-: either on my system or on a fresh debian install i tried yesterday
(14:23:34) naderman: do you have suhosin?
(14:23:39) nn-: i do
(14:23:39) naderman: debian comes with suhosin
(14:23:46) naderman: it breaks phar by default unless you add some setting
(14:23:47) naderman: one sec
(14:24:19) naderman: http://silex.sensiolabs.org/doc/usage.html#pitfalls
(14:24:40) nn-: i'm pretty sure i did that
pie@jungle ~ % irb
irb(main):001:0> require 'rexml/document'
=> true
irb(main):008:0> doc=REXML::Document.new(%(<html><head><script type="text/javascript">window.jQuery || document.write('<script src="{T_ASSETS_PATH}/javascript/jquery.js"><\\/script>')</script></head></html>))
REXML::ParseException: #<REXML::ParseException: malformed XML: missing tag start
Line:
Position:
Last 80 unconsumed characters:
<\/script>')</script></head></html>>
/usr/local/lib/ruby/1.8/rexml/parsers/baseparser.rb:356:in `pull'
@p
p / test reqs
Created August 20, 2011 18:31
phpbb todo
egosearch doing table scans on posts due to approved flag
move sqlite db to tests/tmp (pr #319)
add envvar check to override tests/tmp (pr #319)
https://github.com/phpbb/phpbb3/pull/319
(17:45:43) nn-: when i quote multiple lines of text as described in the ticket the lines are squashed into a single line
(17:45:55) nn-: worse, there is no spacing between what used to be separate lines at all
10253
@p
p / orig
Created August 14, 2011 17:11
wooka% php -d include_path=$HOME/apps/thirdparty/phpunit/bundle/ ~/apps/thirdparty/phpunit/bundle/phpunit.php -c phpunit.xml.all tests/network/ftp_fsock_test.php
PHPUnit @package_version@ by Sebastian Bergmann.
E
Time: 1 second, Memory: 4.50Mb
There was 1 error:
1) phpbb_ftp_fsock_test::test_pasv_epsv
@p
p / main
Created May 18, 2011 05:34
PHPBB3-9856
qi_t21=> ANALYZE phpbb_topics;
ANALYZE
qi_t21=> explain SELECT t.topic_id
qi_t21-> FROM phpbb_topics t
qi_t21-> WHERE t.forum_id = 2
qi_t21-> AND t.topic_type IN (0, 1)
qi_t21-> ORDER BY t.topic_type DESC, t.topic_last_post_time DESC
qi_t21-> LIMIT 25 OFFSET 100;
QUERY PLAN
---------------------------------------------------------------------------------------------------------------