Showing posts with label Developer Tools. Show all posts
Showing posts with label Developer Tools. Show all posts

Tuesday, 24 April 2018

Logger Snippets for VS Code

Snippets are a common feature in text editors, allowing you to essentially paste in a snippet of code from some library somewhere.

Snippets appear for selection as you start typing, and the editor will paste in the entire content of the snippet.

Snippets in VS Code

VS code snippets also have the ability to focus the cursor, ready for typing.

It's very closely related to code completion concepts, applied in VS Code with Intellisense. Vito on Twitter suggested perhaps these should be incorporated into intellisense instead of snippets. I think perhaps that might be a personal choice.

I found following the guide useful in getting started
https://code.visualstudio.com/docs/editor/userdefinedsnippets

And I thought I'd start with the Logger template, since I've finally converted.

I quickly ended up in the deep end, but swimming well. In a few strokes, I can add this entire block of text, with the three instances of the procedure name highlighted, ready to type over. That's pretty cool.


This took 5 keystrokes

I figured a few variations of the entire text would be useful, so now as I type "log", I can tab, then start typing my log text.


 The first few commands at the start of a procedure form another snippet, with the parameter name ready to type.

If I'm going to logger, I'm saving some typing...

I extended this to include two parameters, and as you tab out of the first, the second two 'tabstops' are highlighted.

With all the magic going on by Adrian Png et al, I was a little surprised someone hadn't already published something for Logger.

Find my snippets JSON on Github.

Others on Twitter suggested they might send through a few examples they use, I was going to wait for some more inspiration.

The trickiest bit was escaping the dollar signs for plsql_unit. Thanks Stack Overflow.

Perhaps this set of JSON could be transformed into the Intellisense format. That would make an interesting SQL exercise...

Monday, 23 April 2018

On Switching Code Editors

Ever since I joined the industry, my preferred text editor was TextPad.
It's a solid tool, similar to Notepad++. I probably underutilise it, but I started to see some people to interesting things with more modern editors.

Day-to-day, I work with two monitors, so I've been trialling software literally side-by-side for a while.

With some help from my nearby colleague, I tried a little Sublime (freemium), and that peaked my interest when contemplating the jump. Atom was also emerging at this time, which also had an impressive list of pros & cons. I wanted to give them all a fair go, but it can be tricky when you're busy, you know, programming.

I've ended up using Atom for a number of months now, even after moaning on twitter about it a few times. I wouldn't be surprised if it was over a year. I like the taste it gives for a modern editor, and it really intrigues me how it was built (JavaScript driven), but I think therein lies the downside. It's improved, but it doesn't scale well - for large files, or large lists of files.

Recently I've been hearing mostly good things about Visual Studio Code (free), especially for/by APEX developers, but also from the community in general. The young blood in the 2018 Stack Overflow survey regarded it highly - certainly far more than the 7.2% recorded in 2016.

2018 Stack Overflow Survey - Editors of choice

So I finally thought right, I've got to give VSC a good crack. There's stuff here I need to learn. Stuff that can make me more productive.

I printed a keyboard shortcut cheat sheets, since that's really what's going to make me productive. Luckily, like Toad & SQL Developer, Atom & VSC share a lot of shortcut commands.
And this thought in the back of my mind, perhaps from Editor wizards Adrian Png or Jorge Rimblas, that you should commit to the tool instead of using an extension to bridge shortcut commands.
and I wanted some new wins that would exhibit immediate ROI over the other editors.

I wanted to compile from my editor.

I realise that's what SQL Developer is kinda built for, but we also need dedicated editors for other document types.

I tried making this happen a few times with Atom, but I'm not sure it really liked our network structure.

I got this done in about five minutes with help from Morten.
No hiccups found, and I tweaked it slightly to use a "recent_errors" view I already had defined.

And with the extra time & excitement I had, I had a lot of fun with snippets - which this post was supposed to be about. I think I'm going to like snippets. Something I know Textpad had but I never got going with, but VSC is making the whole experience feel good.

I even find the syntax highlighting pleasing to the eye, so I think this is going to be a welcome transition to VS. Though I haven't played with CSS/JavaScript yet.

Using extension xyz.plsql-language

I understand it shared some framework concepts with Atom, so I'll probably get more familiarity with JSON while I'm at it.

"User Settings" is a place a developer can truly call home. While I yearn for a GUI, I see the advantage & flexibility with this approach. Though I'm sure it could be GUI-fied a little further.

Change default on left, added & overwritten by right.

I know a few actions I still do regularly in TextPad, so we'll see how things go on day two.
- searching across files
- basic macros for repeated text commands, though possible circumvented with the advanced multi-edit mode.
- compare files. I'm not sure why I still do this in TextPad.
- when I just want to see files in white background, with really familiar highlighting.

And with this momentum, I really need to restore my love for SQL*Plus with SQLCL.

If you want some more reading, I also came across a couple of articles that helped validate my experiences, and consider the move:
Switching from VSC to Sublime
Best Text Editor?

Scott

Sunday, 22 February 2015

Twitter as a work tool

