Skip to content

Instantly share code, notes, and snippets.

View alexandernst's full-sized avatar

Alexander Nestorov alexandernst

View GitHub Profile
@alexandernst
alexandernst / detect.php
Created March 21, 2014 09:09
Detect eval calls using PHP's parser
<?php
//Usage: php detect.php /path/to/file.php
$data = file_get_contents($argv[1]);
$tokens = token_get_all($data);
foreach($tokens as $token){
if($token[0]==T_EVAL){
echo "Eval found in file " . $argv[1] . " on line: " . $token[2] . "\n";
}

CSS Layout Debbuger

A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

One-line version to paste in your DevTools

Use $$ if your browser aliases it:

~ 108 byte version

@alexandernst
alexandernst / e404.js
Created June 24, 2012 14:36
Backbone Error 404
window.APP = Backbone.Router.extend({
initialize: function(){
this.route(/.*?/, "e404");
this.route(/^$/, 'mainPage');
//Some other routes
},
e404: function(){
console.log("Error 404!");
@alexandernst
alexandernst / views.js
Created June 24, 2012 13:30
Backbone Views creation
window.App = Backbone.Router.extend({
initialize: function(){
this.route(/^$/, 'mainPage');
}
mainPage: function(){
console.log("Showing main page...");
var content = $('#content');
@alexandernst
alexandernst / myview.js
Created July 18, 2012 08:07
Backbone View listening for finished uploads
var myView = Backbone.View.extend({
events: {
'click .start_upload': 'start_upload'
}
initialize: function(){
EventBus.addEventListener("upload_done", this.upload_callback);
}
@alexandernst
alexandernst / eventbuscall.js
Created July 18, 2012 08:10
EventBus call from server side
<?php
// handle file ...
// more stuff ...
?>
<script language='javascript' type='text/javascript'>
window.top.window.EventBus.dispatch("upload_done", this, 42);
</script>
@alexandernst
alexandernst / cross-compiling-gstreamer-hello-world
Last active December 15, 2015 08:48
Cross-compiling applications for ARM
$ pwd
/home/alexandernst/tmp_arm_build
$ cat gst_hello_world.c
#include <gst/gst.h>
int main(int argc, char **argv){
gst_init(&argc, &argv);
GMainLoop *loop = g_main_loop_new(NULL, FALSE);
GstElement *pipeline = gst_parse_launch("videotestsrc ! autovideosink", NULL);
GstElement *test = gst_bin_get_by_name(GST_BIN(pipeline), "test");
@alexandernst
alexandernst / cross-compiling-folder-structure
Last active December 15, 2015 08:49
Cross-compiling applications for ARM
$ pwd
/home/alexandernst/tmp_arm_build
$ tree -L 2
.
├── deps
│   ├── glib-2.35.9
│   ├── gst-plugins-base-0.10.36
│   ├── gstreamer-0.10.36
│   ├── libffi-3.0.13
│   ├── orc-0.4.17
@alexandernst
alexandernst / cross-compiling-folder-structure
Last active December 15, 2015 08:49
Cross-compiling applications for ARM
$ pwd
/home/alexandernst/tmp_arm_build
$ cd deps/zlib-1.2.7/
$ export PKG_CONFIG_PATH=/home/alexandernst/tmp_arm_build/libs/lib/pkgconfig/
$ sb2 ./configure --prefix=/home/alexandernst/tmp_arm_build/libs/ &> /dev/null
$ sb2 make &> /dev/null
$ sb2 make install &> /dev/null
$ cd ../..
$ pwd
/home/alexandernst/tmp_arm_build
@alexandernst
alexandernst / cross-compiling-folder-structure
Created March 25, 2013 00:37
Cross-compiling applications for ARM
$ tree -L 2
.
├── deps
│   ├── glib-2.35.9
│   ├── gst-plugins-base-0.10.36
│   ├── gstreamer-0.10.36
│   ├── libffi-3.0.13
│   ├── orc-0.4.17
│   └── zlib-1.2.7
├── gst_hello_world