Select content in a div with only css

, ,
.selectable {
    -webkit-touch-callout: all; /* iOS Safari */
    -webkit-user-select: all; /* Safari */
    -khtml-user-select: all; /* Konqueror HTML */
    -moz-user-select: all; /* Firefox */
    -ms-user-select: all; /* Internet Explorer/Edge */
    user-select: all; /* Chrome and Opera */
    border-bottom-width: 1px;
    border-bottom-style: dashed;
    border-bottom-color: chocolate;
    cursor: pointer;
    display: inline-block;
}

Just by adding that CSS and adding the class selectable to your HTML element will highlight all the inner HTML. Then the user can press ctrl+c to copy the text without needing to highlight everything. This has a very nice effect on your mobile devices. It will highlight everything on your phone which is very convenient

New keyboard and mouse

, ,

After approximately eight years, I finally purchased a new keyboard and mouse as my previous ones deteriorated. I conducted thorough research and discovered the realm of mechanical keyboards and gaming mice.

Regarding mechanical keyboards, the options and considerations are seemingly endless. There is a myriad of factors to ponder over before making a decision that suits your preferences and needs. One of the first things to contemplate is whether you desire LED keys or not. LED keys can add a touch of visual appeal to your keyboard, making it stand out and adding a touch of personalization to your gaming or typing experience. Moreover, LED keys also make it easier to locate specific keys in dimly lit environments, enhancing visibility and reducing the chances of making typing errors. However, the decision doesn’t end there. Once you’ve decided on LED keys, you’re faced with an array of color switches to choose from. Each color switch has its own unique characteristics and feel, catering to different typing or gaming styles. For instance, Cherry MX Red switches are known for their smooth linear feel, making them ideal for rapid and precise movements during gaming. On the other hand, Cherry MX Blue switches offer a tactile and audible feedback, perfect for those who enjoy the satisfying clickety-clack sound and a distinct tactile sensation with each keystroke. The selection of the right color switch is crucial as it directly affects the overall typing experience and can significantly impact your productivity or gaming performance. Textured keys are yet another aspect to contemplate. These keys feature a textured surface that provides enhanced grip and tactile feedback. They are particularly useful for gamers who require precise control and accuracy during intense gaming sessions. The added texture ensures key presses are registered accurately, reducing the chances of accidental keystrokes or misfires. Moreover, textured keys can also be beneficial for typing enthusiasts who prefer a unique and gratifying typing experience. The textured surface adds an extra layer of tactile satisfaction, making typing on the keyboard a delightful and engaging experience. Of course, price is always a crucial consideration when buying a mechanical keyboard. The right amount of money to spend on a keyboard can vary depending on individual preferences and budget constraints. Mechanical keyboards can range from budget-friendly options to high-end, premium models. It is important to strike a balance between quality, features, and cost to ensure you are getting the best value for your money. While some mechanical keyboards can indeed be quite expensive, it is essential to consider the long-term benefits and durability they offer, as they are designed to withstand heavy usage and provide a superior typing or gaming experience for years to come. Navigating through the vast array of mechanical keyboards available on the market can undoubtedly be overwhelming. However, after careful research and consideration, I stumbled upon the Corsair K68 keyboard. With its impressive durability, stunning LED backlighting, and wide range of Cherry MX switches to choose from, the Corsair K68 intrigued me. It boasts a robust construction that can withstand accidental spills and dust, providing peace of mind for those who enjoy their beverages while working or gaming. Additionally, the Corsair K68 offers dedicated multimedia controls, allowing seamless control over audio playback without interrupting your workflow or gameplay. In conclusion, the world of mechanical keyboards is a vibrant and dynamic one, offering a plethora of options to cater to everyone’s unique preferences. From LED keys to textured surfaces, the choices are endless. With careful consideration of factors such as switch color, textured keys, and budget, you can find the perfect mechanical keyboard that will elevate your typing or gaming experience to new heights. So, take your time, explore your options, and embark on a journey to discover the mechanical keyboard that resonates with you the most.

What did I choose

For my mouse, I chose a Logitech G502 Hero (around $47), and for my keyboard, I selected the Corsair K68 (around $73).

In my quest for the ideal keyboard, I have found that a quiet keyboard with light, easily pressed keys and a short travel distance is my preference. The soft whisper of the keys enhances my writing experience, while the effortless glide allows for speedy and precise typing. A shorter travel distance reduces strain and promotes comfort. It is through this meticulous selection process that I have discovered the keyboard that complements my typing style, enabling me to express myself with grace and efficiency effortlessly.

