Add a timestamp in brackets editor, maybe using snippets? - adobe-brackets

I would like to be able to insert a current timestamp into a document in brackets using a hotkey, or a menu item or some other menu - for example
Timestamp: '20131009T232028'
would be a good format.
It seems to me that I should be able to do it with the snippets extension, and it even looks to me like that functionality might already be implemented, but not sure how to get the mustache templates in javascript.json to output the correctly formatted date.
Anyone have an example of how to do this?

It doesn't look like that exact format is supported by the Snippets extension, but you can get something like this pretty easily:
timestamp: 9/17/2013 10:09:18 AM
To add this template:
Help > Show Extensions Folder
Navigate to user/jrowny.brackets.snippets/data
Open javascript.json
Add this item:
{
"name": "Timestamp",
"trigger": "t",
"usage": "t",
"description": "Insert timestamp into file",
"template": "timestamp: $${DATETIME}"
}
Restart Brackets
Now you can insert the snippet in any file by typing "t" followed by Ctrl+Alt+V
If you need a very specific date format, you should be able to patch the source code by editing SnippetPresets.js where your extension is installed. (Don't forget to send your improvements back to the original author as a pull request!)

Related

How can I automate data extraction in this website? (can't see query options, if any)

I want to extract election results from this website (currently all data is at zero because voting is ongoing). In the menu you can select the data you want (I need "En Chile" -> "División Geográfica" -> "Comunas"). This is the voting results for each municipality ("comuna"). When you select the desired "comuna", then you can click the excel file and results are downloaded.
The "problem" is that no url is shown along the process. I cannot see the url link to the particular "comuna" I need. I was hoping to get a specific link so then I can automate using wget with the name of each municipality. Instead, the data seems to be masked. I know you can extract JSON data, perhaps using the properties shown in the website's HTML code:
<select class="form-control" id="selComunas" ng-model="comuSelected"
ng-options="item.d for item in comunas" name="comunas"
ng-show="(vistaVertical==='G' || vistaVertical==='E') && subMenu === null"
ng-change="updateComuna()">
<option value="">Comunas...</option>
</select>
But where to make the call? No idea. Also, I see no link to the excel file in the HTML. Stuff seems to be masked inside "ng" elements, which seems to be AngularJS, as far as I can read online. No idea how to proceed. As you can see, I'm noob on this. Any help is more than welcome.
Open chrome dev tools and look for something useful there while clicking on the UI
http://www.servelelecciones.cl/data/elecciones_constitucion/filters/comunas/all.json
This link returns all communas with their ids
[{"c":2564,"d":"ALGARROBO"},{"c":2801,"d":"ALHUE"},{"c":2674,"d":"ALTO BIOBIO"},...
Next thing, when we select value from dropdown, we get another link in network tab. Number in the end matches, isn't it?
http://www.servelelecciones.cl/data/elecciones_constitucion/computo/comunas/2570.json
"d":"Integer",
"e":"Integer",
"f":"Integer",
"sd":null
},
"data":[
{
"a":"Apruebo",
"b":null,
"c":"0",
"d":"0,00%",
"e":null,
"f":"",
"sd":null
},
{
"a":"Rechazo",
"b":null,
"c":"0",
"d":"0,00%",
"e":null,
"f":"",
"sd":null
}
From this point you can process JSON directly by whatever programming language you use

Customize IBM DiffMerge to export a custom Report

I am using IBM DiffMerge to generate a Report that shows all differences between two .cls files or .sbs files. I was playing with it and I saw that there is a filed in option menu that allows you to change the format of the report, but it implies some keywords, like $elemname to print the element's name or $elemtype to print its type $leftonly or $rightonly which show how many differences are in the left diagram or in the right one.
Now, I was wondering if there are more variables like those above, especially one that can print a component's GUID (unique ID in Rhapsody).
Thanks,
Daniel
I would expect that $GUID will give you what you're looking for.
Under the ReporterPlus installation folder there is a folder named Templates. In it you'll find a file named DiffReport.dpl which you can load it into ReporterPlus for editing like any other template. You must run Rep+ with a command line option so that it loads with the Diffmerge specific schema:
Reporter.exe /mode=dfm
After that you can load the Diffmerge template, and edit it to customize the output of DiffMerge reports. When you do, try adding $GUID into the output.
Regards, Simon

How to add timestamp to Atom snippets?

I have been trying to figure out how to add add timestamp to Atom Snippets.
'.text.plain':
'Timestamp':
'prefix': 'isoT'
'body': 'new Date().toISOString()'
This just prints the text and without ' it throws an error.
Is it possible to add javascript to an Atom snippet?
This is not possible. Snippets are stored in a CSON file, which is CoffeeScripts equivalent of JSON.
In all likelyhood, there already exists a package that inserts a timestamp. Otherwise, with knowledge of JavaScript, it's fairly easy to write your own. Take note that all commands provided by a package can be bound to a keystroke.

Add a timestamp and info to a saved CSS/HTML file

Looking for a way to add a custom timestamp(and maybe some extra info) inside a CSS/HTML file everytime you save the file. Is there an extention for brackets, sublime or dreamweaver that does this, Or perhaps some other way to do this?
Thanks
I think this post will give you a Sublime Text plugin that should do what you ask.
In Brackets, you can configure the snippets extension to insert a timestamp manually, like the answer above for Sublime. Here's how: https://stackoverflow.com/a/18844762/1172352.
Similar to the Sublime answer, it would be a bit trickier to do it automatically every time you save. There's not yet a clean hook in Brackets for pre-save processing. Several extensions get around this by listening for a post-save event and saving quickly a second time. You could probably write a timestamp-auto-inserter extension by borrowing their code for that pattern.
Anything that runs automatically would also need a little extra code to find the old timestamp and replace it -- both the snippets solution here and the Sublime solution above just insert the timestamp wherever the cursor/selection is. A regular expression should do the trick for detection.
You'd also want to screen out other file types. Bringing it all together, it would look something like this for Brackets:
function documentSavedHandler(event, doc) {
// TODO: need a little extra code here to ignore save events triggered
// by ourself, to avoid infinite loop
var langId = doc.getLanguage().getId();
if (langId === "html" || langId === "css") {
var pos = /* use regexp to find old timestamp */;
doc.replaceRange(timestampStr, posStart, posEnd);
CommandManager.execute(Commands.FILE_SAVE);
}
}

Aptana changing all <h1> to some snippet?

I'm writing a php file, and whenever I start to type
<h1>
I get this "snippet" of sorts,
//
// aptanavfs254116982902025803overrides.inc
// wordpress
//
// Created by Mike on 2011-08-15.
// Copyright 2011 Mike. All rights reserved.
//
What is this? I guess snippet is the wrong term. Template seems to be the wrong term. Googling doesn't seem to reveal people with this similar problem.
(Using Aptana Studio 3)
EDIT: I've found that it's somehow a shortcut for "Insert Comment Header" but there is still nothing that guides me to a preference to change this.
The "Insert Comment Header" command is actually contributed by the source ruble. It looks like the trigger keyword is "head", so if you start typing 'he' it will show this command as a suggestion. If you would like to remove this, you would need to edit the ruble.
Go to Commands > Source > Edit this ruble, to open the ruble. Then under the commands folder, open the insert_source_header.rb. You can then edi the "cmd.trigger" field to something else so it doesn't get triggered when you type "head".
For more information on editing rubles, you can always go to
http://wiki.appcelerator.org/display/tis/Modifying+an+existing+Ruble
(There should be information there to do more advanced things with rubles)

Resources