How do I post code snippets?

I spotted some discussion about posting code snippets.  However, even those discussions themselves seem to be incorrectly formatted.  So, perhaps apple has changed it's discussion formatting. 
What's the recommended way to quote code in a discussion?

I know this is old old... but this comes up in google when searching "apple forums code snippets"
I forgot, and managed to figure it out again... the forums are based on Jive forum software, and these use css classes and custom attribute names etc to pre format things like quotes and code snippets.
While there isn't a button to do this in the editor, what you can do instead is use the quote button then go to HTML mode and edit it's classes to change the first part of the tag from this:
<pre class="jive_text_macro jive_macro_quote" jivemacro="quote">
to
<pre class="jive_text_macro jive_macro_code" jivemacro="code">
which changes this:
ls -al /var/log/*.out
sudo periodic daily weekly monthly
to:
ls -al /var/log/*.out
sudo periodic daily weekly monthly
The main difference being forced monospaced font and lack of softwrapping... good for code.

Similar Messages

  • Add code snippets iBooks author

    How can I add code snippets to an iBooks author project?
    Is there a way to format a piece of text so that it would recognize Objective-C language?
    Or is there a way to insert a code snippet in some sort of box that will make it stand out from the rest of the text?

    ...is there a way to insert a code snippet in some sort of box that will make it stand out from the rest of the text?
    Have you tested the new pop-up widget?

  • How do I create a drop down menu with Code Snippets and Flash CS5?

    Hi
    I am wondering how to create a drop down menu using the Code Snippets and CS5?
    There are some older tutorials out there and it would be nice if someone could create an updated drop down menu tutorial, and it might be me doing this after I have figured out the best and easiest way to create one, but before that I need some pointers.
    Thanks!
    Have a great day!
    Paal Joachim

    You can use panel widget to create manual menu where set to show target on rollover.
    Something like this :
    http://muse.adobe.com/exchange-library/menu-vertical-accordion-widget-1
    http://muse.adobe.com/exchange-library/tiptop-navigation-menu
    Thanks,
    Sanjit

  • How do you display code in a forum post

    Hey
    Just a quick question to ask how i display my code on these message boards if im having a problem with them?
    because i can see its not a simple copy and paste
    Thanks

    It's in fact very easy. You can post code and then surround it with code tags. The new code tags look like this:
    &#123;code}
    x=y;
    z=w;
    &#123;code}
    The old code tags look this this:
    [code]
    x=y;
    z=w;
    [[/i]code]
    They work the same. If you don't feel like typing in tags, there is a "code" button right there next to the bold, italics, underline buttons... Just select your code and press the code button.

  • How to notify() the main method in the given code snippet

    consider the given code snippet
    code
    public class WaitTest {
    public static void main(String [] args) {
    System.out.print("1 ") ;
    synchronized(args) {
    System.out.print("2 " ) ;
    try {
    args.wait();
    catch(InterruptedException e){}
    System.out.print("3 ");
    code
    Here since there are no threads to notify the main()method the statement System.out.print("3 "); never gets executed.And i cannot use the non static notify() from a static context.In this case how will I notify the main() method.

    A thread can only do one thing at a time.
    It cannot be waiting and notifying at the same time.
    notify only works if another thread is waiting.
    wait() only stops if another thread notify/notifyAll() it at the same time.

  • How to manually add custom code snippets to Xcode?

    I have a lot of code snippets made for programming. In the past, when I used MS Visual Studio , I could simply add my own snippets , but in Xcode I can't find where to add custom codes.

    See this link.

  • Short code snippet uses a lot of CPU. Suggestions on how to optimize?

    What I want to do is to ping a specified address after a specified delay, and then extract the delay and store it in a comma-separated file (optimally along with a timestamp). I could not find any way to make the delay with the ping command in windows XP, so I created a Timer for the task. The program does the trick, but the CPU usage jumps to about 50% when running the application. I'm kind of new to Java, and don't know all the do's and don'ts of threads and infinite loops. Any suggestion to how to optimize the code would be appreciated.
    package WitelcomMonitor;
    import java.io.*;
    import java.util.Timer;
    import java.util.TimerTask;
    public class WitelcomMonitor {
         Timer timer = new Timer(true);
         int counter;
         public WitelcomMonitor(long delay){
              timer.schedule(new TaskPerformer(), 0, 5000);
         class TaskPerformer extends TimerTask{
              public void run(){
                   try {
                        String line;
                        String[] command = {"ping", "-n","3", "123.12.12.1"};
                        Process p = Runtime.getRuntime().exec(command);
                        boolean append = true;
                        BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
                        PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("delayprofile.txt",append)));
                        String subline;
                        int indexEnd,indexStart;
                        while ((line = input.readLine()) != null) {
                             if(line.contains("TTL")){
                                  counter++;
                                  indexStart = indexEnd = line.indexOf("ms");
                                  do {
                                       indexStart--;     
                                  } while (line.charAt(indexStart)!='=');
                                  subline = line.substring(indexStart+1,indexEnd);
                                  out.print(subline.concat(","));
                                  System.out.println(subline.concat(","));               
                             //System.out.println(counter);
                        input.close();
                        out.close();
                   catch (Exception err) {
                        err.printStackTrace();
         public static void main(String[] args){
              long delay = 5000; //milliseconds     
              new WitelcomMonitor(delay);
              while(true);
    }

    Ok, so the while(true) statement by itself drains the CPU, while by asking the main thread to sleep in ten seconds intervals just to sleep again for ten seconds etc. will keep the load on the computer low. Yeah, it worked so I'm happy. I'm not sure though how I can avoid a new thread, as I have to extend TimerTask which requires that I override the run() method. This in turn causes a thread to be run in addition to the main thread. How do you suggest that I avoid this?

  • Post code in delivery address when creating PO

    Hi friends,
    when creating PO, the post code field under delivery address tab is a required field. while some of our delivery address do not has post code. it seems a mandatory filed.
    How could I change it to a optional field.
    Thanks,
    Linda

    Ask your ABAPer to assist you on this.
    Path to Screen Variant
    Choose Basis Components - Application Personalization - Tailoring of Application Transactions - Configure Transaction-Related Display Values for Fields
    Screen variants allow you to simplify screen editing by:
    Inserting default values in fields
    Hiding and changing the ready for input status of fields
    Hiding and changing the attributes of table control columns
    A screen variant contains field values and attribute for exactly one screen. A screen variant may be assigned to multiple transaction variants, however. Screen variants are always cross-client; they may, however, be assigned to a client-specific transaction. They can also be called at runtime by a program. The different possibilities for calling screen variants guarantee great flexibility of use. A specific namespace has been designated for screen variants and they are automatically attached to the Change and Transport System.
    Check following lInk:
    http://wiki.sdn.sap.com/wiki/display/Snippets/TransactionVariant-AStepbyStepGuidefor+Creation
    Thanks & Regards
    JP

  • Code Snippets in Forums

    Hi,
    I recently tried to anwser to a forums question located at this URL: /message/8930166#8930166 [original link is broken]
    I inserted some code snippets and encountered the problem that I was not able to send my posting to the forums (there occured an error like "Method not implemented: POST to /post.jspa not supported"...
    After some try&error I realized that the problem lies in the mixture of JSP-Scriptlets and Javascript-Code in one code snippet.
    So I placed an "_" behind the javascript-script-Tags which enabled me to send the posting finally.
    This was however very annoying... is this a known problem or is this new?
    EDIT: Also in this posting there is the problem only within the script-tags (without using the forum code-markups).

    Oh, looks like so. But how about just using spaces between the square brackets and your index designator, along these lines:
    int[] array = new int[ 10 ];
    int i = 1;
    array[ i++ ] = 42;
    array[ i ] = 50;That's how I always write my code. Unless the client has some strict coding conventions that dictate otherwise, that is.
    .P.

  • Serial port control -- what's this code snippet?

    Hi, all.
    I've just become active working with LabView, version 6.0i. And this because of a program which "suddenly" stopped working, with no changes made by anyone that I can see (yeah, likely story, right?).
    In short, the screenshot which I'll include with this post is of one tiny code snippet buried deeply in the .vi which runs an X-Z positioning system. I'd like to know what people thing this code snippet does. I have my suspicions, but I can't believe that whoever wrote this code actually used it for this purpose!
    The X- and Z-positioners which I'm using are controlled by separate power sources, and separate ports on the computer. The X-positioner is ultra-fine-resolution, and has an optical encoder. It's controlled by the RS-232 port on the computer, and it's meant to be moved only a little at a time. The Z-positioner is a bit more coarse, and usually moves quite a bit at a time. It's serial-port controlled.
    The screenshot is of the portion of the code called "XMove" -- that portion of the code which controls the x-positioning stepper motor. Often, the Z-positioner is still running during this part of the code (the "ZMove" subroutine is called before the "XMove"), and then, after both parts of the positioner have stopped, the code should shut down the power to them, and update the position of the translation stage.
    However, once the code gets to this portion (screenshot), that while loop just keeps running.
    Here's what I think is happening (please correct me if I'm wrong!): The Z-positioner is run by the serial port, which, as far as I know, can be controlled by only one device at a time. Thus, this While loop does the following:
    1) attempts to write the characters "1R" followed by a linefeed to port 0 (the applicable serial port on this computer);
    2) reads how many characters are stored in the serial buffer;
    3) reads all the characters in the serial buffer;
    4) takes the first two characters from the string read;
    5) compares these two characters to *R;
    6) if the two characters are R, then the loop terminates and the code finishes.
    As far as I can tell (I've probed many parts of this structure), the code fails when the "N" portion passes the number of characters in the serial buffer to the "R" portion -- it's always zero. It appears to me that the "W" portion writes to the buffer AFTER the number of characters is read (I wouldn't have suspected this unless I'd run it many times and monitored which steps were done in which order). This ain't right!
    I found a similar question answered in the KnowledgeBase forum, but the answer to that one was that the serial port may have an "echo" mode. That doesn't change the fact that data is being from to the port before it's written, does it?
    Is there a way to make sure that the "read" statement happens AFTER the "write" statement? Am I way off base with what this code snippet should do? And, most importantly, *** is this a good way to tell if the Z-positioner is done with its job? ***. Is this a standard trick to tell if a program is done with the serial port?
    Thanks, all. I know the quandary of trying to debug with so few details, and not having the program in front of you. Any help is appreciated!
    Sincerely,
    Curtis Osterhoudt
    Attachments:
    VI_diagram.jpg ‏17 KB

    I suspect someone did change it, but they just don't realize they did.
    THe code snippet is an example of some very bad LV code! What you suspect is happeneing is indeed true. LV uses a data dependacy paradigm that says code execution order is dependent on data availablility. Data availability is determined by ythe rule that the output of a node or sub-VI is not available until the object completes.
    In you snipet, the only node that has to complete before the read bytes at port and the write to port VI is the the constant port number constant. That means that LV can execute either the write or the check bytes at port VI's first. This is determined at LV compile time. If for some reason LV decideds to compile in the write before the check bytes at port, the
    n the I/O may work as intended, BUT NOT POROGRAMMED!
    For a quick fix, put the contant port number and the write VI in a single frame sequence structure. This way the read from the constant and wire operation must comlplete before the seq completes, therby forcing the read stuff to wait.
    I hope this help,
    Ben
    Ben Rayner
    Certified LabVIEW Developer
    www.DSAutomation.com
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • How do you post multiple personal domains to .Mac sub accounts?

    I was assured by .Mac tech support that .Mac will host a different personal domain on each of five accounts of a family pak. Now I discover that iWeb is a one-trick pony. I'm stunned that I can't create separate sites and upload them individually. I've never heard of an application that can only create one document!
    And I can't even find the data for that ONE document; ~/Library/Application/Domain.sites2 is only 20kb no matter how many photos you've added to the site.
    So I guess I have two questions: How do you post multiple domains to sub accounts?
    And, where's my data?

    The tilde (~/Library/etc.) indicates home folder; that is where I was looking. I did a Spotlite search and discovered that in attempting to backup my data, I'd moved it; Spotlite found it and it was all intact.
    Then I discovered I could duplicate Domain.sites2, change the names to Domain de.sites2, and Domain daru.sites2, open daru's site and delete de's, then open de's and delete daru's, and I had two separate sites that I presume I'll be able to upload separately. Once I get .Mac sub groups created...
    Seems like a stupid bit of programming; must have hired some windows guys to code it...
    Problem I'm having now is, .Mac won't let me set up a sub account in my wife's name because she already has a .Mac ID and a trial account because she joined a .Mac group. Awaiting a reply rom .Mac tech support.
    So my question isn't quite answered yet, but it does look like I can post several sites without having to set up separate user accounts. Seems like this could be explained in the help file in plain English...

  • How to create transaction code for maintenance view

    hai friends,
    i hope every thing goes good.
    i have doubt, how to create transaction code for maintenance view. I created view for tranperant table and now i want to create transaction code for the view.
    i tried and i donot know the screen number and program name and where can i give the view name.
    if any one know please post in details.
    thanks in advance.

    Hi Elam,
    You need to create a "Parameter Transaction".
    What this means is that you will have a transaction (let's call it "ZMAINT") which calls "SM30" and passes in your table name.
    Go to transaction SE93 and enter your new transaction code. Enter in the Tcode description and choose "Transaction with Parameters" (it shouldbe the last radio button).
    Enter in the default transaction "SM30" and tick the "Skip Initial Screen" check box. Hit Enter.
    Now scroll to the bottom of the screen and you will see a Table Control where you will need to enter in the values to the SM30 selection screen.
    Because you hit ENTER, the program will have loaded in the Selection Screen parameters into it's memory. Hit the drop down for "Name of Screen Field" and select "VIEWNAME" and then enter in your Z Table in the "Value" column.
    Now go to the next line and hit the drop down and select "UPDATE" in the "Name of Screen Field". Enter in a "X" in the value column.
    Now save the transaction and there you have it.
    Hope this helps.
    Cheers,
    Pat.
    PS. Kindly assign Reward Points to the posts you find helpful.

  • OLE2 Doc/Code snippet to assist in creating a word doc with underlined text

    I would like to use OLE2 to create a simple Word document. I would like some of the text to be bold/underlined and the rest of the text to be regular. There seems to be a serious dearth of information regarding OLE2 in conjunction with PS/SQL in Word applications. We're running Forms 6 and Oracle 9i.
    I don't believe that I need to use the techniques described in the Forms Manual (OLE2 containers, etc.). I have managed to create a Word doc and write some text to it but I've been unable to find out/guess at the syntax that I'd need to control bolding and underlining. It would be a big help if I could just find the syntax for Word OLE2 commands. During my documentation search, I seem to remember a post that mentioned 'Reference 2' and maybe 'Reference 3' as a source of information related to OLE2 in PL/SQL code. If anyone can give me a shove in the right direction I'm more than willing to read the manuals. I won't be too disappointed if someone could send me a code snippet either!
    Thanks,
    Ron Walker

    Hi Ron,
    Office ships with a number of resources that you will find indispensable for the sort of work you're doing. Take a look at the VBA IDE (Visual Basic for Applications IDE). You may already be familiar with it, if you've ever written a Word macro, but to call it a macro editor sells it short -- it is a full-blown development environment. Its Object Browser allows you to browse Word's object model, search by keyword, and view call syntax.
    In case you aren't familiar with the VBA IDE, try this:
    1. Open Word
    2. Switch between Word and the VBA IDE by pressing <Alt><F11>
    3. Open the Object Browser by pressing <F2>
    Spend some time familiarizing yourself with the Object Browser. Constrain its scope by selecting the Word library instead of <All Libraries> (the default). Learn to search by keyword. Click on items within your results for details. If Visual Basic Help is installed, pressing <F1> will raise help on a selected item.
    Visual Basic Help may not be part of the Compact or Typical install. Running Office Setup, either from the install CD, or through Add/Remove Programs under Control Panel, will allow you to add the feature. (The Office installer lists Visual Basic Help in the Office Tools section.)
    I have found the VBA IDE to be the perfect place for prototyping and testing automated processes. It is a far friendlier environment for learning Office automation, as it offers code completion and context-driven help. Once the process works, I manually translate my VBA routine into Forms PL/SQL, which is fairly painless. I've written a short tutorial, that I will post shortly -- I didn't want to bury it in this thread!
    Hope this helps,
    Eric Adamson
    Lansing, Michigan

  • ColdFusion 11: cfclient ... how does normal CFML code and cfclient code interact?

    G'day:
    I am reposting this from my blog ("ColdFusion 11: ... how does normal CFML code and  code interact?") at the suggestion of Adobe support:
    @dacCfml @ColdFusion Can you post your queries at http://t.co/8UF4uCajTC for all cfclient and mobile queries.— Anit Kumar Panda (@anitkumar85) April 29, 2014
    I have edited this in places to remove language that will be deemed inappropriate by the censors here. Changes I have made are in [square brackets]. The forums software here has broken some of the styling, but so be it.
    G'day:
    Another quick one. I'm raising these quick-fire questions here because Adobe have declined to suggest a better place to raise them, other than as comments on one of their blog entries. Well that was Ram's suggestion (which I don't think is terribly-well thought out). He declined to react to my suggestion that the Adobe ColdFusion forums might be a good place. Anit suggested Twitter or just emailing him, but I think there'd be public interest in this stuff, so don't want to resort to email.
    As I'm the master of what goes on on this blog: I'll clutter this thing up.
    Say I want to have a mix of "normal" CFML and <cfclient>-based CFML in the same file. I can only presume the intent is to allow this, otherwise having <cfclient> as a tag rather than just a file extension seems like a poor approach. Obviously if one can have a start tag and an end tag, then code can come before (and I guess after) the <cfclient> tags themselves.
    So I'd expect this to work:
    <cfset message = "G'day World"> <cfclient> <cfoutput>#message#</cfoutput> </cfclient>
    However all I get is an error in JS:
    Uncaught ReferenceError: message is not defined variablesScopeVariable.cfm:4
    And, indeed, the only mention of message in the JS source is the one that's erroring (as it's on the right-hand side of an assignment).
    So I thought perhaps <cfclient> worked like <cfthread> and I needed to pass attributes into it:
    <cfset message = "G'day World"> <cfclient message="#message#"> <cfoutput>#message#</cfoutput> </cfclient>
    This doesn't compile:
    Attribute validation error for the client tag.
    The tag does not have an attribute called message. The valid attribute(s) are ''.
    ColdFusion cannot determine the line of the template that caused this error.This is often caused by an error in the exception handling subsystem.
    Note also there's an error in the error message itself. It's not the <client> tag, it's the <cfclient> tag.
    Rightio then, so I tried just using the request scope instead (the code's the same as the variables-scoped example, except using the request scope). No dice: same JS error.
    As a last ditch effort, I just tried to see if <cfclient> was aware of anything going on around it, by passing a value on the URL, and seeing if <cfclient> saw that, eg:
    <cfclient> <cfoutput>#URL.message#</cfoutput> </cfclient>
    This behaved differently from the variables- / request- scoped examples, in that I didn't get a JS error, I just got this on the screen:
    undefined
    And no JS error. It pains me to have to do this, but let's look at the generated JS to see why the behaviour is different:
    Variables scope example:
    <script type="text/javascript" src="/CFIDE/cfclient/cfclient_main.js"></script> <script type="text/javascript" src="/CFIDE/cfclient/cffunctions.js"></script> <meta name="viewport" content="width=device-width"> <script type='text/javascript'> globalDivStruct=null; var _$variablesScopeVariable_func=function(){     var self=this;     var variables={};     self.__init=function(){         var localdivstruct=globalDivStruct;         var __output_var="";         var tmpVarArray={};         localdivstruct.outputvar+=message;        return""     } }; function __startPage__$variablesScopeVariable(){     document.write("\x3cdiv id\x3d'__cfclient_0'\x3e\x3c/div\x3e");     window.ispgbuild=false;     var clientDivStruct={         divId        : "__cfclient_0",         outputvar    :""     };     globalDivStruct=clientDivStruct;     try{         _$variablesScopeVariable=new _$variablesScopeVariable_func;         _$variablesScopeVariable.__init()     }     catch(__eArg){         if(__eArg!=="$$$cfclient_abort$$$")             throw __eArg;     }     __$cf.__flush(clientDivStruct) } __startPage__$variablesScopeVariable(); </script>
    The only significant difference (other than function names, based on the file names) between this and the URL-scoped example is the indicated line above is replaced by this in the URL example:
    localdivstruct.outputvar+=__$cf.__arrayGet(URL,"message",true);
    So it's like it's trying to do the right thing, but just failing. I thought it might be because CF does stupid thinks with scope-key casing, and changed the <cfclient> code to expect URL.MESSAGE not URL.message, but this didn't work either.
    So I'm flummoxed. I can't find anything in any documentation which might point me in the right direction, so anyone know what the story is here?
    Update:At Joel's suggestion I tried this:
    <script> message = "G'day World"; </script> <cfclient> <cfoutput>#message#</cfoutput> </cfclient>
    Thisworked. Which elicits from me a mixture of "heh: cute" and "this is an abomination". 
    Adam

    PaulNibin wrote:
    Hi Adam,
    When you write code inside <cfclient>, it is translated to java script. It cannot access server side variables(defined outside cfclient).
    <script> message = "G'day World"; </script> <cfclient> <cfoutput>#message#</cfoutput> </cfclient>
    The above code works because, message is defined in a script block and client side CFML is interoprable with javascript. So client side CFML can use variables, functions defined in javascript blocks.
    Thanks,
    Paul
    So you're saying you did not provide a mechanism for transferring the variables from the server-side part of a file's code to the client side part? Is this not a bit of an oversight?
    And what - in your mind - is the point of having a file with blocks of both normal CFML, and then a <cfclient> block, then more CFML, then another <cfclient> block (for example) if the code cannot interact?
    Adam

  • EDGE ANIMATE CC (2014) : Missing Code Snippets sidebar - WHY!?!?!

    I just updated today, and now a project I had been working on for weeks (my first real project) won't open in CC anymore. The only reason I wanted to open it back up in CC - NOT Adobe Edge Animate CC (2014), was because this updated Edge Animate IS MISSING THE CODE SNIPPET SIDEBAR!! WHY!! WHY!! WHY!! It's a little hard to follow along with tutorials you have been using when they insert snippets from the sidebar and suddenly you don't have one anymore!
    I have rebuilt permissions and restarted hoping that would fix the issue but it has not. If I can't get this project to pen in CC, can someone tell me how to trick CC into opening it again? Byt he Way -- the old version of Edge Animate was AUTOMATICALLY UNINSTALLED with this update. Also very frustrating!! I had to go to my could menu and download CC (3.0) again.

    OK - Possibly Good News... I talked to Adobe Tech Support. I am able to download a previous version of the Edge Animate CC by choosing PREVIOUS VERSION under the FIND NEW APPS section of the Creative Cloud Desktop app. This is a new feature of CC. Thankfully. I can install CC and then do as hemanth kumar r suggested and edit the _edge.js file to allow 3.0 to open the file.
    Thanks for all of the help. Sorry for the frustration in MY TYPING . I'll reply if that all works.

Maybe you are looking for

  • Multiple copies of email appearing in Apple Mail

    Suddenly I am starting to see multiple copies of an email in me Apple mail client. This seems to have started when I did the software upgrade earlier today - although I have no idea if this is a coincidence, or part of the problem. fyi I am using App

  • How to find the user exit in BOM?

    hi this is ganesh, my requirement is to put the check in bom header level at adminstrative data tab creation on field. so can you expain me the how to exit to header level in BOM.

  • Appraisals - Value list/Rating scales problem

    I assign the rating scale/value list to a template. I face a problem. I have defined a 5 scale rating. Its working fine in R/3 side. But when I go to ESS/MSS, an extra 'Select a Value' comes as default. I do not want this default. Is there any way, I

  • ATP Check in ECC

    Hi, In ECC, can ATP check while creating Sales Order; trigger production if stocks are not present. Will ATP check be able to confirm the dates if stock not available. Also please share what time variables does ATP ceck consider if stock is present (

  • Bought songs from the touch while I was on vacation, wont sync with home PC

    I bought an IPOD while on VACA synced it with another PC but when I go home the ipod says syched with another PC.....I can go to manual mode correct? But wont I lose my songs next time I switch to AUTO mode?