I absolutely adore macros and shortcut keys; they have become an integral part of my daily computing experience. They not only save me valuable time but also enhance my productivity. That’s why I was delighted when I discovered the G502 Hero, a gaming mouse that offers a stunning array of 11 programmable buttons. This remarkable feature allows me to customize my mouse to suit my specific needs, whether it’s for gaming or for streamlining my work processes. But that’s not all; the G502 Hero goes above and beyond by providing the ability to adjust pointer sensitivity directly on the mouse itself. This means that I can effortlessly fine-tune the mouse’s tracking speed to match my preferences without having to navigate through complex software settings. This feature has proven to be incredibly convenient, especially when I switch between different tasks that require varying levels of precision. In terms of satisfaction, I can confidently say that I am highly pleased with my purchase of the G502 Hero. The mouse not only meets but exceeds my expectations, considering its affordable price point. Its ergonomic design fits comfortably in my hand, ensuring that I can use it for extended periods without experiencing any discomfort or fatigue. The G502 Hero’s exceptional build quality, coupled with its precise and responsive tracking, further adds to its appeal. Whether I’m engaged in intense gaming sessions or tackling demanding work projects, the mouse effortlessly keeps up with my every move. Moreover, the G502 Hero is equipped with customizable RGB lighting, allowing me to personalize its appearance to match my style or mood. This feature adds a touch of flair to my workstation and enhances the overall aesthetic appeal. Additionally, the G502 Hero comes with onboard memory that enables me to save my preferred settings directly on the mouse. This means that I can seamlessly transition between different computers without having to reconfigure my macros and sensitivity settings every time. This convenience has proved to be a game-changer for me, as I frequently switch between my gaming rig and my work laptop. In conclusion, the G502 Hero has undoubtedly exceeded my expectations in terms of functionality, customization options, and overall user satisfaction. Its extensive button layout, pointer sensitivity adjustment, ergonomic design, build quality, and additional features make it a standout choice for both gaming enthusiasts and professionals seeking a versatile and reliable mouse. Considering its reasonable price point, it is an absolute steal and a worthwhile investment for anyone looking to elevate their computing experience to new heights.

if you search for ‘ or ” and it breaks your software

, ,

Chances are if you are using a database and your application errors out when you enter ‘ or ” into a field and you get an error this usually means your prone to SQL injection. While SQL injection is very dangerous it’s relatively simple to resolve. Now I say its simple but it could mean lots of re-work for you.

I don’t want to talk about how to prevent and cure SQL injection. But, I want to show a solution to this problem. There are already so many great resources out there on how to resolve this issue.

Really the best quick thing you can do is escape all ” and ‘. PHP has a lot of really useful commands to carry out this like mysql_real_escape_string(deprecated) But, probably the biggest thing that can be done is to use PDO(PHP Data Objects).

 

This sample query

$sql = <<<SQL
SELECT * FROM users WHERE users.id = ‘123’;
SQL;

would turn into something like this

$sql = <<<SQL
SELECT * FROM users WHERE users.id = :user_id
SQL;
$sth = $dbh->prepare($sql);
$sth->execute([‘:user_id’ => ‘1234’]);
$results = $stmt->fetchAll(PDO::FETCH_ASSOC)

 

Some useful links:

  • http://php.net/manual/en/security.database.sql-injection.php
  • https://phpdelusions.net/pdo
  • https://www.w3schools.com/sql/sql_injection.asp

testing emails

, ,

Safe Email Testing Solution

As developers or project staff it’s really hard to come up with a clean and safe email testing solution. You never want to send production emails but, really how do you test them.

I’ve recently found this service https://mailtrap.io/. You just add the email settings in your application however you usually would and all emails generated by your system will just display in your dashboard inside mail trap. Please feel free to check out this amazing service https://mailtrap.io/billing/plans

htop

,

Htop is super easy to use

Linux top is very useful in seeing system processes. The only problem is the general layout and commands are not obvious while its open. For those reasons, I like htop (htop – interactive process viewer). It lists many options on the bottom of the screen and you can press the letter h to get more detailed information. Once in the application, you can press f5 to activate tree view or you can press the period key to change the sorting column. I also use the f4 key a lot to activate the search functionality. HTop is definitely a must-have application

 

In a Debian based Linux distro like Ubuntu, Gnome, Kubuntu and plenty more just run this comment below which will install it because htop is not installed by default.

sudo apt install htop -y;

 

Some resources:

Timesaving tips for programming
To save time, lots of people will say they have code repositories where they can easily pop in what they need. That’s not always true or the most functional way to program. I have put together a few things that I use almost daily to help save minutes here and there.

to me, notes could be:

  • searchable
  • be able to track revisions
  • be easy to use

for those reasons, I like to use a self-hosted wiki called DokuWiki, it’s free and powerful with lots of plugins and its super lite and easy to use.

Dokuwiki logo

Software Toolbox, just a few things that I use to help productivity.

phpstorm logo


I have a kind of large toolbox of software and tricks I like to use.
Some software I use A LOT:
  • kruler free on-screen pixel ruler
  • gcolor2 easy on-screen color selector
  • shutter super awesome screenshoting tool
  • PHPStorm as my ide, and a few terminal alias and scripts.

Utilize aliases and scripting when possible.

