Skip to content

Instantly share code, notes, and snippets.

% pwd
/tmp/ex
% mkdir old
% echo "0xFF 255 11111111" > old/stuff
% echo "192.168.0.0/16" > old/net
% cp -R old new
% echo "192.168.2.0/24" > old/net
% echo "0xF0 240 11110000" > old/stuff
% diff -r -u old/ new/ > patchfile
% cat patchfile
% docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0069ffd119ae mysql:5 "/entrypoint.sh mysq 7 minutes ago Up 7 minutes 0.0.0.0:49153->3306/tcp mysql
% mysql -u root -h 192.168.59.103 -P 49153 -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.24 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
@kramapet
kramapet / wymeditor_destroy.js
Created October 28, 2014 20:33
Destroy instance of WYMeditor
/**
* destroy instance of wymeditor:
* - updates content between iframe and textarea
* - remove iframe
* - show textarea
* - replace element with undefined (to trick jQuery.getWymeditorByTextarea(el))
* @see https://github.com/wymeditor/wymeditor/blob/master/src/wymeditor/core.js#L520
* @param {WYMeditor.editor} instance
*/
var wymeditor_destroy = function (instance) {
@kramapet
kramapet / gist:0084ef46c3aab5b8f931
Last active August 29, 2015 14:07
Perl - binding socket on port
$ perl -mIO::Socket -e 'my $s = new IO::Socket::INET(Listen => 1, LocalAddr => "localhost", LocalPort => 8888, Proto => "tcp"); my $data = $s->accept(); while (<$data>) { print $_; } close($s);'
@kramapet
kramapet / gist:9f876ead1241ff0d141d
Last active August 29, 2015 14:06
Wordpress - How to extend xmlrpc to retrieve archives
<?php
/**
* Plugin Name: XMLRPC archive
* Plugin Uri: http://localhost/
* Description: Extend Wordpress API to get archives
* Version 1.0
* Author: John Doe
*/
@kramapet
kramapet / gist:c1127438c10dd36e3aec
Last active August 29, 2015 14:04
Drupal API - How to add field translation for label
<?php
$entity = 'node';
$field_name = 'employee_first_name';
$bundle = 'employee';
$lang_code = 'fi';
$value = 'Nimi';
// get field instance
$instance = field_info_instance($entity, $field_name, $bundle);