Scott Spendolini conducted a little experiment last week, then Jeff Smith & Kellyn Pot'Vin whipped up a little slideshow on the topic.

I thought I'd chime in after some recent experiences were helped along by the use of Twitter, a tool it seems many are underutilising.

Why?

Exhibit A

I had an afternoon of generating JSON with SQL using LISTAGG and I kept facing this issue of being limited by 4000 characters. Knowing I occasionally get feedback from comments on Twitter about SQL, I thought I'd post something passive

Moritz Klein ended up replying, pointing me to a blog post in german by Carsten Czarski that I may have ended up missing with a google search. Utilising that post will be another story, but the fact is within an hour I received a useful response to a simple tweet.

Exhibit B

Trevor: Can we advertise your APEX demo as using APEX 5?
Me: Don't know, I'll ask the product manager
<goes on twitter>
Reply from Joel Kallman:
"I'll ask the Oracle APEX product manager" - can you imagine saying that in 2005? Australia is almost the antipode to the United States...

Exhibit C

All the examples Tobias Arnhold provides here regarding SQL Developer tips. I know there is plenty I don't know about SQL Developer, I scratch the surface as far as what it can really do - yet here is a great way to learn little snippets at a time.

Initial Trepidation

I understand people's hesitation to join yet another social media outlet, I had the inital trepidation considering I only got talked into joining Facebook to play some online poker.

Twitter usage has some distinct levels, my first post about twitter suggested just following certain people by adding them to your RSS feed (long live google reader). You can also secure all your tweets to only those you let follow you, which I did for starters while I tested the waters.

Then I came to realise how useful twitter can be even as just another resource to find information, but I also realised it had a little more potential than that.

Twitter as a Tool

You don't even need to register a twitter account to extract information - it's a public feed. Visiting this URL alone will provide you all the recent posts about APEX
https://twitter.com/search?q=%23orclapex
Visit this URL to peruse tips about SQL Developer at your own leisure.
https://twitter.com/OracleSQLDev

Creating an account will make it easier to use twitter as the apps will help you follow the grain, so to speak. Over time your can build rapport with the community to enable you to harness it further.

As Jeff and Kellyn explained in their slidedeck, you don't need to post statuses to make effective use of twitter, or worry about gaining followers - but it can help.

Critical Mass

In my experience I found once I started contributing more, I gained more followers. I'm sure that's simple internet physics, but I think it helps attain a level of critical mass that turns a status from shouting into a crowded room to something that people will encounter and perhaps give you feedback on (see Exhibit A).

You posts don't need to be about what you ate for breakfast, the deja vu I experienced writing this sentence, or about piece of code you just wrote - though some people do in fact find that interesting.

Thanks to a suggestion from Chris Muir, I started reposting articles I was reading from my RSS feed, often prefixing them with "Reading: ", showing I wasn't necessarily endorsing the article but found it interesting enough to share.

I read a great article once describing the benefits of being a contributor to social media, not just a consumer. In trying to locate it I came across a term for this: prosumer.

Coming back to the critical mass concept, I wonder if that's why some people have trouble working out how to use twitter and "don't get it", particularly if they've been a long time facebook user - it's just a different kettle of fish (aren't English idioms crazy?)

Outcomes

I think I can attribute twitter with a lot of credit when it comes to having my paper accepted at Kscope15. Twitter has helped me build an online network, I've gained rapport with my peers and I've demonstrated who I am beyond what I write in this blog.

Another great advantage is to help find like minded people at conferences. I found Spendolini's comments regarding twitter participation interesting, I've observed the same here in Australia.

A few years ago I attended an APEXposed event in Melbourne. Out of the 50-odd people I found a mere handful tweeting about it. In some respects it was an echo chamber, but you'd be surprised how many people in other countries are interested. I often follow feeds like #apexworld to listen out for special announcements or news.

And I did make a new friend, someone to make banter with during the event, to affirm certain thoughts, to help, to learn from. Imagine if more people did it?

Basic Rules

Before using something for the first time it helps to understand the basic rules, from a programmer's perspective.

First of all it's not case sensitive. Hoo-bloody-ray, it's not related to JavaScript. That being said I find adding the occasional capital helps readability.

Hash tags 

if you've ever encountered instagram, hash tags are an easy way to be a douche and stop people from venturing into twitter. Used effectively they're essentially an index to good information. Take #orclapex, it's the standard hashtag used for all posts relating to APEX. It's an easy way to find information you're after amongst the 500 million tweets per day.

Nobody owns a hash tag and anyone can create one. Sometimes they're done just for humour's sake, in fact I think there is a certain nature to twitter humour that's a little unique, but it could just be me.

@somebody

If a tweet starts with the @ symbol, meaning you're tweeting to somebody in particular - this won't appear in your standard feed unless you follow both people. This means that you don't see every random conversation that might be going on.

Sometimes you might see a reply that starts like this:
". @somebody blah blah"
Sometimes people Prefixing with a period to reply with a particular point to make, but make it so anyone following will see it.

You can also include @somebody at the end of your tweet to clue them in on the conversation, or prefix with "via @somebody" to help direct people to the author of a linked post.