On my current project, we use Jira, which is great, but all the word we do is in feature branches. The branch name is something like Zach/bug/st-111-i-am-doing-something, and after creating the feature branch we mark the task as in development, assign ourselves, yadda yadda. So, I took an hour and scripted all that stuff. I’m not saving hours at a time by doing that. But, just consider the collective time over years of working on this project, it’ll add up. in my aliases file for my terminal I’ve added a few things that I’ll add below

This file is a little messy but it shows the point:

alias art=”php artisan”
alias codecept=”php vendor/bin/codecept”
# Enable debugger in phpstorm
alias debug=”export XDEBUG_CONFIG=\”idekey=PHPSTORM\””
# copying commands
alias rsync=”rsync -hrltiSmP”
alias dd=”dd status=progress”
alias ai=”sudo apt install -y”
alias au=”sudo apt update”
alias ag=”au && sudo apt dist-upgrade”
alias a=”git add”
alias s=”git status”
alias stat=s
alias d=”git diff”
alias checkout=”git checkout”
alias ..=”cd ..”
alias …=”cd ../..”

Hand travel time

Probably the biggest thing you can do is consider travel time. The distance your Hands move during the workday between your mouse and keyboard. Whether it’s jumping to the mouse or backspace or some other random action. An un-optimized shortcut key like in PHPStorm ctrl alt l, to format text when something like ctrl alt z would be easier for your left hand to quickly reach all the keys.
So, learning and customizing your shortcut keys will probably save you the most time in anything.
After shortcut keys, you’ll need to script what you can. Scripting can include system aliases and quick commands.
Another, for probably most of us, customize your system colors and fonts. The easier you can read code the better. By doing this the system will feel for intuitive and your eyes will be drawn to the different sections of the screen

Reduce backspacing and redundant typing

For all operating systems, you can download system-wide macros. These are even driven events that allow you to tell the computer what to do when you type or do something. Like on my computer I auto replace the lowercase i with a capital one I also replace ~addr with my full address, to show a few basic examples. In coding, you can use this to store common coding fragments or in some cases, you can create most of your code with a few simple keywords

I like to use autokey, but, I’m on Linux for other operating systems you may need to look for a good one. I think for windows you have AutoHotkey

My last and probably biggest tip

Take breaks, your mind needs time to relax and subconsciously process what you’re working on. Sometimes when I’ve tried to fix something for hours the best thing I can do is let the problem sit until the morning and BOOM within minutes I usually get it. It’s like my mind works on the problem all night or something. When you’re tired you tend to make a lot of mistakes you would not normally make. I have worked with a lot of people over the years and nobody(with a VERY few minor exceptions) can work great tired.

So while you are working on a problem subconsciously work on another simpler problem if you can/ have the time or just take a nap!

Good luck, let me know what you do to save some time. I’m always looking for more things to do to optimize my work day

what is the cloud

The cloud just means somebodies elses computer

The cloud is really just a fancy way of saying not my computer. Like Facebook is not hosted on your computer its in the cloud, or in their data warehouse. Cloud software is convenient in so many ways. If the software needs to update we know the computer or server is hosting it and how to support it.

Code View

Linux Rename

,

Rename!

there’s a really cool terminal command called “split” if you have to break up a large CSV file, such as something like a million rows, into separate files with 100k rows in each, you can just run something like
split thefile.csv -d –lines=”100000″
-d uses a numeric file increment instead of letters
from what I can tell this method will remove the file extension but you can use another terminal command called “rename” something like this should do it
rename ‘s/&/.csv’ the file* .

Useful links:

  • http://man7.org/linux/man-pages/man1/rename.1.html
  • https://linux.die.net/man/1/split

Implement dependency injection

Quick notes on implementing dependency injection

 

Most if not all PHP frameworks utilize dependency injection. Its allowing PHP to automate supplying function parameters. In my code example below in the class Test the function test requires the User class to be passed in as a parameter. Maybe you’ll want more things like Route or maybe some kind of Registry object. Having decency injection helps reduce redundant code by instantiating the function everywhere needed.

class user {
   public $id = 1;
}

class Test {
   public static function test( User $user ) {
      return $user->id;
   }
}

Here is a VERY basic example of how to implement PHP reflection.

$controller = Test;
$method = test;
$rm = new \ReflectionMethod($controller, $method);
$parameters = [];
foreach ($rm->getParameters() as $inc => $parameter) {
// Quick example getting the parameters and
// which class that parameter location is looking for
$class_name = $parameter->getType()->getName();
// Instatiate the new class
$parameters[] = new $class_name;
}
//Call the controller and method with the parameters you were expecting
call_user_func_array([$controller, $method], $parameters);

The idea is that PHP will use reflection to look at the method you are trying to call and figure out what parameters are expected. My example is simple, you can do a lot more. The idea is to present in note style form a starting point and to present the idea in a functional way.

 

Here are a few links for reference: