Skip to content

Instantly share code, notes, and snippets.

Avatar

Petr Kramář kramapet

View GitHub Profile
View gist:73e20123b4a30941bf08
% 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
View gist:2ff31862b477537c4792
% 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 Oct 28, 2014
Destroy instance of WYMeditor
View wymeditor_destroy.js
/**
* 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 Aug 29, 2015
Perl - binding socket on port
View gist:0084ef46c3aab5b8f931
$ 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 Aug 29, 2015
Wordpress - How to extend xmlrpc to retrieve archives
View gist:9f876ead1241ff0d141d
<?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 Aug 29, 2015
Drupal API - How to add field translation for label
View gist:c1127438c10dd36e3aec
<?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);
You can’t perform that action at this time.