Retweets 

If you retweet something, it will appear on your feed as if you wrote it, but you won't get credit - only for finding what might be an interesting tweet worthy enough of retweeting. It's similar to multiple people sharing the same thing on Facebook.

Interesting nuggets get retweeted. More people see it, it gets retweeted. Come up with some gold and you'll be amazed how far it goes.

Favourites

I think people use favourites in different ways. Some people use them similar to bookmarks, to follow up later. Others use them to help represent who they are when people look at your profile and decide if they want to follow you. A link exists on your profile that shows all your favourite tweets.

Lists

I've tried to allocate each person I follow to a particular list, like filing emails into particular categories. One advantage of this is if you feel like seeing what your Oracle contacts currently have to say, twitter software can list only tweets from that list. If you feel like seeing what's in your science news feed, ditto.

Another advantage it provides is an easy way to find others you might like to follow. I have an "Oracle" list which is actually quite generic to all things technology. I have JavaScript, general programming, HTML, and tech news feeds in my list - anything that might help my career in some form. Feel free to see who's on it.

Other uses

I started using twitter for anything work related, then quickly found it useful for other things. For instance I encountered the hashtag #PerthTraffic to help notify me of any bungles before I drive to work.

I like science stuff, so I started following certain scientists and science educators for interesting information. Phil Plait and @NeilTyson offer great snippets and often "live tweet" astronomical events or scientific achievements like the #Philae lander. See how this works?

In fact twitter is the perfect tool for obtaining information about current events. Want to see photos about flooding in a nearby town? Hop in twitter and you'll get photos from people on the scene.

Open any article from a news website, chances are it includes a bunch of tweets from random citizens. Does this make some journalists even more lazy? This blogger thinks yes.

Everyone also needs a laugh. Plenty of parody accounts exist, and some accounts you have to wonder if it's a 'Poe'.

At the other end of the scale, even Mars landers and other space probes have twitter accounts. You can discover accounts that suit your interest over time, and with the help of critical mass.

Work vs Personal

There appears to be conflicting opinions on this, googling "twitter work vs personal" returns over a billion hits. Jeff & Kellyn's slides suggested to keep it separate. Like his two blogs, Steven Feuerstein created a twitter account for PL/SQL and one for is own ramblings. I respect that and the reasons for it, but I subscribe to the opposite opinion.

I started just using it for Oracle stuff, you know, 'work'. Then I started re-posting tech articles I find, or interesting science stories like a future generation hard drive technology. Then I started having conversations with other people about things they were posting. I was using twitter as a tool to garner information.

Where is the line? I initially had a disclaimer on my profile stating it was my own opinions blah blah and I might post about stuff that wasn't Oracle. I'm me, why should I have to filter my thoughts and uses of twitter into two distinct accounts? How do I decide which account to use if I think a post would be of interest to followers of both accounts? Do I rely on twitter apps to help manage this? What if I post to the wrong account?

I decided not to sanitise my thoughts in that way. I still have boundaries regarding what I post, but my @swesley_perth account represents mostly technology and some outside interests in science and skepticism. I've even drafted a blog post describing a pie chart meme generator using APEX that describes the general distribution of my posts.

People can choose to follow me based on the list of hashtags I have in my profile, and by the tweets I tweet. All work and no play makes Jack Scott a dull boy. I'm human and have other thoughts to share, scroll past if you're not interested ;p

Bullying Kills

There is a golden rule: don't be a bully. Bullying can kill people. It's so easy to type an ad hominem attack towards someone, but you really don't know who's on the other and and what frame of mind they might be in.

This might be a complete divergence from the rest of this post but I feel it's necessary to mention.
Nobody deserves it, and people shouldn't need thick skin just to use the internet. I would like to think it's just a really small percentage of people, but I see it so often.

Block, report, ignore - but that's only the start.

Conclusion

If you're using Oracle technology and want to learn & keep up to date, you shouldn't ignore Twitter, just like you shouldn't ignore forums and blogs.

It's worth the dive, how far you go is up to you.

Wednesday, 26 November 2014

Chrome Device Mode and Mobile Emulation

Recently a colleague suggested I take a fresh look at the mobile emulation button in Chrome's developer tools.

Apparently this was upgraded earlier in the year and it's a shame I didn't have this a year ago!

Chrome Developer Tools Mobile Emulation
Some immediate advantages I see for APEX development:




  • Specify the device you'd like to emulate from a decent range of contemporary devices
    • This viewport can then be easily scaled to suit whatever monitor you're using
  • Apply network throtttling to simulate access on a mobile network
  • Use the emulation tab to define a media type to render as - I've been using 'print' to test how certain pages look when printed
  • The cursor changes, indicating the behaviour will emulate finger touches on a touchscreen
    • touch & drag emulated perfectly - I removed touchpunch from my page and sliders stopped working as expected without jQuery mobile
    • scrolling drifts instead of static desktop movement (happy to improve terminology here)
Full details on how to use these features are available here: developer.chrome.com

Tomomi also has a great write up on the topic.

Nice work Chrome, nice work.