Skip to content

Instantly share code, notes, and snippets.

@ArtemGr
ArtemGr / snippets.php
Last active August 29, 2015 13:56
PHP snippets.
// Logging.
error_log (print_r ($whatever, true));
foreach (debug_backtrace() as $en)
error_log (' ' . (empty ($en['file']) ? '' : $en['file'] . ':' . $en['line']) . '; ' . $en['function']);
file_put_contents ('/tmp/php.delme.log', print_r ($..., true) . "\n", FILE_APPEND);
// Interpolation hack (http://php.net/manual/en/language.types.string.php#91628).
function _e ($v) {return $v;} // Usage: $_e = '_e'; "foo {$_e ('bar')}"
// Casting a variable in IntelliJ.
@ArtemGr
ArtemGr / mod_sustest.c
Created March 30, 2014 10:09
SUSPENDED test case
// apxs -i -a -c mod_sustest.c
// SetHandler sustest
#include <httpd.h>
#include <http_protocol.h>
#include <http_config.h>
#include <http_request.h>
#include <http_log.h>
#include <http_connection.h>
#include <ap_mpm.h>
@ArtemGr
ArtemGr / event.patch
Last active August 29, 2015 13:57
A hack to make Apache SUSPENDED work with HTTP.
--- a/server/mpm/event/event.c 2013-07-11 16:24:26.000000000 +0400
+++ b/server/mpm/event/event.c 2014-03-31 12:05:54.314892858 +0400
@@ -1044,6 +1044,7 @@
}
}
else if (cs->pub.state == CONN_STATE_SUSPENDED) {
+ cs->c->vhost_lookup_data = cs; // A hack to save the `cs` for `resume_suspended`.
apr_atomic_inc32(&suspended_count);
}
/*
@ArtemGr
ArtemGr / eador-unpack.cc
Last active August 29, 2015 14:01
Eador: Masters of the Broken World - savegame unpacker
// Cygwin: cd /tmp; g++ -O3 -fno-inline-functions -Wall -std=c++11 eador-unpack.cc -o eador-unpack -lz
// MinGW: g++ -static -O3 -fno-inline-functions -Wall -std=c++11 eador-unpack.cc -o eador-unpack -lz && upx eador-unpack.exe
// "They are just using ionic zip to compress part of the contents"
// http://www.cheathappens.com/show_board2.asp?headID=117333&titleID=19617&onPage=11
#include <stdlib.h>
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
@ArtemGr
ArtemGr / Cargo.toml
Created January 18, 2015 20:43
Test case for json_macros bug
[package]
name = "err"
version = "0.0.1"
authors = ["ArtemGr"]
[[bin]]
name = "test"
path = "test.rs"
[dependencies]
@ArtemGr
ArtemGr / icu.rs
Created January 25, 2015 21:05
Partial ICU bindings for Rust
pub mod ICU {
// --- Hand-made ICU bindings ---
// $ apt-get install -y libicu-dev
// To check the argument types:
// $ apt-get install -y libicu52-dbg
// $ cd /usr/lib/x86_64-linux-gnu && gdb libicui18n.so
// ) print utrans_open_52
// ) ptype UChar
// ) ptype UParseError
#![feature(scoped_tls)]
#[macro_use] extern crate nickel;
use nickel::Nickel;
use nickel::router::http_router::HttpRouter;
use nickel::ResponseFinalizer;
struct MyObject;
impl MyObject {
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint at: /tmp/yup-oauth2/target/debug/.fingerprint/yup-oauth2-f648bac97266aa1c/lib-yup-oauth2
DEBUG:cargo::ops::cargo_rustc::fingerprint: extra Target { kind: Lib([Lib]), name: "yup-oauth2", src_path: "/tmp/yup-oauth2/src/lib.rs", metadata: Some(Metadata { metadata: "f648bac97266aa1c", extra_filename: "-f648bac97266aa1c" }), tested: true, benched: true, doc: true, doctest: true, harness: true, for_host: false } Profile { opt_level: 0, lto: false, codegen_units: None, rustc_args: None, debuginfo: true, debug_assertions: true, rpath: false, test: false, doc: false } None = def601c33e56949f
DEBUG:cargo::ops::cargo_rustc::fingerprint: extra Target { kind: Lib([Dylib]), name: "serde_macros", src_path: "/root/.cargo/registry/src/github.com-1ecc6299db9ec823/serde_macros-0.4.0/src/lib.rs", metadata: Some(Metadata { metadata: "a56f347bda653264", extra_filename: "-a56f347bda653264" }), tested: true, benched: true, doc: true, doctest: false, harness: true, for_host: true
@ArtemGr
ArtemGr / gist:45741
Created January 11, 2009 18:08
Moving to FreeBSD 7.1 using Pover Recovery at server4you.de
We couldn’t find that file to show.
@ArtemGr
ArtemGr / gist:51009
Created January 23, 2009 12:55
Enable optional transparency in PlotKit
[artemgr@pcbsd /tmp/plotkit-patches]$ git diff
diff --git a/PlotKit/SweetCanvas.js b/PlotKit/SweetCanvas.js
index dcfdfc5..39cbf2c 100644
--- a/PlotKit/SweetCanvas.js
+++ b/PlotKit/SweetCanvas.js
@@ -195,6 +195,10 @@ PlotKit.SweetCanvasRenderer.prototype._renderLineChart = function() {
// faux shadow for firefox
if (this.options.shouldFill) {
+ // Transparent fill.