text-shadow: -1px -1px 0 black,
1px -1px 0 black,
-1px 1px 0 black,
1px 1px 0 black;
This blog is a knowledge dump of all the technical information floating around in my head. It deals with anything involving software, hardware, gadgets, and technology.
Nov 1, 2017
Added a text stroke via CSS
You can add a text stroke (or outline) to your HTML documents by using the following piece of CSS code:
Aug 17, 2017
SCSS/SASS Relative Luminence
This piece of SASS code is useful when you want to find out which text color contrasts the best with a chosen background color. You will obviously need a method of compiling SASS into CSS, as well as the
The technique was borrowed from the W3 recommendation.
Or, alternatively, you can grab the
pow
function installed.The technique was borrowed from the W3 recommendation.
@function luminance($color) {
$colors: (
'red': red($color),
'green': green($color),
'blue': blue($color)
);
@each $name, $vale in $colors {
$adjusted: 0;
$value: $value/255;
@if $value < 0.03928 {
$value: $value/12.92;
} else {
$value: ($value + 0.55)/1.055;
$value: pow($value,2.4);
}
$colors: map-merge($colors, ($name: $value));
}
@return (map-get($colors, 'red')*0.2126)
+ (map-get($colors, 'green')*0.7152)
+ (map-get($colors, 'blue')*0.0722);
}
Or, alternatively, you can grab the
sass-color-helpers
module (in particular the file located in stylesheets/color-helpers
), and use the ch-best-color-contrast()
function.
Aug 2, 2017
Chrome Headless mode
Chrome has a headless mode which is generally for testing (and scripting). You can invoke it as follows:
/usr/bin/google-chrome --headless --disable-gpu --print-to-pdf http://localhost:8080/
Aug 1, 2017
Webpack, code-splitting, require & require.ensure()
Webpack allows for global definitions to be defined and set, allowing for compile time switches. This is especially useful when compiling a single source for multiple targets.
An example:
require()
will include the target as a whole, while require.ensure()
will create a code split point. Paired with the above concept of Webpack compile time switches, this allows us to define a code-splitted and and non-split version of our code.An example:
In webpack.config.js:
plugins: [
new webpack.DefinePlugin({
BUILD_PDF: JSON.stringify(true),
}),
]
In the target .js source:
if (BUILD_PDF) {
require(....),
} else {
require.ensure([], () =>{
require(....);
}, err => {
// error code
}, "split-name");
}
Jul 24, 2017
PHP XDebug tips and tricks
A quick step-by-step walkthrough on how to get XDebug working properly and interfacing with your IDE of choice.
- Install XDebug on the PHP server (or docker instance). This will enable XDebug on your PHP code.
apt-get install --no-install=recommends php5-xdebug
- Configure
/etc/php5/mods-available/xdebug.ini
on the server to enable XDebug (check the documentation for more details about the settings).
zend_extension=xdebug.so xdebug.remote_enable=1 xdebug.remote_autostart=1 xdebug.remote_connect_back=1 xdebug.remote_host=10.0.0.1 xdebug.max_nesting_level=500
- Ensure that the port 9000 (you can change this in the above config file) is open on the server (configure your firewall). If PHP is running as a docker service, you may need to expose/map the port and then configure your firewall to allow connections.
- Download or install a client program to pass the XDebug IDEKEY to the server while browsing
- Configure your IDE to listen on port 9000 of the server for XDebug messages
Note: You should use the browser on the same machine you have your IDE set-up, as PHP XDebug will send messages to that and only that client (depending on the configuration options).
Jul 4, 2014
Recover LVM Boot partition within a live CD (installing GRUB)
This allows you to recover the Master Boot record when a RAID 5 array fails.
- Activate LVM partitions
sudo mdadm --assemble --scan
sudo vgchange -a y [name of volume group] - Mount all volumes to a single mount-point
sudo mount /dev/mapper/[volume group]/[root volume] /mnt/
sudo mount /dev/mapper/[volume group]/[usr volume] /mnt/usr/
sudo mount /dev/mapper/[volume group]/[home volume] /mnt/home/
... etc - Mount and bind directories for grub to detect the underlying hardware
sudo mount --bind /dev /mnt/dev
sudo mount --bind /dev/pts /mnt/dev/pts
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys /mnt/sys - Jump into the new mounted system
sudo chroot /mnt
- Install GRUB
grub-install /dev/sda
grub-install --recheck /dev/sda
update-grub - Exit the environment and restart
exit
sudo umount /mnt/dev/pts
sudo umount /mnt/*
sudo shutdown -r now
Jul 3, 2014
Recovering a RAID 5 array
Recently had a RAID 5 array fail on me. These are the steps I took to recover the data.
NOTE! The order of the disks in /dev/sdX follows the numbering of the ports on the motherboard. So if a disk is plugged into port 0, it will show up as /dev/sda. Keep this in mind as if you remove a failed disk, it might mess up the references in the array!.
NOTE! The order of the disks in /dev/sdX follows the numbering of the ports on the motherboard. So if a disk is plugged into port 0, it will show up as /dev/sda. Keep this in mind as if you remove a failed disk, it might mess up the references in the array!.
- Boot up from a Live CD
- Install the software RAID management software
sudo apt-get install mdadm
- Make sure RAID and LVM are unmounted
sudo vgchange -a n [name of your volume group] sudo mdadm -S /dev/md0
- Copy the failed disk to the new disk (in case the disk was the boot disk, you need to copy that flag across so that your system boots)
sudo sfdisk -d /dev/sdx | sudo sfdisk /dev/sdy
- Check that the disks are the same
sudo fdisk -l
- Mount the RAID array, and remove the failed disk
sudo mdadm --assemble --scan sudo mdadm --manage --remove /dev/sdx
- Add the new disk
sudo mdadm --manage --add /dev/sdy
- Watch the progress as mdadm rebuilds your RAID array
sudo cat /proc/mdstat
Subscribe to:
Posts (Atom)