Skip to content

Instantly share code, notes, and snippets.

@dawehner
dawehner / hack.sh
Last active August 29, 2015 08:52 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
class foo {
public $foo = 123;
public function test() {
test($this);
print $this->foo;
}
}
function test(foo $foo) {
$new_foo = new foo();
@dawehner
dawehner / gist:9502861
Created March 12, 2014 08:18
Auto-update ipython notebook cell
var update = function() {
cell = IPython.notebook.get_cell(5);cell.execute();
cell.focus_cell();
};
setInterval(update, 600000);
class EntityDerivative implements ContainerDerivativeInterface {
public function getDerivativeDefinitions($base_plugin_definition) {
$route_collection = ... // INSERT COIN/MAGIC
$route = $route_collection->get($route_name);
class ResourceRoutes extends RouteSubscriberBase{
protected function alterRoutes(RouteCollection $collection) {
$routes = array();
$enabled_resources = $this->config->get('rest.settings')->get('resources') ?: array();
// Iterate over all enabled resource plugins.
foreach ($enabled_resources as $id => $enabled_methods) {
$plugin = $this->manager->getInstance(array('id' => $id));
diff --git a/core/lib/Drupal/Core/EventDispatcher/LiteEventDispatcher.php b/core/lib/Drupal/Core/EventDispatcher/LiteEventDispatcher.php
new file mode 100644
index 0000000..81d5987
--- /dev/null
+++ b/core/lib/Drupal/Core/EventDispatcher/LiteEventDispatcher.php
@@ -0,0 +1,194 @@
+<?php
+
+/**
+ * @file
diff --git a/core/modules/menu_link/lib/Drupal/menu_link/MenuTree.php b/core/modules/menu_link/lib/Drupal/menu_link/MenuTree.php
index adbf85d..c52be9e 100644
--- a/core/modules/menu_link/lib/Drupal/menu_link/MenuTree.php
+++ b/core/modules/menu_link/lib/Drupal/menu_link/MenuTree.php
@@ -428,7 +428,7 @@ public function buildTree($menu_name, array $parameters = array()) {
// Build the menu tree.
$tree = $this->doBuildTree($menu_name, $parameters);
// Check access for the current user to each item in the tree.
- $this->checkAccess($tree);
+ $this->doCheckAccess($tree);
@dawehner
dawehner / gist:11393594
Created April 29, 2014 08:04
Provide a small script to check whether a host is reachable via ssh, when the ssh connection is disabled/storage problems occured or whatever
import subprocess
import os
proc = subprocess.Popen(['ssh', '-v', 'user@host', 'exit'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
for line in iter(proc.stderr.readline,''):
if line.find("Authenticated to") is not -1:
os.system('notify-send "Server X works again"');
os.system('echo "Server X works again" | mail -s "Server update" yourmail@example.com')

Keybase proof

I hereby claim:

  • I am dawehner on github.
  • I am dawehner (https://keybase.io/dawehner) on keybase.
  • I have a public key whose fingerprint is E374 2F8C CDB4 A44E 8F2F 65C0 DEDA D193 C1CA A511

To claim this, I am signing this object:

#!/usr/bin/python
import random
import os
import argparse
import requests
import xml.etree.ElementTree as ET