Skip to content

Instantly share code, notes, and snippets.

View ditikos's full-sized avatar
🎯
Focusing

Panagiotis Chalatsakos ditikos

🎯
Focusing
View GitHub Profile

How to setup a minimal X11 environment on Debian GNU/Linux

  1. Install the following packages

    • xserver-xorg-core (server)
    • xserver-xorg-video-XXX (video driver, XXX depends on your hardware)
    • xserver-xorg-input-XXX (input device driver, XXX depends on your hardware. evdev works well for most cases)
    • x11-xserver-utils (xmodmap, xrandr)
    • x11-xkb-utils (setxkbmap)
  • x11-utils (xdpyinfo, xev, xkill, xprop, xwininfo)
Why is the answer 5 ?
Let’s go through the question again and talk through the result.
1 rabbit saw 6 elephants while going to the river. <– Therefore, one animal (the rabbit) is going towards the river.
Every elephant saw 2 monkeys going towards the river. <– This is the tricky part, from the sentence it implies each of the 6 elephants saw 2 monkeys going towards the river, hence logically will be 6 x 2 = 12 animals (monkeys) going towards the river.
However, the statement does not explicitly say that “Every elephant saw 2 DIFFERENT monkeys…”, therefore implicit rules apply and infer that the 2 monkeys are the same.
@ditikos
ditikos / detect.asm
Created April 10, 2020 19:07 — forked from ljmccarthy/detect.asm
Detect CGA, EGA, VGA or VESA BIOS in DOS.
format MZ
entry main:start
use16
segment main
start:
; detect EGA BIOS
mov ah, 0x12
mov bl, 0x10
@ditikos
ditikos / squash.php
Created December 1, 2019 15:00 — forked from woganmay/squash.php
Use PHP to flatten a multidimensional stdClass object (like a json_decode result)
<?php
function squash($array, $prefix = '')
{
$flat = array();
$sep = ".";
if (!is_array($array)) $array = (array)$array;
foreach($array as $key => $value)
@ditikos
ditikos / product-compare.php
Created December 30, 2016 14:35
Compare a woocommerce product in En / Gr using WPML functions.
global $post;
define( 'WP_USE_THEMES', false );
/* Template Name: Price comparison */
/* Page needs to be in EN language */
get_header();
?>
<table>
<tr>
@ditikos
ditikos / functions.php
Created July 22, 2015 11:52
Wordpress admin add Google Maps Metabox
<?php
// ... include at the end of functions.php
// 1. Add google maps -- REQUIRED GOOGLE MAPS API KEY
function wp_google_scripts() {
$API_KEY = "AIzaSyAj1hqhXwaUnJDZzisebduqKg2QFsCYCS4";
wp_enqueue_script( 'google-maps-native', "http://maps.googleapis.com/maps/api/js?key=".$API_KEY);
}
add_action( 'admin_enqueue_scripts', 'wp_google_scripts' );
@ditikos
ditikos / gmaps_cpt_cfields.txt
Created July 22, 2015 10:38
Load Google maps in multiple posts/pages/cpt using lat/lng as custom fields
// PREREQUISITES
1. Google API Maps Browser Key
// NOTE: The following example assumes you are using posts in the front page (like twentyfifteen theme).
// Change when needed.
// Style.css:
Add the direction:
.maps { height: 40vh; width: 100%; }
@ditikos
ditikos / gist:4f44b2f03243cd13df20
Created July 14, 2015 09:20
Custom taxonomy preselection (eg prefecture) on wordpress "Add new page/post/CPT"
Στο παράδειγμα που χρησιμοποιώ, έχω συνδέσει τις pages με την category taxonomy.<br/>
Επίσης έχει και συνδεση με το polylang (εαν ειναι ενεργοποιημενο, ειδαλλως ολα τα taxonomy terms θεωρουνται στην default language).
Στο pages εχω κανει assign 3 terms: homepage-elements, home-slider, galleries, με αντίστοιχα πολυγλωσσικα.
1. δημιουργούμε την δομή στο χρήστη (usermeta) που θα κρατήσει το taxonomy term.
Για λόγους ευκολίας θα είναι textbox με key "assigned_term" και την τιμή homepage_elements. Ιδανικά θα ήταν ενα dropdown με τα terms ή μια ομαδα checkboxes.
Στο functions.php προσθέτουμε τα εξής:
@ditikos
ditikos / gist:681ac3c01dc1cb2415cc
Last active August 29, 2015 14:07
New Exclude Class
class Extended_Walker_Category extends Walker_Category
{
/**
* Start the element output.
*
* @see Walker::start_el()
*
* @since 2.1.0
*
* @param string $output Passed by reference. Used to append additional content.
@ditikos
ditikos / WooExclude_Walker_Category
Last active August 29, 2015 14:07
Exclude specific products from a woocommerce list using a custom walker.
class WooExclude_Walker_Category extends Walker_Category
{
/**
* Start the element output.
*
* @see Walker::start_el()
*
* @since 2.1.0
*
* @param string $output Passed by reference. Used to append additional content.