Skip to content

Instantly share code, notes, and snippets.

@colin-kiegel
colin-kiegel / gist:b35d278d6ed5251dfa85
Created December 1, 2015 14:11
regex replace multi-line + in multiple files
$FILES="*.rs"
$REGEX="s#(.*)\n(.*)/\2\n\1/"
find . -name "$FILES" | xargs perl -0777 -pi -e '$REGEX'
# flag: -0777 tells perl to read the file as a whole
# replace '-pi' with '-pi.bak' to create backups
@colin-kiegel
colin-kiegel / self_contained_reference.rs
Created November 22, 2015 16:56
Twig Tokens with str-references - *without RC*
use std::mem;
/// This is an attempt to reduce allocations in the Twig-Rust template engine.
///
/// During compilation the inial template string is transformed
/// - to a token stream during lexing
/// - to a node tree during parsing
///
/// The tokens and nodes mostly contain slices of the original string. But the
/// current implementation uses new allocations and copy-by-value instead of
@colin-kiegel
colin-kiegel / cargo-kcov
Last active November 28, 2015 01:44
cargo-kcov
#!/bin/bash
# original source https://users.rust-lang.org/t/tutorial-how-to-collect-test-coverages-for-rust-project/650
# modified version https://gist.github.com/colin-kiegel/e3a1fea04cd3ad8ed06d
PKGID="$(cargo pkgid)"
[ -z "$PKGID" ] && exit 1
ORIGIN="${PKGID%#*}"
ORIGIN="${ORIGIN:7}"
PKGNAME="${ORIGIN##*/}"
@colin-kiegel
colin-kiegel / .ctags
Created November 7, 2015 16:58
~/.ctags for PHP
--recurse
--languages=PHP
--exclude=.svn
--exclude=.git
--exclude="*/_*cache/*"
--exclude="*/_*logs{0,1}/*"
--exclude="*/_*data/*"
--totals=yes
--tag-relative=yes
--PHP-kinds=+cfd
@colin-kiegel
colin-kiegel / print-testpage
Last active May 1, 2016 20:46
Print Weekly Testpage with anacron
#!/bin/bash
lp /usr/share/cups/data/default-testpage.pdf
@colin-kiegel
colin-kiegel / racer-update
Last active April 5, 2017 08:17
racer-update
#!/bin/bash
RACER_SRC_PATH="/usr/local/src/racer"
RACER_REPO="https://github.com/phildawes/racer.git"
RUST_REPO="https://github.com/rust-lang/rust.git"
if [ -z $RUST_SRC_PATH ]; then
echo "TODO: Set the RUST_SRC_PATH env variable to point to the 'src' dir in your rust source installation, e.g.:
export RUST_SRC_PATH=/usr/local/src/rust/src";
RUST_SRC_PATH=/usr/local/src/rust/src
@colin-kiegel
colin-kiegel / cargo-exec
Last active March 18, 2016 23:30
cargo-wait
#!/bin/bash
# This FIRST WRAPPER only calls cargo - but it has a different name, so we can search for its PID in the second wrapper
#
# This is only meant to be called by cargo-wait (=second wrapper)
/usr/local/bin/cargo $@
@colin-kiegel
colin-kiegel / pre-compile-hhvm.sh
Created March 30, 2015 16:13
HHVM PreCompile-Script for RepoAuthoritative Mode
#!/bin/bash
# CONFIGURATION: #############
echo "You need to edit this script before running it the first time."
exit # remove this line after finishing your configuration
WWW_DIR="/www/pub/ilias-trunk"
FILE_MASK="\\*.php"
INDEX_TMP="/var/run/hhvm/precompiled/fileindex"
@colin-kiegel
colin-kiegel / hhvm_php.ini
Last active June 30, 2016 11:28
ILIAS / HHVM / Nginx configs
; /etc/hhvm/php.ini
; php options
session.save_handler = files
session.save_path = /var/lib/php5
session.gc_maxlifetime = 1440
; hhvm specific
hhvm.log.level = Warning
hhvm.log.always_log_unhandled_exceptions = true ; (!)
Testcase ID=/Modules/SurveyQuestionPool/phplot/phplot.php:672
Array
(
[in] => Array
(
[which_style] => 4-3
[which_ndxcol] => 0
)
[out1] => Array