Search Results

Search found 252786 results on 10112 pages for 'stack'.

Page 32/10112 | < Previous Page | 28 29 30 31 32 33 34 35 36 37 38 39  | Next Page >

  • How to create a separate thread to do some operation periodically and update UI in WPF?I'm stack

    - by black sensei
    Hello Experts! I'm trying to do a periodic separated thread operation let's say check for internet connection or check for user's info via web service and update the user interface. i've tried with quartz.net to implement that.So i created an inner class for the window i need to update.That inner class does what is meant for but the problem is that i don't know how to access parent's(window class) members form the child(inner class). for example public partial class Window2 : Window { private int i; public Window2() { InitializeComponent(); } public string doMyOperation() { //code here return result; } public class Myclass :IJob { public void Execute(JobExecutionContext context) { string result = doMyOperation(); //Now here i could be able to call a label of name lblNotif //lblNotif.Content = result; } } } Well the whole idea works but i'm stacked at here i need to access a controls of Window2 Since i'm stacked i tried Spring.Net way of implementing Quartz hoping that i could use MethodInvokingJobDetailFactoryObject and rather have the Operation done on Window2 itself.But for some reason i'm having an exception Cannot resolve type [System.Windows.Window2,System.Windows];, could not load type from string value System.Windows.Window2,System.Windows and the wiring is done so <object name="UpdateLabelJob" type="System.Windows.Window2,System.Windows"/> What i'm i doing wrong here?Is that a way round? thanks for reading and for helping out

    Read the article

  • insertvalue function in stack class is not calling when pointing by smartpointer class? please expai

    - by user323422
    template< class Type > class cStack { Type *m_array; int m_Top; int m_Size; public:cStack(); cStack(const Type&); cStack(const cStack<Type> &); bool Is_Full(); bool Is_Empty(); void InsertValue(const Type&); void RemeoveValue(); ~cStack(); }; template< class Type > class Smartpointer { cStack<Type> *sPtr; public: Smartpointer(); Smartpointer(const Type&); Type* operator->(); Type& operator*(); }; int main() { Smartpointer<int> sptr(1); sptr->InsertValue(2);//its not calling insertvalue } }

    Read the article

  • how to set up ubuntu LAMP stack /var/www similar to the xampp htdocs for http://localhost

    - by kimsia
    In xampp, all anyone has to do is to place a folder inside htdocs and http://localhost/folder_name will automatically work. If i set up a LAMP stack using sudo tasksel in ubuntu, how do i do it such that if i put a folder inside /var/www the same thing would happen as in localhost/folder_name would work? update sorry all, i have chosen to do things in a different way hence this question is no longer relevant to me. I apologise. I have awarded upticks to all answers here. Thanks for the suggestion.

    Read the article

  • Why Is Faulty Behaviour In The .NET Framework Not Fixed?

    - by Alois Kraus
    Here is the scenario: You have a Windows Form Application that calls a method via Invoke or BeginInvoke which throws exceptions. Now you want to find out where the error did occur and how the method has been called. Here is the output we do get when we call Begin/EndInvoke or simply Invoke The actual code that was executed was like this:         private void cInvoke_Click(object sender, EventArgs e)         {             InvokingFunction(CallMode.Invoke);         }            [MethodImpl(MethodImplOptions.NoInlining)]         void InvokingFunction(CallMode mode)         {             switch (mode)             {                 case CallMode.Invoke:                     this.Invoke(new MethodInvoker(GenerateError));   The faulting method is called GenerateError which does throw a NotImplementedException exception and wraps it in a NotSupportedException.           [MethodImpl(MethodImplOptions.NoInlining)]         void GenerateError()         {             F1();         }           private void F1()         {             try             {                 F2();             }             catch (Exception ex)             {                 throw new NotSupportedException("Outer Exception", ex);             }         }           private void F2()         {            throw new NotImplementedException("Inner Exception");         } It is clear that the method F2 and F1 did actually throw these exceptions but we do not see them in the call stack. If we directly call the InvokingFunction and catch and print the exception we can find out very easily how we did get into this situation. We see methods F1,F2,GenerateError and InvokingFunction directly in the stack trace and we see that actually two exceptions did occur. Here is for comparison what we get from Invoke/EndInvoke System.NotImplementedException: Inner Exception     StackTrace:    at System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[] args, Boolean synchronous)     at System.Windows.Forms.Control.Invoke(Delegate method, Object[] args)     at WindowsFormsApplication1.AppForm.InvokingFunction(CallMode mode)     at WindowsFormsApplication1.AppForm.cInvoke_Click(Object sender, EventArgs e)     at System.Windows.Forms.Control.OnClick(EventArgs e)     at System.Windows.Forms.Button.OnClick(EventArgs e) The exception message is kept but the stack starts running from our Invoke call and not from the faulting method F2. We have therefore no clue where this exception did occur! The stack starts running at the method MarshaledInvoke because the exception is rethrown with the throw catchedException which resets the stack trace. That is bad but things are even worse because if previously lets say 5 exceptions did occur .NET will return only the first (innermost) exception. That does mean that we do not only loose the original call stack but all other exceptions and all data contained therein as well. It is a pity that MS does know about this and simply closes this issue as not important. Programmers will play a lot more around with threads than before thanks to TPL, PLINQ that do come with .NET 4. Multithreading is hyped quit a lot in the press and everybody wants to use threads. But if the .NET Framework makes it nearly impossible to track down the easiest UI multithreading issue I have a problem with that. The problem has been reported but obviously not been solved. .NET 4 Beta 2 did not have changed that dreaded GetBaseException call in MarshaledInvoke to return only the innermost exception of the complete exception stack. It is really time to fix this. WPF on the other hand does the right thing and wraps the exceptions inside a TargetInvocationException which makes much more sense. But Not everybody uses WPF for its daily work and Windows forms applications will still be used for a long time. Below is the code to repro the issues shown and how the exceptions can be rendered in a meaningful way. The default Exception.ToString implementation generates a hard to interpret stack if several nested exceptions did occur. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Threading; using System.Globalization; using System.Runtime.CompilerServices;   namespace WindowsFormsApplication1 {     public partial class AppForm : Form     {         enum CallMode         {             Direct = 0,             BeginInvoke = 1,             Invoke = 2         };           public AppForm()         {             InitializeComponent();             Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;             Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);         }           void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)         {             cOutput.Text = PrintException(e.Exception, 0, null).ToString();         }           private void cDirectUnhandled_Click(object sender, EventArgs e)         {             InvokingFunction(CallMode.Direct);         }           private void cDirectCall_Click(object sender, EventArgs e)         {             try             {                 InvokingFunction(CallMode.Direct);             }             catch (Exception ex)             {                 cOutput.Text = PrintException(ex, 0, null).ToString();             }         }           private void cInvoke_Click(object sender, EventArgs e)         {             InvokingFunction(CallMode.Invoke);         }           private void cBeginInvokeCall_Click(object sender, EventArgs e)         {             InvokingFunction(CallMode.BeginInvoke);         }           [MethodImpl(MethodImplOptions.NoInlining)]         void InvokingFunction(CallMode mode)         {             switch (mode)             {                 case CallMode.Direct:                     GenerateError();                     break;                 case CallMode.Invoke:                     this.Invoke(new MethodInvoker(GenerateError));                     break;                 case CallMode.BeginInvoke:                     IAsyncResult res = this.BeginInvoke(new MethodInvoker(GenerateError));                     this.EndInvoke(res);                     break;             }         }           [MethodImpl(MethodImplOptions.NoInlining)]         void GenerateError()         {             F1();         }           private void F1()         {             try             {                 F2();             }             catch (Exception ex)             {                 throw new NotSupportedException("Outer Exception", ex);             }         }           private void F2()         {            throw new NotImplementedException("Inner Exception");         }           StringBuilder PrintException(Exception ex, int identLevel, StringBuilder sb)         {             StringBuilder builtStr = sb;             if( builtStr == null )                 builtStr = new StringBuilder();               if( ex == null )                 return builtStr;                 WriteLine(builtStr, String.Format("{0}: {1}", ex.GetType().FullName, ex.Message), identLevel);             WriteLine(builtStr, String.Format("StackTrace: {0}", ShortenStack(ex.StackTrace)), identLevel + 1);             builtStr.AppendLine();               return PrintException(ex.InnerException, ++identLevel, builtStr);         }               void WriteLine(StringBuilder sb, string msg, int identLevel)         {             foreach (string trimmedLine in SplitToLines(msg)                                            .Select( (line) => line.Trim()) )             {                 for (int i = 0; i < identLevel; i++)                     sb.Append('\t');                 sb.Append(trimmedLine);                 sb.AppendLine();             }         }           string ShortenStack(string stack)         {             int nonAppFrames = 0;             // Skip stack frames not part of our app but include two foreign frames and skip the rest             // If our stack frame is encountered reset counter to 0             return SplitToLines(stack)                               .Where((line) =>                               {                                   nonAppFrames = line.Contains("WindowsFormsApplication1") ? 0 : nonAppFrames + 1;                                   return nonAppFrames < 3;                               })                              .Select((line) => line)                              .Aggregate("", (current, line) => current + line + Environment.NewLine);         }           static char[] NewLines = Environment.NewLine.ToCharArray();         string[] SplitToLines(string str)         {             return str.Split(NewLines, StringSplitOptions.RemoveEmptyEntries);         }     } }

    Read the article

  • Exception Handling Differences Between 32/64 Bit

    - by Alois Kraus
    I do quite a bit of debugging .NET applications but from time to time I see things that are impossible (at a first look). I may ask you dear reader what your mental exception handling model is. Exception handling is easy after all right? Lets suppose the following code:         private void F1(object sender, EventArgs e)         {             try             {                 F2();             }             catch (Exception ex)             {                 throw new Exception("even worse Exception");             }           }           private void F2()         {             try             {                 F3();             }             finally             {                 throw new Exception("other exception");             }         }           private void F3()         {             throw new NotImplementedException();         }   What will the call stack look like when you break into the catch(Exception) clause in Windbg (32 and 64 bit on .NET 3.5 SP1)? The mental model I have is that when an exception is thrown the stack frames are unwound until the catch handler can execute. An exception does propagate the call chain upwards.   So when F3 does throw an exception the control flow will resume at the finally handler in F2 which does throw another exception hiding the original one (that is nasty) and then the new Exception will be catched in F1 where the catch handler is executed. So we should see in the catch handler in F1 as call stack only the F1 stack frame right? Well lets try it out in Windbg. For this I created a simple Windows Forms application with one button which does execute the F1 method in its click handler. When you compile the application for 64 bit and the catch handler is reached you will find with the following commands in Windbg   Load sos extension from the same path where mscorwks was loaded in the current process .loadby sos mscorwks   Beak on clr exceptions sxe clr   Continue execution g   Dump mixed call stack container C++  and .NET Stacks interleaved 0:000> !DumpStack OS Thread Id: 0x1d8 (0) Child-SP         RetAddr          Call Site 00000000002c88c0 000007fefa68f0bd KERNELBASE!RaiseException+0x39 00000000002c8990 000007fefac42ed0 mscorwks!RaiseTheExceptionInternalOnly+0x295 00000000002c8a60 000007ff005dd7f4 mscorwks!JIT_Throw+0x130 00000000002c8c10 000007fefa6942e1 WindowsFormsApplication1!WindowsFormsApplication1.Form1.F1(System.Object, System.EventArgs)+0xb4 00000000002c8c60 000007fefa661012 mscorwks!ExceptionTracker::CallHandler+0x145 00000000002c8d60 000007fefa711a72 mscorwks!ExceptionTracker::CallCatchHandler+0x9e 00000000002c8df0 0000000077b055cd mscorwks!ProcessCLRException+0x25e 00000000002c8e90 0000000077ae55f8 ntdll!RtlpExecuteHandlerForUnwind+0xd 00000000002c8ec0 000007fefa637c1a ntdll!RtlUnwindEx+0x539 00000000002c9560 000007fefa711a21 mscorwks!ClrUnwindEx+0x36 00000000002c9a70 0000000077b0554d mscorwks!ProcessCLRException+0x20d 00000000002c9b10 0000000077ae5d1c ntdll!RtlpExecuteHandlerForException+0xd 00000000002c9b40 0000000077b1fe48 ntdll!RtlDispatchException+0x3cb 00000000002ca220 000007fefdaeaa7d ntdll!KiUserExceptionDispatcher+0x2e 00000000002ca7e0 000007fefa68f0bd KERNELBASE!RaiseException+0x39 00000000002ca8b0 000007fefac42ed0 mscorwks!RaiseTheExceptionInternalOnly+0x295 00000000002ca980 000007ff005dd8df mscorwks!JIT_Throw+0x130 00000000002cab30 000007fefa6942e1 WindowsFormsApplication1!WindowsFormsApplication1.Form1.F2()+0x9f 00000000002cab80 000007fefa71b5b3 mscorwks!ExceptionTracker::CallHandler+0x145 00000000002cac80 000007fefa70dcd0 mscorwks!ExceptionTracker::ProcessManagedCallFrame+0x683 00000000002caed0 000007fefa7119af mscorwks!ExceptionTracker::ProcessOSExceptionNotification+0x430 00000000002cbd90 0000000077b055cd mscorwks!ProcessCLRException+0x19b 00000000002cbe30 0000000077ae55f8 ntdll!RtlpExecuteHandlerForUnwind+0xd 00000000002cbe60 000007fefa637c1a ntdll!RtlUnwindEx+0x539 00000000002cc500 000007fefa711a21 mscorwks!ClrUnwindEx+0x36 00000000002cca10 0000000077b0554d mscorwks!ProcessCLRException+0x20d 00000000002ccab0 0000000077ae5d1c ntdll!RtlpExecuteHandlerForException+0xd 00000000002ccae0 0000000077b1fe48 ntdll!RtlDispatchException+0x3cb 00000000002cd1c0 000007fefdaeaa7d ntdll!KiUserExceptionDispatcher+0x2e 00000000002cd780 000007fefa68f0bd KERNELBASE!RaiseException+0x39 00000000002cd850 000007fefac42ed0 mscorwks!RaiseTheExceptionInternalOnly+0x295 00000000002cd920 000007ff005dd968 mscorwks!JIT_Throw+0x130 00000000002cdad0 000007ff005dd875 WindowsFormsApplication1!WindowsFormsApplication1.Form1.F3()+0x48 00000000002cdb10 000007ff005dd786 WindowsFormsApplication1!WindowsFormsApplication1.Form1.F2()+0x35 00000000002cdb60 000007ff005dbe6a WindowsFormsApplication1!WindowsFormsApplication1.Form1.F1(System.Object, System.EventArgs)+0x46 00000000002cdbc0 000007ff005dd452 System_Windows_Forms!System.Windows.Forms.Control.OnClick(System.EventArgs)+0x5a   Hm okaaay. I see my method F1 two times in this call stack. Looks like we did get some recursion bug. But that can´t be given the obvious code above. Let´s try the same thing in a 32 bit process.  0:000> !DumpStack OS Thread Id: 0x33e4 (0) Current frame: KERNELBASE!RaiseException+0x58 ChildEBP RetAddr  Caller,Callee 0028ed38 767db727 KERNELBASE!RaiseException+0x58, calling ntdll!RtlRaiseException 0028ed4c 68b9008c mscorwks!Binder::RawGetClass+0x20, calling mscorwks!Module::LookupTypeDef 0028ed5c 68b904ff mscorwks!Binder::IsClass+0x23, calling mscorwks!Binder::RawGetClass 0028ed68 68bfb96f mscorwks!Binder::IsException+0x14, calling mscorwks!Binder::IsClass 0028ed78 68bfb996 mscorwks!IsExceptionOfType+0x23, calling mscorwks!Binder::IsException 0028ed80 68bfbb1c mscorwks!RaiseTheExceptionInternalOnly+0x2a8, calling KERNEL32!RaiseExceptionStub 0028eda8 68ba0713 mscorwks!Module::ResolveStringRef+0xe0, calling mscorwks!BaseDomain::GetStringObjRefPtrFromUnicodeString 0028edc8 68b91e8d mscorwks!SetObjectReferenceUnchecked+0x19 0028ede0 68c8e910 mscorwks!JIT_Throw+0xfc, calling mscorwks!RaiseTheExceptionInternalOnly 0028ee44 68c8e734 mscorwks!JIT_StrCns+0x22, calling mscorwks!LazyMachStateCaptureState 0028ee54 68c8e865 mscorwks!JIT_Throw+0x1e, calling mscorwks!LazyMachStateCaptureState 0028eea4 02ffaecd (MethodDesc 0x7af08c +0x7d WindowsFormsApplication1.Form1.F1(System.Object, System.EventArgs)), calling mscorwks!JIT_Throw 0028eeec 02ffaf19 (MethodDesc 0x7af098 +0x29 WindowsFormsApplication1.Form1.F2()), calling 06370634 0028ef58 02ffae37 (MethodDesc 0x7a7bb0 +0x4f System.Windows.Forms.Control.OnClick(System.EventArgs))   That does look more familar. The call stack has been unwound and we do see only some frames into the history where the debugger was smart enough to find out that we have called F2 from F1. The exception handling on 64 bit systems does work quite differently which seems to have the nice property to remember the called methods not only during the first pass of exception filter clauses (during first pass all catch handler are called if they are going to catch the exception which is about to be thrown)  but also when the actual stack unwind has taken place. This makes it possible to follow not only the call stack right at the moment but also to look into the “history” of the catch/finally clauses. In a 64 bit process you only need to look at the ExceptionTracker to find out if a catch or finally handler was called. The two frames ProcessManagedCallFrame/CallHandler does indicate a finally clause whereas CallCatchHandler/CallHandler indicates a catch clause. That was a interesting one. Oh and by the way if you manage to load the Microsoft symbols you can also find out the hidden exception which. When you encounter in the call stack a line 0016eb34 75b79617 KERNELBASE!RaiseException+0x58 ====> Exception Code e0434f4d cxr@16e850 exr@16e838 Then it is a good idea to execute .exr 16e838 !analyze –v to find out more. In the managed world it is even easier since we can dump the objects allocated on the stack which have not yet been garbage collected to look at former method parameters. The command !dso which is the abbreviation for dump stack objects will give you 0:000> !dso OS Thread Id: 0x46c (0) ESP/REG  Object   Name 0016dd4c 020737f0 System.Exception 0016dd98 020737f0 System.Exception 0016dda8 01f5c6cc System.Windows.Forms.Button 0016ddac 01f5d2b8 System.EventHandler 0016ddb0 02071744 System.Windows.Forms.MouseEventArgs 0016ddc0 01f5d2b8 System.EventHandler 0016ddcc 01f5c6cc System.Windows.Forms.Button 0016dddc 020737f0 System.Exception 0016dde4 01f5d2b8 System.EventHandler 0016ddec 02071744 System.Windows.Forms.MouseEventArgs 0016de40 020737f0 System.Exception 0016de80 02071744 System.Windows.Forms.MouseEventArgs 0016de8c 01f5d2b8 System.EventHandler 0016de90 01f5c6cc System.Windows.Forms.Button 0016df10 02073784 System.SByte[] 0016df5c 02073684 System.NotImplementedException 0016e2a0 02073684 System.NotImplementedException 0016e2e8 01ed69f4 System.Resources.ResourceManager From there it is easy to do 0:000> !pe 02073684 Exception object: 02073684 Exception type: System.NotImplementedException Message: Die Methode oder der Vorgang sind nicht implementiert. InnerException: <none> StackTrace (generated):     SP       IP       Function     0016ECB0 006904AD WindowsFormsApplication2!WindowsFormsApplication2.Form1.F3()+0x35     0016ECC0 00690411 WindowsFormsApplication2!WindowsFormsApplication2.Form1.F2()+0x29     0016ECF0 0069038F WindowsFormsApplication2!WindowsFormsApplication2.Form1.F1(System.Object, System.EventArgs)+0x3f StackTraceString: <none> HResult: 80004001 to see the former exception. That´s all for today.

    Read the article

  • Trying to run Soldier of fortune 2 on ubuntu 12.04 64 using wine 1.4

    - by Fyksen
    Im trying to run SoF 2 multiplayer in ubuntu 12.04. If I run in terminal I get this output: fyksen@fyksen-skole:~/Nedlastinger/SOF2_FULL på gunnar (gunnar)$ wine SoF2MP.exe fixme:thread:NtQueryInformationThread Cannot get kerneltime or usertime of other threads err:seh:setup_exception_record stack overflow 1916 bytes in thread 0009 eip 7bc3e41f esp 01270bb4 stack 0x1270000-0x1271000-0x1a70000 It seems like it's the: "err:seh:setup_exception_record stack overflow 1916 bytes in thread 0009 eip 7bc3e41f esp 01270bb4 stack 0x1270000-0x1271000-0x1a70000" I google it but i couldn't find any solution

    Read the article

  • Bukkit inventory saving: crashing somewhere

    - by HcgRandon
    I'm working on a command for a bukkit plugin that lets you transfer worlds. In the section about saving the player's inventory, I'm getting a runtime error. My question is: Why is the error happening, and how can I prevent it? The plugin code public void savePlayerInv(Player p, World w){ File playerInvConfigFile = new File(plugin.getDataFolder() + File.separator + "players" + File.separator + p.getName(), "inventory.yml"); FileConfiguration pInv = YamlConfiguration.loadConfiguration(playerInvConfigFile); PlayerInventory inv = p.getInventory(); int i = 0; for (ItemStack stack : inv.getContents()) { //increment integer i++; String startInventory = w.getName() + ".inv." + Integer.toString(i); //save inv pInv.set(startInventory + ".amount", stack.getAmount()); pInv.set(startInventory + ".durability", Short.toString(stack.getDurability())); pInv.set(startInventory + ".type", stack.getTypeId()); //pInv.set(startInventory + ".enchantment", stack.getEnchantments()); //TODO add enchant saveing } i = 0; for (ItemStack armor : inv.getArmorContents()){ i++; String startArmor = w.getName() + ".armor." + Integer.toString(i); //save armor pInv.set(startArmor + ".amount", armor.getAmount()); pInv.set(startArmor + ".durability", armor.getDurability()); pInv.set(startArmor + ".type", armor.getTypeId()); //pInv.set(startArmor + ".enchantment", armor.getEnchantments()); } //save exp if (p.getExp() != 0) { pInv.set(w.getName() + ".exp", p.getExp()); } } The offending line The stack trace complains about line 130, which is this line. pInv.set(startInventory + ".amount", stack.getAmount()); The stack trace 2012-03-21 13:23:25 [SEVERE] null org.bukkit.command.CommandException: Unhandled exception executing command 'wtp' in plugin Needs v1.0 at org.bukkit.command.PluginCommand.execute(PluginCommand.java:42) at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:166) at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:461) at net.minecraft.server.NetServerHandler.handleCommand(NetServerHandler.java:818) at net.minecraft.server.NetServerHandler.chat(NetServerHandler.java:778) at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:761) at net.minecraft.server.Packet3Chat.handle(Packet3Chat.java:33) at net.minecraft.server.NetworkManager.b(NetworkManager.java:229) at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:112) at net.minecraft.server.NetworkListenThread.a(NetworkListenThread.java:78) at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:554) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:452) at net.minecraft.server.ThreadServerApplication.run(SourceFile:490) Caused by: java.lang.NullPointerException at com.devoverflow.improved.needs.commands.CommandWorldtp.savePlayerInv(CommandWorldtp.java:130) at com.devoverflow.improved.needs.commands.CommandWorldtp.onCommand(CommandWorldtp.java:60) at org.bukkit.command.PluginCommand.execute(PluginCommand.java:40) ... 12 more

    Read the article

  • Passing data between objects in Chain of Responsibility pattern

    - by AbrahamJP
    While implementing the Chain of Responsibility pattern, i came across a dilemma om how to pass data between objects in the chain. The datatypes passed between object in the chain can differ for each object. As a temporary fix I had created a Static class containing a stack where each object in the chain can push the results to the stack while the next object in the chain could pop the results from the stack. Here is a sample code on what I had implemented. public interface IHandler { void Process(); } public static class StackManager { public static Stack DataStack = new Stack(); } //This class doesn't require any input to operate public class OpsA : IHandler { public IHandler Successor {get; set; } public void Process() { //Do some processing, store the result into Stack var ProcessedData = DoSomeOperation(); StackManager.DataStack.Push(ProcessedData); if(Successor != null) Successor(); } } //This class require input data to operate upon public class OpsB : IHandler { public IHandler Successor {get; set; } public void Process() { //Retrieve the results from the previous Operation var InputData = StackManager.DataStack.Pop(); //Do some processing, store the result into Stack var NewProcessedData = DoMoreProcessing(InputData); StackManager.DataStack.Push(NewProcessedData); if(Successor != null) Successor(); } } public class ChainOfResponsibilityPattern { public void Process() { IHandler ProcessA = new OpsA(); IHandler ProcessB = new OpsB(); ProcessA.Successor = ProcessB; ProcessA.Process(); } } Please help me to find a better approach to pass data between handlers objects in the chain.

    Read the article

  • What's the lowest cost, legal, Microsoft server stack you can assemble?

    - by McKAMEY
    Assuming that you have an app infrastructure that generally only requires: ASP.NET MVC / C# / .NET Database or NoSQL data store (must be accessible from C#) Here's the challenge to you server gods: What is the least expensive configuration that will allow you to deploy to production in a way that doesn't break any licensing rules? In what ways does this solution differ from the "standard" Microsoft deployment scenario? Where does this solution's performance break down once the app begins to scale? I'm not concerned about the hardware, only the server software itself. I would love to hear about any solutions you've personally put into production. Especially if they are unique alternatives. For ideas, consider some of the possible variations, a) any Microsoft server solutions where they have lowered the barrier to entry to compete with OSS, or b) any OSS alternatives to Microsoft products which perform at a similar level. An example of a): SQL Server 2008 Express Edition SP1 is a 100% free version of SQL Server which will scale to the needs of many smaller / early stage applications. An example of b): running the Mono Framework on Linux. An example of differing from the "standard" stack: running Mono on Linux will require a completely different server OS familiarity. None of the Windows-based knowledge really transfers. An example of breaking down under scale: SQL Server Express will only scale to 1GB of memory and 4GB of disk storage. After that point, the application will need to move to one of the paid versions of SQL Server.

    Read the article

  • Building a Web proxy to get around same-origin restrictions for collaborative Webapp based on a MEAN stack

    - by Lew Cohen
    Can anyone point to books, articles, blogs, or even applications - open-source or proprietary - that detail building a Web proxy? This specific proxy will exist to get around the same-origin restrictions that prevent, for instance, loading a given Website into an <iframe> in a Webapp. This Webapp is a collaborative application in which a group of users log in to the app's Website and can then load different Websites into this app's <iframe> and do various collaborative things (e.g., several users simultaneously browsing a Website, in synch). The Webapp itself is built on a MEAN stack (MongoDB, Express, AngularJS, and Node.js). The purpose of this proxy is not to do anonymous browsing or to bypass censorship. Information on how to build such a vehicle seems not to be readily available from my research. I've come across Glype but am not sure whether this is a feasible solution. I don't want to reinvent the wheel, so if a product is available for purchase, great. Else, we'd need to build one. The one that seems to be close is http://www.corsproxy.com. In effect, we'd like to re-create this since it evidently does what's needed. I don't care what server-side technology is used. Our app is MEAN-based, if that has any bearing. Also, the proxy has to obviously honor basic security considerations (user cookies, etc.) and eventually be scalable. So, anyone know of any sources that would detail how to build one of these? Is it even worth building if something already exists? If so, what would be a good candidate? Any other issues that should be considered with this proxy/application? Thanks a lot!

    Read the article

  • performing simple buffer overflow on Mac os 10.6

    - by REALFREE
    I'm trying to learn about stack base overflow and write a simple code to exploit stack. But somehow it doesn't work at all but showing only Abort trap on my machine (mac os leopard) I guess Mac os treats overflow differently, it won't allow me to overwrite memory through c code. for example, strcpy(buffer, input) // lets say char buffer[6] but input is 7 bytes on Linux machine, this code successfully overwrite next stack, but prevented on mac os (Abort trap) Anyone know how to perform a simple stack-base overflow on mac machine?

    Read the article

  • System.InvalidOperationException in Output Window

    - by user318068
    I constantly get the following message in my output/debug windows. The app doesn't crash but I was wondering what the deal with it is: A first chance exception of type 'System.InvalidOperationException' occurred in System.dll my code :sol.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Sol { public LinkedList<int> tower1 = new LinkedList<int>(); public LinkedList<int> tower2 = new LinkedList<int>(); public LinkedList<int> tower3 = new LinkedList<int>(); public static LinkedList<string> BFS = new LinkedList<string>(); public static LinkedList<string> DFS = new LinkedList<string>(); public static LinkedList<string> IDS = new LinkedList<string>(); public int depth; public LinkedList<Sol> neighbors; public Sol() { } public Sol(LinkedList<int> tower1, LinkedList<int> tower2, LinkedList<int> tower3) { this.tower1 = tower1; this.tower2 = tower2; this.tower3 = tower3; neighbors = new LinkedList<Sol>(); } public virtual void getneighbors() { Sol temp = this.copy(); Sol neighbor1 = this.copy(); Sol neighbor2 = this.copy(); Sol neighbor3 = this.copy(); Sol neighbor4 = this.copy(); Sol neighbor5 = this.copy(); Sol neighbor6 = this.copy(); if (temp.tower1.Count != 0) { if (neighbor1.tower2.Count != 0) { if (neighbor1.tower1.First.Value < neighbor1.tower2.First.Value) { neighbor1.tower2.AddFirst(neighbor1.tower1.First); neighbor1.tower1.RemoveFirst(); neighbors.AddLast(neighbor1); } } else { neighbor1.tower2.AddFirst(neighbor1.tower1.First); neighbor1.tower1.RemoveFirst(); neighbors.AddLast(neighbor1); } if (neighbor2.tower3.Count != 0) { if (neighbor2.tower1.First.Value < neighbor2.tower3.First.Value) { neighbor2.tower3.AddFirst(neighbor2.tower1.First); neighbor2.tower1.RemoveFirst(); neighbors.AddLast(neighbor2); } } else { neighbor2.tower3.AddFirst(neighbor2.tower1.First); neighbor2.tower1.RemoveFirst(); neighbors.AddLast(neighbor2); } } //------------- if (temp.tower2.Count != 0) { if (neighbor3.tower1.Count != 0) { if (neighbor3.tower2.First.Value < neighbor3.tower1.First.Value) { neighbor3.tower1.AddFirst(neighbor3.tower2.First); neighbor3.tower2.RemoveFirst(); neighbors.AddLast(neighbor3); } } else { neighbor3.tower1.AddFirst(neighbor3.tower2.First); neighbor3.tower2.RemoveFirst(); neighbors.AddLast(neighbor3); } if (neighbor4.tower3.Count != 0) { if (neighbor4.tower2.First.Value < neighbor4.tower3.First.Value) { neighbor4.tower3.AddFirst(neighbor4.tower2.First); neighbor4.tower2.RemoveFirst(); neighbors.AddLast(neighbor4); } } else { neighbor4.tower3.AddFirst(neighbor4.tower2.First); neighbor4.tower2.RemoveFirst(); neighbors.AddLast(neighbor4); } } //------------------------ if (temp.tower3.Count() != 0) { if (neighbor5.tower1.Count() != 0) { if (neighbor5.tower3.ElementAtOrDefault(0) < neighbor5.tower1.ElementAtOrDefault(0)) { neighbor5.tower1.AddFirst(neighbor5.tower3.First); neighbor5.tower3.RemoveFirst(); neighbors.AddLast(neighbor5); } } else { neighbor5.tower1.AddFirst(neighbor5.tower3.First); neighbor5.tower3.RemoveFirst(); neighbors.AddLast(neighbor5); } if (neighbor6.tower2.Count() != 0) { if (neighbor6.tower3.ElementAtOrDefault(0) < neighbor6.tower2.ElementAtOrDefault(0)) { neighbor6.tower2.AddFirst(neighbor6.tower3.First); neighbor6.tower3.RemoveFirst(); neighbors.AddLast(neighbor6); } } else { neighbor6.tower2.AddFirst(neighbor6.tower3.First); neighbor6.tower3.RemoveFirst(); neighbors.AddLast(neighbor6); } } } public override string ToString() { string str; str = "tower1" + tower1.ToString() + " tower2" + tower2.ToString() + " tower3" + tower3.ToString(); return str; } public Sol copy() { Sol So; LinkedList<int> l1 = new LinkedList<int>(); LinkedList<int> l2 = new LinkedList<int>(); LinkedList<int> l3 = new LinkedList<int>(); for (int i = 0; i <= this.tower1.Count() - 1; i++) { l1.AddLast(tower1.ElementAt(i)); } for (int i = 0; i <= this.tower2.Count - 1; i++) { l2.AddLast(tower2.ElementAt(i)); } for (int i = 0; i <= this.tower3.Count - 1; i++) { l3.AddLast(tower3.ElementAt(i)); } So = new Sol(l1, l2, l3); return So; } public bool Equals(Sol sol) { if (this.tower1.Equals(sol.tower1) & this.tower2.Equals(sol.tower2) & this.tower3.Equals(sol.tower3)) return true; return false; } public virtual bool containedin(Stack<Sol> vec) { bool found = false; for (int i = 0; i <= vec.Count - 1; i++) { if (vec.ElementAt(i).tower1.Equals(this.tower1) && vec.ElementAt(i).tower2.Equals(this.tower2) && vec.ElementAt(i).tower3.Equals(this.tower3)) { found = true; break; } } return found; } public virtual bool breadthFirst(Sol start, Sol goal) { Stack<Sol> nextStack = new Stack<Sol>(); Stack<Sol> traversed = new Stack<Sol>(); bool found = false; start.depth = 0; nextStack.Push(start); while (nextStack.Count != 0) { Sol sol = nextStack.Pop(); BFS.AddFirst("poped State:" + sol.ToString() + "level " + sol.depth); traversed.Push(sol); if (sol.Equals(goal)) { found = true; BFS.AddFirst("Goal:" + sol.ToString()); break; } else { sol.getneighbors(); foreach (Sol neighbor in sol.neighbors) { if (!neighbor.containedin(traversed) && !neighbor.containedin(nextStack)) { neighbor.depth = (sol.depth + 1); nextStack.Push(neighbor); } } } } return found; } public virtual bool depthFirst(Sol start, Sol goal) { Stack<Sol> nextStack = new Stack<Sol>(); Stack<Sol> traversed = new Stack<Sol>(); bool found = false; start.depth = 0; nextStack.Push(start); while (nextStack.Count != 0) { //Dequeue next State for comparison //And add it 2 list of traversed States Sol sol = nextStack.Pop(); DFS.AddFirst("poped State:" + sol.ToString() + "level " + sol.depth); traversed.Push(sol); if (sol.Equals(goal)) { found = true; DFS.AddFirst("Goal:" + sol.ToString()); break; } else { sol.getneighbors(); foreach (Sol neighbor in sol.neighbors) { if (!neighbor.containedin(traversed) && !neighbor.containedin(nextStack)) { neighbor.depth = sol.depth + 1; nextStack.Push(neighbor); } } } } return found; } public virtual bool iterativedeepening(Sol start, Sol goal) { bool found = false; for (int level = 0; ; level++) { Stack<Sol> nextStack = new Stack<Sol>(); Stack<Sol> traversed = new Stack<Sol>(); start.depth = 0; nextStack.Push(start); while (nextStack.Count != 0) { Sol sol = nextStack.Pop(); IDS.AddFirst("poped State:" + sol.ToString() + "Level" + sol.depth); traversed.Push(sol); if (sol.Equals(goal)) { found = true; IDS.AddFirst("Goal:" + sol.ToString()); break; } else if (sol.depth < level) { sol.getneighbors(); foreach (Sol neighbor in sol.neighbors) { if (!neighbor.containedin(traversed) && !neighbor.containedin(nextStack)) { neighbor.depth = sol.depth + 1; nextStack.Push(neighbor); } //end if } //end for each } //end else if } // end while if (found == true) break; } // end for return found; } } } Just wondering if I may be doing something wrong somewhere or something.

    Read the article

  • Event Logging in LINQ C# .NET

    The first thing you'll want to do before using this code is to create a table in your database called TableHistory: CREATE TABLE [dbo].[TableHistory] (     [TableHistoryID] [int] IDENTITY NOT NULL ,     [TableName] [varchar] (50) NOT NULL ,     [Key1] [varchar] (50) NOT NULL ,     [Key2] [varchar] (50) NULL ,     [Key3] [varchar] (50) NULL ,     [Key4] [varchar] (50) NULL ,     [Key5] [varchar] (50) NULL ,     [Key6] [varchar] (50)NULL ,     [ActionType] [varchar] (50) NULL ,     [Property] [varchar] (50) NULL ,     [OldValue] [varchar] (8000) NULL ,     [NewValue] [varchar] (8000) NULL ,     [ActionUserName] [varchar] (50) NOT NULL ,     [ActionDateTime] [datetime] NOT NULL ) Once you have created the table, you'll need to add it to your custom LINQ class (which I will refer to as DboDataContext), thus creating the TableHistory class. Then, you'll need to add the History.cs file to your project. You'll also want to add the following code to your project to get the system date: public partial class DboDataContext{ [Function(Name = "GetDate", IsComposable = true)] public DateTime GetSystemDate() { MethodInfo mi = MethodBase.GetCurrentMethod() as MethodInfo; return (DateTime)this.ExecuteMethodCall(this, mi, new object[] { }).ReturnValue; }}private static Dictionary<type,> _cachedIL = new Dictionary<type,>();public static T CloneObjectWithIL<t>(T myObject){ Delegate myExec = null; if (!_cachedIL.TryGetValue(typeof(T), out myExec)) { // Create ILGenerator DynamicMethod dymMethod = new DynamicMethod("DoClone", typeof(T), new Type[] { typeof(T) }, true); ConstructorInfo cInfo = myObject.GetType().GetConstructor(new Type[] { }); ILGenerator generator = dymMethod.GetILGenerator(); LocalBuilder lbf = generator.DeclareLocal(typeof(T)); //lbf.SetLocalSymInfo("_temp"); generator.Emit(OpCodes.Newobj, cInfo); generator.Emit(OpCodes.Stloc_0); foreach (FieldInfo field in myObject.GetType().GetFields( System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic)) { // Load the new object on the eval stack... (currently 1 item on eval stack) generator.Emit(OpCodes.Ldloc_0); // Load initial object (parameter) (currently 2 items on eval stack) generator.Emit(OpCodes.Ldarg_0); // Replace value by field value (still currently 2 items on eval stack) generator.Emit(OpCodes.Ldfld, field); // Store the value of the top on the eval stack into // the object underneath that value on the value stack. // (0 items on eval stack) generator.Emit(OpCodes.Stfld, field); } // Load new constructed obj on eval stack -> 1 item on stack generator.Emit(OpCodes.Ldloc_0); // Return constructed object. --> 0 items on stack generator.Emit(OpCodes.Ret); myExec = dymMethod.CreateDelegate(typeof(Func<t,>)); _cachedIL.Add(typeof(T), myExec); } return ((Func<t,>)myExec)(myObject);}I got both of the above methods off of the net somewhere (maybe even from CodeProject), but it's been long enough that I can't recall where I got them.Explanation of the History ClassThe History class records changes by creating a TableHistory record, inserting the values for the primary key for the table being modified into the Key1, Key2, ..., Key6 columns (if you have more than 6 values that make up a primary key on any table, you'll want to modify this), setting the type of change being made in the ActionType column (INSERT, UPDATE, or DELETE), old value and new value if it happens to be an update action, and the date and Windows identity of the user who made the change.Let's examine what happens when a call is made to the RecordLinqInsert method:public static void RecordLinqInsert(DboDataContext dbo, IIdentity user, object obj){ TableHistory hist = NewHistoryRecord(obj); hist.ActionType = "INSERT"; hist.ActionUserName = user.Name; hist.ActionDateTime = dbo.GetSystemDate(); dbo.TableHistories.InsertOnSubmit(hist);}private static TableHistory NewHistoryRecord(object obj){ TableHistory hist = new TableHistory(); Type type = obj.GetType(); PropertyInfo[] keys; if (historyRecordExceptions.ContainsKey(type)) { keys = historyRecordExceptions[type].ToArray(); } else { keys = type.GetProperties().Where(o => AttrIsPrimaryKey(o)).ToArray(); } if (keys.Length > KeyMax) throw new HistoryException("object has more than " + KeyMax.ToString() + " keys."); for (int i = 1; i <= keys.Length; i++) { typeof(TableHistory) .GetProperty("Key" + i.ToString()) .SetValue(hist, keys[i - 1].GetValue(obj, null).ToString(), null); } hist.TableName = type.Name; return hist;}protected static bool AttrIsPrimaryKey(PropertyInfo pi){ var attrs = from attr in pi.GetCustomAttributes(typeof(ColumnAttribute), true) where ((ColumnAttribute)attr).IsPrimaryKey select attr; if (attrs != null && attrs.Count() > 0) return true; else return false;}RecordLinqInsert takes as input a data context which it will use to write to the database, the user, and the LINQ object to be recorded (a single object, for instance, a Customer or Order object if you're using AdventureWorks). It then calls the NewHistoryRecord method, which uses LINQ to Objects in conjunction with the AttrIsPrimaryKey method to pull all the primary key properties, set the Key1-KeyN properties of the TableHistory object, and return the new TableHistory object. The code would be called in an application, like so: Continue span.fullpost {display:none;}

    Read the article

  • Segfaulting Java process

    - by zenmonkey
    I've a java process that is working on some large data set in memory. I've seen it crash with a SIGSEGV signal sometimes, so i was wondering some potential causes and fixes could do. Caues: - JVM bug - Native library bug (e.g pthreads etc) - JNI bug in user code Fixes: - Upgrade to new JVM In my particular case, this is the output form the log file (pruned) A fatal error has been detected by the Java Runtime Environment: # SIGSEGV (0xb) at pc=0x00002aaaaacd1b94, pid=32116, tid=1086544208 # JRE version: 6.0_14-b08 Java VM: Java HotSpot(TM) 64-Bit Server VM (14.0-b16 mixed mode linux-amd64 ) Problematic frame: C [libpthread.so.0+0xab94] pthread_cond_timedwait+0x154 # If you would like to submit a bug report, please visit: http://java.sun.com/webapps/bugreport/crash.jsp # --------------- T H R E A D --------------- Current thread (0x00002aacaad41000): WatcherThread [stack: 0x0000000040b35000,0x0000000040c36000] [id=32141] siginfo:si_signo=SIGSEGV: si_errno=0, si_code=1 (SEGV_MAPERR), si_addr=0x00002aabc40008c0 Registers: RAX=0x0000000000000000, RBX=0x0000000000000000, RCX=0x0000000000000000, RDX=0x0000000000000002 RSP=0x0000000040c34cc0, RBP=0x0000000040c34d80, RSI=0x0000000000000001, RDI=0x00002aabc40008c0 R8 =0x00002aacaad42528, R9 =0x0000000000000000, R10=0x0000000040c34cd8, R11=0x0000000000000202 R12=0x0000000000000001, R13=0x0000000040c34d40, R14=0xffffffffffffff92, R15=0x00002aacaad42550 RIP=0x00002aaaaacd1b94, EFL=0x0000000000010246, CSGSFS=0x000000000000e033, ERR=0x0000000000000006 TRAPNO=0x000000000000000e Top of Stack: (sp=0x0000000040c34cc0) 0x0000000040c34cc0: 0000000000000000 00002aabc40008c0 0x0000000040c34cd0: 00002aacaad42528 0000000000000000 0x0000000040c34ce0: 0000000002fae0e0 0000000000000000 0x0000000040c34cf0: 00002aaaaacd1750 0000000040c34cc0 0x0000000040c34d00: 00002aacaad42528 0000000000000000 0x0000000040c34d10: 00002aacaad42528 00002aacaad42500 0x0000000040c34d20: 0000000000000032 00002aaaabadf876 0x0000000040c34d30: fffffffdaad40e80 0000000040c34d40 0x0000000040c34d40: 000000004bbb7166 0000000015f07098 0x0000000040c34d50: 0000000040c34d80 00138cd32df59cce 0x0000000040c34d60: 431bde82d7b634db 00002aacaad429c0 0x0000000040c34d70: 0000000000000032 00002aacaad429c0 0x0000000040c34d80: 0000000040c34e00 00002aaaabadda6d 0x0000000040c34d90: 0000000040c34da0 00002aacaad42500 0x0000000040c34da0: 00002aacaad429c0 00002aaa00000002 0x0000000040c34db0: 0000000000000001 0000000000000002 0x0000000040c34dc0: 0000000040c34dd0 00002aaaabb6f613 0x0000000040c34dd0: 0000000040c34e00 00002aacaad41000 0x0000000040c34de0: 0000000000000032 00002aacaad429c0 0x0000000040c34df0: 00002aacaad41000 0000000000001000 0x0000000040c34e00: 0000000040c34e60 00002aaaabbc39fb 0x0000000040c34e10: 0000000040c34e40 00002aaaabab868f 0x0000000040c34e20: 00002aacaad41000 00002aacaad42aa0 0x0000000040c34e30: 00002aacaad42aa0 00002aaaabe10630 0x0000000040c34e40: 00002aaaabe10630 00002aacaad42aa0 0x0000000040c34e50: 00002aacaad429c0 00002aacaad41000 0x0000000040c34e60: 0000000040c35130 00002aaaabadff9f 0x0000000040c34e70: 0000000000000000 0000000000000000 0x0000000040c34e80: 0000000000000000 0000000000000000 0x0000000040c34e90: 0000000000000000 0000000000000000 0x0000000040c34ea0: 0000000000000000 0000000000000000 0x0000000040c34eb0: 0000000000000000 0000000000000000 Instructions: (pc=0x00002aaaaacd1b94) 0x00002aaaaacd1b84: 88 22 00 00 48 8b 7c 24 08 be 01 00 00 00 31 c0 0x00002aaaaacd1b94: f0 0f b1 37 0f 85 e8 00 00 00 8b 57 2c 48 8b 47 Stack: [0x0000000040b35000,0x0000000040c36000], sp=0x0000000040c34cc0, free space=1023k Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) C [libpthread.so.0+0xab94] pthread_cond_timedwait+0x154 V [libjvm.so+0x594a6d] V [libjvm.so+0x67a9fb] V [libjvm.so+0x596f9f] --------------- P R O C E S S --------------- Java Threads: ( = current thread ) 0x00002aacaad3f000 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=32140, stack(0x0000000040a34000,0x0000000040b35000)] 0x00002aacaad3c000 JavaThread "CompilerThread1" daemon [_thread_blocked, id=32139, stack(0x0000000040933000,0x0000000040a34000)] 0x00002aacaad37800 JavaThread "CompilerThread0" daemon [_thread_blocked, id=32138, stack(0x0000000040832000,0x0000000040933000)] 0x00002aacaad36800 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=32137, stack(0x0000000040731000,0x0000000040832000)] 0x00002aacaab7d800 JavaThread "Finalizer" daemon [_thread_blocked, id=32136, stack(0x0000000040630000,0x0000000040731000)] 0x00002aacaab7b800 JavaThread "Reference Handler" daemon [_thread_blocked, id=32135, stack(0x000000004052f000,0x0000000040630000)] 0x0000000040115800 JavaThread "main" [_thread_blocked, id=32117, stack(0x000000004012b000,0x000000004022c000)] Other Threads: 0x00002aacaab75000 VMThread [stack: 0x000000004042e000,0x000000004052f000] [id=32134] =0x00002aacaad41000 WatcherThread [stack: 0x0000000040b35000,0x0000000040c36000] [id=32141] VM state:at safepoint (normal execution) VM Mutex/Monitor currently owned by a thread: ([mutex/lock_event]) [0x0000000040112e80] Threads_lock - owner thread: 0x00002aacaab75000 [0x0000000040113380] Heap_lock - owner thread: 0x0000000040115800 Heap PSYoungGen total 1854528K, used 1029248K [0x00002aac025a0000, 0x00002aaca8340000, 0x00002aaca9040000) eden space 1029248K, 100% used [0x00002aac025a0000,0x00002aac412c0000,0x00002aac412c0000) from space 825280K, 0% used [0x00002aac412c0000,0x00002aac412c0000,0x00002aac738b0000) to space 812800K, 0% used [0x00002aac76980000,0x00002aac76980000,0x00002aaca8340000) PSOldGen total 4423680K, used 4423651K [0x00002aaab5040000, 0x00002aabc3040000, 0x00002aac025a0000) object space 4423680K, 99% used [0x00002aaab5040000,0x00002aabc3038fe8,0x00002aabc3040000) PSPermGen total 21248K, used 5848K [0x00002aaaafc40000, 0x00002aaab1100000, 0x00002aaab5040000) object space 21248K, 27% used [0x00002aaaafc40000,0x00002aaab01f61f0,0x00002aaab1100000) Dynamic libraries: 40000000-40009000 r-xp 00000000 08:01 313415 /usr/java/jdk1.6.0_14/bin/java 40108000-4010a000 rwxp 00008000 08:01 313415 /usr/java/jdk1.6.0_14/bin/java 4010a000-4012b000 rwxp 4010a000 00:00 0 [heap] 4012b000-4012e000 ---p 4012b000 00:00 0 4012e000-4022c000 rwxp 4012e000 00:00 0 4022c000-4022d000 ---p 4022c000 00:00 0 4022d000-4032d000 rwxp 4022d000 00:00 0 4032d000-4032e000 ---p 4032d000 00:00 0 4032e000-4042e000 rwxp 4032e000 00:00 0 4042e000-4042f000 ---p 4042e000 00:00 0 4042f000-4052f000 rwxp 4042f000 00:00 0 4052f000-40532000 ---p 4052f000 00:00 0 40532000-40630000 rwxp 40532000 00:00 0 40630000-40633000 ---p 40630000 00:00 0 40633000-40731000 rwxp 40633000 00:00 0 40731000-40734000 ---p 40731000 00:00 0 40734000-40832000 rwxp 40734000 00:00 0 40832000-40835000 ---p 40832000 00:00 0 40835000-40933000 rwxp 40835000 00:00 0 40933000-40936000 ---p 40933000 00:00 0 40936000-40a34000 rwxp 40936000 00:00 0 40a34000-40a37000 ---p 40a34000 00:00 0 40a37000-40b35000 rwxp 40a37000 00:00 0 40b35000-40b36000 ---p 40b35000 00:00 0 40b36000-40c36000 rwxp 40b36000 00:00 0 2aaaaaaab000-2aaaaaac6000 r-xp 00000000 08:01 49198 /lib64/ld-2.7.so 2aaaaaac6000-2aaaaaac7000 rwxp 2aaaaaac6000 00:00 0 2aaaaaac7000-2aaaaaad0000 r-xs 0006d000 08:10 29851669 /mnt/home/jatten/workspace/common/build/lib/common.jar 2aaaaaad2000-2aaaaaad3000 rwxp 2aaaaaad2000 00:00 0 2aaaaaad3000-2aaaaaae0000 r-xp 00000000 08:01 315357 /usr/java/jdk1.6.0_14/jre/lib/amd64/libverify.so 2aaaaaae0000-2aaaaabdf000 ---p 0000d000 08:01 315357 /usr/java/jdk1.6.0_14/jre/lib/amd64/libverify.so 2aaaaabdf000-2aaaaabe2000 rwxp 0000c000 08:01 315357 /usr/java/jdk1.6.0_14/jre/lib/amd64/libverify.so 2aaaaabe2000-2aaaaac0a000 rwxp 2aaaaabe2000 00:00 0 2aaaaac0a000-2aaaaac0f000 r-xs 0003a000 08:10 30326840 /mnt/home/jatten/workspace/common_ml20010405/build/lib/common_ml.jar 2aaaaac0f000-2aaaaac12000 r-xs 00020000 08:10 29786222 /mnt/home/jatten/pagescorer.jar 2aaaaacc5000-2aaaaacc6000 r-xp 0001a000 08:01 49198 /lib64/ld-2.7.so 2aaaaacc6000-2aaaaacc7000 rwxp 0001b000 08:01 49198 /lib64/ld-2.7.so 2aaaaacc7000-2aaaaacdd000 r-xp 00000000 08:01 49280 /lib64/libpthread-2.7.so 2aaaaacdd000-2aaaaaedc000 ---p 00016000 08:01 49280 /lib64/libpthread-2.7.so 2aaaaaedc000-2aaaaaedd000 r-xp 00015000 08:01 49280 /lib64/libpthread-2.7.so 2aaaaaedd000-2aaaaaede000 rwxp 00016000 08:01 49280 /lib64/libpthread-2.7.so 2aaaaaede000-2aaaaaee2000 rwxp 2aaaaaede000 00:00 0 2aaaaaee2000-2aaaaaee9000 r-xp 00000000 08:01 315360 /usr/java/jdk1.6.0_14/jre/lib/amd64/jli/libjli.so 2aaaaaee9000-2aaaaafea000 ---p 00007000 08:01 315360 /usr/java/jdk1.6.0_14/jre/lib/amd64/jli/libjli.so 2aaaaafea000-2aaaaafec000 rwxp 00008000 08:01 315360 /usr/java/jdk1.6.0_14/jre/lib/amd64/jli/libjli.so 2aaaaafec000-2aaaaafee000 r-xp 00000000 08:01 49240 /lib64/libdl-2.7.so 2aaaaafee000-2aaaab1ee000 ---p 00002000 08:01 49240 /lib64/libdl-2.7.so 2aaaab1ee000-2aaaab1ef000 r-xp 00002000 08:01 49240 /lib64/libdl-2.7.so 2aaaab1ef000-2aaaab1f0000 rwxp 00003000 08:01 49240 /lib64/libdl-2.7.so 2aaaab1f0000-2aaaab1f1000 rwxp 2aaaab1f0000 00:00 0 2aaaab1f1000-2aaaab33e000 r-xp 00000000 08:01 49219 /lib64/libc-2.7.so 2aaaab33e000-2aaaab53e000 ---p 0014d000 08:01 49219 /lib64/libc-2.7.so 2aaaab53e000-2aaaab542000 r-xp 0014d000 08:01 49219 /lib64/libc-2.7.so 2aaaab542000-2aaaab543000 rwxp 00151000 08:01 49219 /lib64/libc-2.7.so 2aaaab543000-2aaaab549000 rwxp 2aaaab543000 00:00 0 2aaaab549000-2aaaabca7000 r-xp 00000000 08:01 315371 /usr/java/jdk1.6.0_14/jre/lib/amd64/server/libjvm.so 2aaaabca7000-2aaaabda6000 ---p 0075e000 08:01 315371 /usr/java/jdk1.6.0_14/jre/lib/amd64/server/libjvm.so 2aaaabda6000-2aaaabf1e000 rwxp 0075d000 08:01 315371 /usr/java/jdk1.6.0_14/jre/lib/amd64/server/libjvm.so 2aaaabf1e000-2aaaabf5c000 rwxp 2aaaabf1e000 00:00 0 2aaaabf67000-2aaaabfe9000 r-xp 00000000 08:01 49263 /lib64/libm-2.7.so 2aaaabfe9000-2aaaac1e8000 ---p 00082000 08:01 49263 /lib64/libm-2.7.so 2aaaac1e8000-2aaaac1e9000 r-xp 00081000 08:01 49263 /lib64/libm-2.7.so 2aaaac1e9000-2aaaac1ea000 rwxp 00082000 08:01 49263 /lib64/libm-2.7.so 2aaaac1ea000-2aaaac1f2000 r-xp 00000000 08:01 49283 /lib64/librt-2.7.so 2aaaac1f2000-2aaaac3f1000 ---p 00008000 08:01 49283 /lib64/librt-2.7.so 2aaaac3f1000-2aaaac3f2000 r-xp 00007000 08:01 49283 /lib64/librt-2.7.so 2aaaac3f2000-2aaaac3f3000 rwxp 00008000 08:01 49283 /lib64/librt-2.7.so 2aaaac3f3000-2aaaac41c000 r-xp 00000000 08:01 315336 /usr/java/jdk1.6.0_14/jre/lib/amd64/libjava.so 2aaaac41c000-2aaaac51b000 ---p 00029000 08:01 315336 /usr/java/jdk1.6.0_14/jre/lib/amd64/libjava.so 2aaaac51b000-2aaaac522000 rwxp 00028000 08:01 315336 /usr/java/jdk1.6.0_14/jre/lib/amd64/libjava.so 2aaaac522000-2aaaac523000 ---p 2aaaac522000 00:00 0 2aaaac523000-2aaaac524000 rwxp 2aaaac523000 00:00 0 2aaaac52d000-2aaaac542000 r-xp 00000000 08:01 49265 /lib64/libnsl-2.7.so 2aaaac542000-2aaaac741000 ---p 00015000 08:01 49265 /lib64/libnsl-2.7.so 2aaaac741000-2aaaac742000 r-xp 00014000 08:01 49265 /lib64/libnsl-2.7.so 2aaaac742000-2aaaac743000 rwxp 00015000 08:01 49265 /lib64/libnsl-2.7.so 2aaaac743000-2aaaac745000 rwxp 2aaaac743000 00:00 0 2aaaac745000-2aaaac74c000 r-xp 00000000 08:01 315362 /usr/java/jdk1.6.0_14/jre/lib/amd64/native_threads/libhpi.so 2aaaac74c000-2aaaac84d000 ---p 00007000 08:01 315362 /usr/java/jdk1.6.0_14/jre/lib/amd64/native_threads/libhpi.so 2aaaac84d000-2aaaac84f000 rwxp 00008000 08:01 315362 /usr/java/jdk1.6.0_14/jre/lib/amd64/native_threads/libhpi.so 2aaaac84f000-2aaaac850000 rwxp 2aaaac84f000 00:00 0 2aaaac850000-2aaaac858000 rwxs 00000000 08:01 229379 /tmp/hsperfdata_jatten/32116 2aaaac85b000-2aaaac865000 r-xp 00000000 08:01 49269 /lib64/libnss_files-2.7.so 2aaaac865000-2aaaaca64000 ---p 0000a000 08:01 49269 /lib64/libnss_files-2.7.so 2aaaaca64000-2aaaaca65000 r-xp 00009000 08:01 49269 /lib64/libnss_files-2.7.so 2aaaaca65000-2aaaaca66000 rwxp 0000a000 08:01 49269 /lib64/libnss_files-2.7.so 2aaaaca66000-2aaaaca74000 r-xp 00000000 08:01 315358 /usr/java/jdk1.6.0_14/jre/lib/amd64/libzip.so 2aaaaca74000-2aaaacb76000 ---p 0000e000 08:01 315358 /usr/java/jdk1.6.0_14/jre/lib/amd64/libzip.so 2aaaacb76000-2aaaacb79000 rwxp 00010000 08:01 315358 /usr/java/jdk1.6.0_14/jre/lib/amd64/libzip.so 2aaaacb79000-2aaaacdea000 rwxp 2aaaacb79000 00:00 0 2aaaacdea000-2aaaafb7a000 rwxp 2aaaacdea000 00:00 0 2aaaafb7a000-2aaaafb84000 rwxp 2aaaafb7a000 00:00 0 2aaaafb84000-2aaaafc3a000 rwxp 2aaaafb84000 00:00 0 2aaaafc40000-2aaab1100000 rwxp 2aaaafc40000 00:00 0 2aaab1100000-2aaab5040000 rwxp 2aaab1100000 00:00 0 2aaab5040000-2aabc3040000 rwxp 2aaab5040000 00:00 0 2aac025a0000-2aaca8340000 rwxp 2aac025a0000 00:00 0 2aaca8340000-2aaca9040000 rwxp 2aaca8340000 00:00 0 2aaca9040000-2aaca904b000 rwxp 2aaca9040000 00:00 0 2aaca904b000-2aaca906a000 rwxp 2aaca904b000 00:00 0 2aaca906a000-2aaca98da000 rwxp 2aaca906a000 00:00 0 2aaca98da000-2aaca9ad4000 rwxp 2aaca98da000 00:00 0 2aaca9ad4000-2aacaa004000 rwxp 2aaca9ad4000 00:00 0 2aacaa004000-2aacaa00a000 rwxp 2aacaa004000 00:00 0 2aacaa00a000-2aacaa87b000 rwxp 2aacaa00a000 00:00 0 2aacaa87b000-2aacaaa76000 rwxp 2aacaa87b000 00:00 0 2aacaaa76000-2aacaaa81000 rwxp 2aacaaa76000 00:00 0 2aacaaa81000-2aacaaaa0000 rwxp 2aacaaa81000 00:00 0 2aacaaaa0000-2aacaaba0000 rwxp 2aacaaaa0000 00:00 0 2aacaaba0000-2aacaad36000 r-xs 02fb1000 08:01 315318 /usr/java/jdk1.6.0_14/jre/lib/rt.jar 2aacaad36000-2aacaaf36000 rwxp 2aacaad36000 00:00 0 2aacaaf36000-2aacaaf49000 r-xp 00000000 08:01 315349 /usr/java/jdk1.6.0_14/jre/lib/amd64/libnet.so 2aacaaf49000-2aacab04a000 ---p 00013000 08:01 315349 /usr/java/jdk1.6.0_14/jre/lib/amd64/libnet.so 2aacab04a000-2aacab04d000 rwxp 00014000 08:01 315349 /usr/java/jdk1.6.0_14/jre/lib/amd64/libnet.so 2aacab058000-2aacab05c000 r-xp 00000000 08:01 49268 /lib64/libnss_dns-2.7.so 2aacab05c000-2aacab25b000 ---p 00004000 08:01 49268 /lib64/libnss_dns-2.7.so 2aacab25b000-2aacab25c000 r-xp 00003000 08:01 49268 /lib64/libnss_dns-2.7.so 2aacab25c000-2aacab25d000 rwxp 00004000 08:01 49268 /lib64/libnss_dns-2.7.so 2aacab25d000-2aacab26e000 r-xp 00000000 08:01 49282 /lib64/libresolv-2.7.so 2aacab26e000-2aacab46e000 ---p 00011000 08:01 49282 /lib64/libresolv-2.7.so 2aacab46e000-2aacab46f000 r-xp 00011000 08:01 49282 /lib64/libresolv-2.7.so 2aacab46f000-2aacab470000 rwxp 00012000 08:01 49282 /lib64/libresolv-2.7.so 2aacab470000-2aacab572000 rwxp 2aacab470000 00:00 0 2aacab572000-2aacab57e000 r-xs 00081000 08:10 29851828 /mnt/home/jatten/workspace/common/lib/google-collect-1.0.jar 2aacab57e000-2aacab585000 r-xs 000aa000 08:10 29851946 /mnt/home/jatten/workspace/common/lib/mysql-connector-java-5.1.8-bin.jar 2aacab585000-2aacab58d000 r-xs 00028000 08:10 29851949 /mnt/home/jatten/workspace/common/lib/xml-apis.jar 2aacab58d000-2aacab591000 r-xs 0002f000 08:10 29851947 /mnt/home/jatten/workspace/common/lib/commons-beanutils-core-1.8.2.jar 2aacab591000-2aacab59e000 r-xs 0007f000 08:10 29851943 /mnt/home/jatten/workspace/common/lib/commons-collections-3.2.jar 2aacab59e000-2aacab5a3000 r-xs 00026000 08:10 29851942 /mnt/home/jatten/workspace/common/lib/httpcore-4.0.jar 2aacab5a3000-2aacab5a9000 r-xs 00030000 08:10 29851932 /mnt/home/jatten/workspace/common/lib/junit-dep-4.8.1.jar 2aacab5a9000-2aacab5ac000 r-xs 00011000 08:10 29851922 /mnt/home/jatten/workspace/common/lib/servlet.jar 2aacab5ac000-2aacab5ae000 r-xs 00009000 08:10 29851937 /mnt/home/jatten/workspace/common/lib/gsb.jar 2aacab5ae000-2aacab5b5000 r-xs 00059000 08:10 29851930 /mnt/home/jatten/workspace/common/lib/log4j-1.2.15.jar 2aacab5b5000-2aacab6b5000 rwxp 2aacab5b5000 00:00 0 2aacab6b5000-2aacab6b7000 r-xs 00009000 08:10 29851956 /mnt/home/jatten/workspace/common/lib/gsb-src.jar 2aacab6b7000-2aacab7b7000 rwxp 2aacab6b7000 00:00 0 2aacab7b7000-2aacab7cf000 r-xs 00115000 08:10 29851938 /mnt/home/jatten/workspace/common/lib/xercesImpl.jar 2aacab7cf000-2aacab7d1000 r-xs 00009000 08:10 29851957 /mnt/home/jatten/workspace/common/lib/velocity-tools-view-1.0.jar 2aacab7d1000-2aacab7d3000 r-xs 00009000 08:10 29851939 /mnt/home/jatten/workspace/common/lib/commons-cli-1.2.jar 2aacab7d3000-2aacab7d9000 r-xs 00034000 08:10 29851955 /mnt/home/jatten/workspace/common/lib/junit-4.8.1.jar 2aacab7d9000-2aacab7db000 r-xs 0000e000 08:10 29851917 /mnt/home/jatten/workspace/common/lib/jakarta-oro-2.0.8.jar 2aacab7db000-2aacab858000 r-xs 0031d000 08:10 29851916 /mnt/home/jatten/workspace/common/lib/poi-ooxml-schemas-3.6-20091214.jar 2aacab858000-2aacab85c000 r-xs 00028000 08:10 29851936 /mnt/home/jatten/workspace/common/lib/httpcore-nio-4.0.jar 2aacab85c000-2aacab85e000 r-xs 00005000 08:10 29851940 /mnt/home/jatten/workspace/common/lib/commons-beanutils-bean-collections-1.8.2.jar 2aacab85e000-2aacab864000 r-xs 00059000 08:10 29851919 /mnt/home/jatten/workspace/common/lib/mail-1.4.jar 2aacab864000-2aacab866000 r-xs 0000d000 08:10 29851950 /mnt/home/jatten/workspace/common/lib/commons-logging-1.1.1.jar 2aacab866000-2aacab86c000 r-xs 00045000 08:10 29851924 /mnt/home/jatten/workspace/common/lib/commons-httpclient-3.1.jar 2aacab86c000-2aacab877000 r-xs 00074000 08:10 29851931 /mnt/home/jatten/workspace/common/lib/velocity-dep-1.4.jar 2aacab877000-2aacab87f000 r-xs 00051000 08:10 29851954 /mnt/home/jatten/workspace/common/lib/velocity-1.4.jar 2aacab87f000-2aacab884000 r-xs 00034000 08:10 29851958 /mnt/home/jatten/workspace/common/lib/commons-beanutils-1.8.2.jar 2aacab884000-2aacab889000 r-xs 00048000 08:10 29851918 /mnt/home/jatten/workspace/common/lib/dom4j-1.6.1.jar 2aacab889000-2aacab8c6000 r-xs 0024f000 08:10 29851914 /mnt/home/jatten/workspace/common/lib/xmlbeans-2.3.0.jar 2aacab8c6000-2aacab8cb000 r-xs 00033000 08:10 29851929 /mnt/home/jatten/workspace/common/lib/xmemcached-1.2.3.jar 2aacab8cb000-2aacab8cd000 r-xs 00005000 08:10 29851928 /mnt/home/jatten/workspace/common/lib/org.hamcrest.core_1.1.0.v20090501071000.jar 2aacab8cd000-2aacab8d0000 r-xs 0000a000 08:10 29851944 /mnt/home/jatten/workspace/common/lib/persistence-api-1.0.jar 2aacab8d0000-2aacab8d6000 r-xs 0005f000 08:10 29851926 /mnt/home/jatten/workspace/common/lib/poi-ooxml-3.6-20091214.jar 2aacab8d6000-2aacab8d7000 r-xs 0002b000 08:10 29851951 /mnt/home/jatten/workspace/common/lib/maxmind.jar 2aacab8d7000-2aacab8d8000 r-xs 00002000 08:10 29851935 /mnt/home/jatten/workspace/common/lib/jackson-jaxrs-1.2.0.jar 2aacab8d8000-2aacab8d9000 r-xs 00002000 08:10 29851913 /mnt/home/jatten/workspace/common/lib/slf4j-log4j12-1.5.6.jar 2aacab8d9000-2aacab8dd000 r-xs 00025000 08:10 29851945 /mnt/home/jatten/workspace/common/lib/yanf4j-1.1.1.jar 2aacab8dd000-2aacab8df000 r-xs 00003000 08:10 29851952 /mnt/home/jatten/workspace/common/lib/clickstream-1.0.2.jar 2aacab8df000-2aacab8e1000 r-xs 00004000 08:10 29851953 /mnt/home/jatten/workspace/common/lib/slf4j-api-1.5.6.jar 2aacab8e1000-2aacab8e9000 r-xs 0004d000 08:10 29851920 /mnt/home/jatten/workspace/common/lib/jackson-mapper-asl-1.2.0.jar 2aacab8e9000-2aacab8ed000 r-xs 0001f000 08:10 29851925 /mnt/home/jatten/workspace/common/lib/jackson-core-asl-1.2.0.jar 2aacab8ed000-2aacab8f1000 r-xs 0001b000 08:10 29851912 /mnt/home/jatten/workspace/common/lib/oscache-2.3.jar 2aacab8f1000-2aacab90c000 r-xs 0015d000 08:10 29851927 /mnt/home/jatten/workspace/common/lib/poi-3.6-20091214.jar 2aacab90c000-2aacab911000 r-xs 00040000 08:10 29851831 /mnt/home/jatten/workspace/common/lib/commons-lang-2.5.jar 2aacab911000-2aacab914000 r-xs 00012000 08:10 29851923 /mnt/home/jatten/workspace/common/lib/jgooglesafebrowser-0.1a.2.jar 2aacab914000-2aacab918000 r-xs 00023000 08:10 29851933 /mnt/home/jatten/workspace/common/lib/gson-1.3.jar 2aacab918000-2aacabb18000 rwxp 2aacab918000 00:00 0 2aacabb82000-2aacabd82000 rwxp 2aacabb82000 00:00 0 2aacabe05000-2aacaf204000 rwxp 2aacabe05000 00:00 0 7fffaa12a000-7fffaa141000 rwxp 7fffaa12a000 00:00 0 [stack] ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vdso] VM Arguments: jvm_args: -Xmx8000M java_command: com.scorers.ModelImplementingPageScorer -t data/data/golds/adult.all.json -b 18 -s data/models/pagetext.binary. adult.april6.all.model -m com.models.MultiClassUpdateableModel -p 30 --goldsilver -v --cat adult --fakeinput -e /mnt/tmp/xyz.15647.pageo bjects.txt -o Launcher Type: SUN_STANDARD Environment Variables: JAVA_HOME=/usr/java/jdk1.6.0_14 PATH=/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/jatten/bin LD_LIBRARY_PATH=/usr/java/jdk1.6.0_14/jre/lib/amd64/server:/usr/java/jdk1.6.0_14/jre/lib/amd64:/usr/java/jdk1.6.0_14/jre/../lib/amd64 SHELL=/bin/bash Signal Handlers: SIGSEGV: [libjvm.so+0x6bd980], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 SIGBUS: [libjvm.so+0x6bd980], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 SIGFPE: [libjvm.so+0x594cc0], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 SIGPIPE: [libjvm.so+0x594cc0], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 SIGXFSZ: [libjvm.so+0x594cc0], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 SIGILL: [libjvm.so+0x594cc0], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 SIGUSR1: SIG_DFL, sa_mask[0]=0x00000000, sa_flags=0x00000000 SIGUSR2: [libjvm.so+0x597480], sa_mask[0]=0x00000000, sa_flags=0x10000004 SIGHUP: [libjvm.so+0x5971d0], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 SIGINT: [libjvm.so+0x5971d0], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 SIGTERM: [libjvm.so+0x5971d0], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 SIGQUIT: [libjvm.so+0x5971d0], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 --------------- S Y S T E M --------------- OS:Fedora release 8 (Werewolf) uname:Linux 2.6.21.7-2.fc8xen #1 SMP Fri Feb 15 12:34:28 EST 2008 x86_64 libc:glibc 2.7 NPTL 2.7 rlimit: STACK 10240k, CORE 0k, NPROC 61504, NOFILE 1024, AS infinity load average:2.83 2.73 2.78 CPU:total 2 (4 cores per cpu, 1 threads per core) family 6 model 23 stepping 10, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1 Memory: 4k page, physical 7872040k(14540k free), swap 0k(0k free) vm_info: Java HotSpot(TM) 64-Bit Server VM (14.0-b16) for linux-amd64 JRE (1.6.0_14-b08), built on May 21 2009 01:11:11 by "java_re" with gcc 3.2.2 (SuSE Lin ux) [error occurred during error reporting (printing date and time), id 0xb]

    Read the article

  • c# Truncate HTML safely for article summary

    - by WickedW
    Hi All, Does anyone have a c# variation of this? This is so I can take some html and display it without breaking as a summary lead in to an article? http://stackoverflow.com/questions/1193500/php-truncate-html-ignoring-tags Save me from reinventing the wheel! Thank you very much ---------- edit ------------------ Sorry, new here, and your right, should have phrased the question better, heres a bit more info I wish to take a html string and truncate it to a set number of words (or even char length) so I can then show the start of it as a summary (which then leads to the main article). I wish to preserve the html so I can show the links etc in preview. The main issue I have to solve is the fact that we may well end up with unclosed html tags if we truncate in the middle of 1 or more tags! The idea I have for solution is to a) truncate the html to N words (words better but chars ok) first (be sure not to stop in the middle of a tag and truncate a require attribute) b) work through the opened html tags in this truncated string (maybe stick them on stack as I go?) c) then work through the closing tags and ensure they match the ones on stack as I pop them off? d) if any open tags left on stack after this, then write them to end of truncated string and html should be good to go!!!! -- edit 12112009 Here is what I have bumbled together so far as a unittest file in VS2008, this 'may' help someone in future My hack attempts based on Jan code are at top for char version + word version (DISCLAIMER: this is dirty rough code!! on my part) I assume working with 'well-formed' HTML in all cases (but not necessarily a full document with a root node as per XML version) Abels XML version is at bottom, but not yet got round to fully getting tests to run on this yet (plus need to understand the code) ... I will update when I get chance to refine having trouble with posting code? is there no upload facility on stack? Thanks for all comments :) using System; using System.Collections.Generic; using System.Text.RegularExpressions; using System.Xml; using System.Xml.XPath; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace PINET40TestProject { [TestClass] public class UtilityUnitTest { public static string TruncateHTMLSafeishChar(string text, int charCount) { bool inTag = false; int cntr = 0; int cntrContent = 0; // loop through html, counting only viewable content foreach (Char c in text) { if (cntrContent == charCount) break; cntr++; if (c == '<') { inTag = true; continue; } if (c == '>') { inTag = false; continue; } if (!inTag) cntrContent++; } string substr = text.Substring(0, cntr); //search for nonclosed tags MatchCollection openedTags = new Regex("<[^/](.|\n)*?>").Matches(substr); MatchCollection closedTags = new Regex("<[/](.|\n)*?>").Matches(substr); // create stack Stack<string> opentagsStack = new Stack<string>(); Stack<string> closedtagsStack = new Stack<string>(); // to be honest, this seemed like a good idea then I got lost along the way // so logic is probably hanging by a thread!! foreach (Match tag in openedTags) { string openedtag = tag.Value.Substring(1, tag.Value.Length - 2); // strip any attributes, sure we can use regex for this! if (openedtag.IndexOf(" ") >= 0) { openedtag = openedtag.Substring(0, openedtag.IndexOf(" ")); } // ignore brs as self-closed if (openedtag.Trim() != "br") { opentagsStack.Push(openedtag); } } foreach (Match tag in closedTags) { string closedtag = tag.Value.Substring(2, tag.Value.Length - 3); closedtagsStack.Push(closedtag); } if (closedtagsStack.Count < opentagsStack.Count) { while (opentagsStack.Count > 0) { string tagstr = opentagsStack.Pop(); if (closedtagsStack.Count == 0 || tagstr != closedtagsStack.Peek()) { substr += "</" + tagstr + ">"; } else { closedtagsStack.Pop(); } } } return substr; } public static string TruncateHTMLSafeishWord(string text, int wordCount) { bool inTag = false; int cntr = 0; int cntrWords = 0; Char lastc = ' '; // loop through html, counting only viewable content foreach (Char c in text) { if (cntrWords == wordCount) break; cntr++; if (c == '<') { inTag = true; continue; } if (c == '>') { inTag = false; continue; } if (!inTag) { // do not count double spaces, and a space not in a tag counts as a word if (c == 32 && lastc != 32) cntrWords++; } } string substr = text.Substring(0, cntr) + " ..."; //search for nonclosed tags MatchCollection openedTags = new Regex("<[^/](.|\n)*?>").Matches(substr); MatchCollection closedTags = new Regex("<[/](.|\n)*?>").Matches(substr); // create stack Stack<string> opentagsStack = new Stack<string>(); Stack<string> closedtagsStack = new Stack<string>(); foreach (Match tag in openedTags) { string openedtag = tag.Value.Substring(1, tag.Value.Length - 2); // strip any attributes, sure we can use regex for this! if (openedtag.IndexOf(" ") >= 0) { openedtag = openedtag.Substring(0, openedtag.IndexOf(" ")); } // ignore brs as self-closed if (openedtag.Trim() != "br") { opentagsStack.Push(openedtag); } } foreach (Match tag in closedTags) { string closedtag = tag.Value.Substring(2, tag.Value.Length - 3); closedtagsStack.Push(closedtag); } if (closedtagsStack.Count < opentagsStack.Count) { while (opentagsStack.Count > 0) { string tagstr = opentagsStack.Pop(); if (closedtagsStack.Count == 0 || tagstr != closedtagsStack.Peek()) { substr += "</" + tagstr + ">"; } else { closedtagsStack.Pop(); } } } return substr; } public static string TruncateHTMLSafeishCharXML(string text, int charCount) { // your data, probably comes from somewhere, or as params to a methodint XmlDocument xml = new XmlDocument(); xml.LoadXml(text); // create a navigator, this is our primary tool XPathNavigator navigator = xml.CreateNavigator(); XPathNavigator breakPoint = null; // find the text node we need: while (navigator.MoveToFollowing(XPathNodeType.Text)) { string lastText = navigator.Value.Substring(0, Math.Min(charCount, navigator.Value.Length)); charCount -= navigator.Value.Length; if (charCount <= 0) { // truncate the last text. Here goes your "search word boundary" code: navigator.SetValue(lastText); breakPoint = navigator.Clone(); break; } } // first remove text nodes, because Microsoft unfortunately merges them without asking while (navigator.MoveToFollowing(XPathNodeType.Text)) { if (navigator.ComparePosition(breakPoint) == XmlNodeOrder.After) { navigator.DeleteSelf(); } } // moves to parent, then move the rest navigator.MoveTo(breakPoint); while (navigator.MoveToFollowing(XPathNodeType.Element)) { if (navigator.ComparePosition(breakPoint) == XmlNodeOrder.After) { navigator.DeleteSelf(); } } // moves to parent // then remove *all* empty nodes to clean up (not necessary): // TODO, add empty elements like <br />, <img /> as exclusion navigator.MoveToRoot(); while (navigator.MoveToFollowing(XPathNodeType.Element)) { while (!navigator.HasChildren && (navigator.Value ?? "").Trim() == "") { navigator.DeleteSelf(); } } // moves to parent navigator.MoveToRoot(); return navigator.InnerXml; } [TestMethod] public void TestTruncateHTMLSafeish() { // Case where we just make it to start of HREF (so effectively an empty link) // 'simple' nested none attributed tags Assert.AreEqual(@"<h1>1234</h1><b><i>56789</i>012</b>", TruncateHTMLSafeishChar( @"<h1>1234</h1><b><i>56789</i>012345</b>", 12)); // In middle of a! Assert.AreEqual(@"<h1>1234</h1><a href=""testurl""><b>567</b></a>", TruncateHTMLSafeishChar( @"<h1>1234</h1><a href=""testurl""><b>5678</b></a><i><strong>some italic nested in string</strong></i>", 7)); // more Assert.AreEqual(@"<div><b><i><strong>1</strong></i></b></div>", TruncateHTMLSafeishChar( @"<div><b><i><strong>12</strong></i></b></div>", 1)); // br Assert.AreEqual(@"<h1>1 3 5</h1><br />6", TruncateHTMLSafeishChar( @"<h1>1 3 5</h1><br />678<br />", 6)); } [TestMethod] public void TestTruncateHTMLSafeishWord() { // zero case Assert.AreEqual(@" ...", TruncateHTMLSafeishWord( @"", 5)); // 'simple' nested none attributed tags Assert.AreEqual(@"<h1>one two <br /></h1><b><i>three ...</i></b>", TruncateHTMLSafeishWord( @"<h1>one two <br /></h1><b><i>three </i>four</b>", 3), "we have added ' ...' to end of summary"); // In middle of a! Assert.AreEqual(@"<h1>one two three </h1><a href=""testurl""><b class=""mrclass"">four ...</b></a>", TruncateHTMLSafeishWord( @"<h1>one two three </h1><a href=""testurl""><b class=""mrclass"">four five </b></a><i><strong>some italic nested in string</strong></i>", 4)); // start of h1 Assert.AreEqual(@"<h1>one two three ...</h1>", TruncateHTMLSafeishWord( @"<h1>one two three </h1><a href=""testurl""><b>four five </b></a><i><strong>some italic nested in string</strong></i>", 3)); // more than words available Assert.AreEqual(@"<h1>one two three </h1><a href=""testurl""><b>four five </b></a><i><strong>some italic nested in string</strong></i> ...", TruncateHTMLSafeishWord( @"<h1>one two three </h1><a href=""testurl""><b>four five </b></a><i><strong>some italic nested in string</strong></i>", 99)); } [TestMethod] public void TestTruncateHTMLSafeishWordXML() { // zero case Assert.AreEqual(@" ...", TruncateHTMLSafeishWord( @"", 5)); // 'simple' nested none attributed tags string output = TruncateHTMLSafeishCharXML( @"<body><h1>one two </h1><b><i>three </i>four</b></body>", 13); Assert.AreEqual(@"<body>\r\n <h1>one two </h1>\r\n <b>\r\n <i>three</i>\r\n </b>\r\n</body>", output, "XML version, no ... yet and addeds '\r\n + spaces?' to format document"); // In middle of a! Assert.AreEqual(@"<h1>one two three </h1><a href=""testurl""><b class=""mrclass"">four ...</b></a>", TruncateHTMLSafeishCharXML( @"<body><h1>one two three </h1><a href=""testurl""><b class=""mrclass"">four five </b></a><i><strong>some italic nested in string</strong></i></body>", 4)); // start of h1 Assert.AreEqual(@"<h1>one two three ...</h1>", TruncateHTMLSafeishCharXML( @"<h1>one two three </h1><a href=""testurl""><b>four five </b></a><i><strong>some italic nested in string</strong></i>", 3)); // more than words available Assert.AreEqual(@"<h1>one two three </h1><a href=""testurl""><b>four five </b></a><i><strong>some italic nested in string</strong></i> ...", TruncateHTMLSafeishCharXML( @"<h1>one two three </h1><a href=""testurl""><b>four five </b></a><i><strong>some italic nested in string</strong></i>", 99)); } } }

    Read the article

  • Where can these be posted besides the Python Cookbook?

    - by Noctis Skytower
    Whitespace Assembler #! /usr/bin/env python """Assembler.py Compiles a program from "Assembly" folder into "Program" folder. Can be executed directly by double-click or on the command line. Give name of *.WSA file without extension (example: stack_calc).""" ################################################################################ __author__ = 'Stephen "Zero" Chappell <[email protected]>' __date__ = '14 March 2010' __version__ = '$Revision: 3 $' ################################################################################ import string from Interpreter import INS, MNEMONIC ################################################################################ def parse(code): program = [] process_virtual(program, code) process_control(program) return tuple(program) def process_virtual(program, code): for line, text in enumerate(code.split('\n')): if not text or text[0] == '#': continue if text.startswith('part '): parse_part(program, line, text[5:]) elif text.startswith(' '): parse_code(program, line, text[5:]) else: syntax_error(line) def syntax_error(line): raise SyntaxError('Line ' + str(line + 1)) ################################################################################ def process_control(program): parts = get_parts(program) names = dict(pair for pair in zip(parts, generate_index())) correct_control(program, names) def get_parts(program): parts = [] for ins in program: if isinstance(ins, tuple): ins, arg = ins if ins == INS.PART: if arg in parts: raise NameError('Part definition was found twice: ' + arg) parts.append(arg) return parts def generate_index(): index = 1 while True: yield index index *= -1 if index > 0: index += 1 def correct_control(program, names): for index, ins in enumerate(program): if isinstance(ins, tuple): ins, arg = ins if ins in HAS_LABEL: if arg not in names: raise NameError('Part definition was never found: ' + arg) program[index] = (ins, names[arg]) ################################################################################ def parse_part(program, line, text): if not valid_label(text): syntax_error(line) program.append((INS.PART, text)) def valid_label(text): if not between_quotes(text): return False label = text[1:-1] if not valid_name(label): return False return True def between_quotes(text): if len(text) < 3: return False if text.count('"') != 2: return False if text[0] != '"' or text[-1] != '"': return False return True def valid_name(label): valid_characters = string.ascii_letters + string.digits + '_' valid_set = frozenset(valid_characters) label_set = frozenset(label) if len(label_set - valid_set) != 0: return False return True ################################################################################ from Interpreter import HAS_LABEL, Program NO_ARGS = Program.NO_ARGS HAS_ARG = Program.HAS_ARG TWO_WAY = tuple(set(NO_ARGS) & set(HAS_ARG)) ################################################################################ def parse_code(program, line, text): for ins, word in enumerate(MNEMONIC): if text.startswith(word): check_code(program, line, text[len(word):], ins) break else: syntax_error(line) def check_code(program, line, text, ins): if ins in TWO_WAY: if text: number = parse_number(line, text) program.append((ins, number)) else: program.append(ins) elif ins in HAS_LABEL: text = parse_label(line, text) program.append((ins, text)) elif ins in HAS_ARG: number = parse_number(line, text) program.append((ins, number)) elif ins in NO_ARGS: if text: syntax_error(line) program.append(ins) else: syntax_error(line) def parse_label(line, text): if not text or text[0] != ' ': syntax_error(line) text = text[1:] if not valid_label(text): syntax_error(line) return text ################################################################################ def parse_number(line, text): if not valid_number(text): syntax_error(line) return int(text) def valid_number(text): if len(text) < 2: return False if text[0] != ' ': return False text = text[1:] if '+' in text and '-' in text: return False if '+' in text: if text.count('+') != 1: return False if text[0] != '+': return False text = text[1:] if not text: return False if '-' in text: if text.count('-') != 1: return False if text[0] != '-': return False text = text[1:] if not text: return False valid_set = frozenset(string.digits) value_set = frozenset(text) if len(value_set - valid_set) != 0: return False return True ################################################################################ ################################################################################ from Interpreter import partition_number VMC_2_TRI = { (INS.PUSH, True): (0, 0), (INS.COPY, False): (0, 2, 0), (INS.COPY, True): (0, 1, 0), (INS.SWAP, False): (0, 2, 1), (INS.AWAY, False): (0, 2, 2), (INS.AWAY, True): (0, 1, 2), (INS.ADD, False): (1, 0, 0, 0), (INS.SUB, False): (1, 0, 0, 1), (INS.MUL, False): (1, 0, 0, 2), (INS.DIV, False): (1, 0, 1, 0), (INS.MOD, False): (1, 0, 1, 1), (INS.SET, False): (1, 1, 0), (INS.GET, False): (1, 1, 1), (INS.PART, True): (2, 0, 0), (INS.CALL, True): (2, 0, 1), (INS.GOTO, True): (2, 0, 2), (INS.ZERO, True): (2, 1, 0), (INS.LESS, True): (2, 1, 1), (INS.BACK, False): (2, 1, 2), (INS.EXIT, False): (2, 2, 2), (INS.OCHR, False): (1, 2, 0, 0), (INS.OINT, False): (1, 2, 0, 1), (INS.ICHR, False): (1, 2, 1, 0), (INS.IINT, False): (1, 2, 1, 1) } ################################################################################ def to_trinary(program): trinary_code = [] for ins in program: if isinstance(ins, tuple): ins, arg = ins trinary_code.extend(VMC_2_TRI[(ins, True)]) trinary_code.extend(from_number(arg)) else: trinary_code.extend(VMC_2_TRI[(ins, False)]) return tuple(trinary_code) def from_number(arg): code = [int(arg < 0)] if arg: for bit in reversed(list(partition_number(abs(arg), 2))): code.append(bit) return code + [2] return code + [0, 2] to_ws = lambda trinary: ''.join(' \t\n'[index] for index in trinary) def compile_wsa(source): program = parse(source) trinary = to_trinary(program) ws_code = to_ws(trinary) return ws_code ################################################################################ ################################################################################ import os import sys import time import traceback def main(): name, source, command_line, error = get_source() if not error: start = time.clock() try: ws_code = compile_wsa(source) except: print('ERROR: File could not be compiled.\n') traceback.print_exc() error = True else: path = os.path.join('Programs', name + '.ws') try: open(path, 'w').write(ws_code) except IOError as err: print(err) error = True else: div, mod = divmod((time.clock() - start) * 1000, 1) args = int(div), '{:.3}'.format(mod)[1:] print('DONE: Comipled in {}{} ms'.format(*args)) handle_close(error, command_line) def get_source(): if len(sys.argv) > 1: command_line = True name = sys.argv[1] else: command_line = False try: name = input('Source File: ') except: return None, None, False, True print() path = os.path.join('Assembly', name + '.wsa') try: return name, open(path).read(), command_line, False except IOError as err: print(err) return None, None, command_line, True def handle_close(error, command_line): if error: usage = 'Usage: {} <assembly>'.format(os.path.basename(sys.argv[0])) print('\n{}\n{}'.format('-' * len(usage), usage)) if not command_line: time.sleep(10) ################################################################################ if __name__ == '__main__': main() Whitespace Helpers #! /usr/bin/env python """Helpers.py Includes a function to encode Python strings into my WSA format. Has a "PRINT_LINE" function that can be copied to a WSA program. Contains a "PRINT" function and documentation as an explanation.""" ################################################################################ __author__ = 'Stephen "Zero" Chappell <[email protected]>' __date__ = '14 March 2010' __version__ = '$Revision: 1 $' ################################################################################ def encode_string(string, addr): print(' push', addr) print(' push', len(string)) print(' set') addr += 1 for offset, character in enumerate(string): print(' push', addr + offset) print(' push', ord(character)) print(' set') ################################################################################ # Prints a string with newline. # push addr # call "PRINT_LINE" """ part "PRINT_LINE" call "PRINT" push 10 ochr back """ ################################################################################ # def print(array): # if len(array) <= 0: # return # offset = 1 # while len(array) - offset >= 0: # ptr = array.ptr + offset # putch(array[ptr]) # offset += 1 """ part "PRINT" # Line 1-2 copy get less "__PRINT_RET_1" copy get zero "__PRINT_RET_1" # Line 3 push 1 # Line 4 part "__PRINT_LOOP" copy copy 2 get swap sub less "__PRINT_RET_2" # Line 5 copy 1 copy 1 add # Line 6 get ochr # Line 7 push 1 add goto "__PRINT_LOOP" part "__PRINT_RET_2" away part "__PRINT_RET_1" away back """ Whitespace Interpreter #! /usr/bin/env python """Interpreter.py Runs programs in "Programs" and creates *.WSO files when needed. Can be executed directly by double-click or on the command line. If run on command line, add "ASM" flag to dump program assembly.""" ################################################################################ __author__ = 'Stephen "Zero" Chappell <[email protected]>' __date__ = '14 March 2010' __version__ = '$Revision: 4 $' ################################################################################ def test_file(path): disassemble(parse(trinary(load(path))), True) ################################################################################ load = lambda ws: ''.join(c for r in open(ws) for c in r if c in ' \t\n') trinary = lambda ws: tuple(' \t\n'.index(c) for c in ws) ################################################################################ def enum(names): names = names.replace(',', ' ').split() space = dict((reversed(pair) for pair in enumerate(names)), __slots__=()) return type('enum', (object,), space)() INS = enum('''\ PUSH, COPY, SWAP, AWAY, \ ADD, SUB, MUL, DIV, MOD, \ SET, GET, \ PART, CALL, GOTO, ZERO, LESS, BACK, EXIT, \ OCHR, OINT, ICHR, IINT''') ################################################################################ def parse(code): ins = iter(code).__next__ program = [] while True: try: imp = ins() except StopIteration: return tuple(program) if imp == 0: # [Space] parse_stack(ins, program) elif imp == 1: # [Tab] imp = ins() if imp == 0: # [Tab][Space] parse_math(ins, program) elif imp == 1: # [Tab][Tab] parse_heap(ins, program) else: # [Tab][Line] parse_io(ins, program) else: # [Line] parse_flow(ins, program) def parse_number(ins): sign = ins() if sign == 2: raise StopIteration() buffer = '' code = ins() if code == 2: raise StopIteration() while code != 2: buffer += str(code) code = ins() if sign == 1: return int(buffer, 2) * -1 return int(buffer, 2) ################################################################################ def parse_stack(ins, program): code = ins() if code == 0: # [Space] number = parse_number(ins) program.append((INS.PUSH, number)) elif code == 1: # [Tab] code = ins() number = parse_number(ins) if code == 0: # [Tab][Space] program.append((INS.COPY, number)) elif code == 1: # [Tab][Tab] raise StopIteration() else: # [Tab][Line] program.append((INS.AWAY, number)) else: # [Line] code = ins() if code == 0: # [Line][Space] program.append(INS.COPY) elif code == 1: # [Line][Tab] program.append(INS.SWAP) else: # [Line][Line] program.append(INS.AWAY) def parse_math(ins, program): code = ins() if code == 0: # [Space] code = ins() if code == 0: # [Space][Space] program.append(INS.ADD) elif code == 1: # [Space][Tab] program.append(INS.SUB) else: # [Space][Line] program.append(INS.MUL) elif code == 1: # [Tab] code = ins() if code == 0: # [Tab][Space] program.append(INS.DIV) elif code == 1: # [Tab][Tab] program.append(INS.MOD) else: # [Tab][Line] raise StopIteration() else: # [Line] raise StopIteration() def parse_heap(ins, program): code = ins() if code == 0: # [Space] program.append(INS.SET) elif code == 1: # [Tab] program.append(INS.GET) else: # [Line] raise StopIteration() def parse_io(ins, program): code = ins() if code == 0: # [Space] code = ins() if code == 0: # [Space][Space] program.append(INS.OCHR) elif code == 1: # [Space][Tab] program.append(INS.OINT) else: # [Space][Line] raise StopIteration() elif code == 1: # [Tab] code = ins() if code == 0: # [Tab][Space] program.append(INS.ICHR) elif code == 1: # [Tab][Tab] program.append(INS.IINT) else: # [Tab][Line] raise StopIteration() else: # [Line] raise StopIteration() def parse_flow(ins, program): code = ins() if code == 0: # [Space] code = ins() label = parse_number(ins) if code == 0: # [Space][Space] program.append((INS.PART, label)) elif code == 1: # [Space][Tab] program.append((INS.CALL, label)) else: # [Space][Line] program.append((INS.GOTO, label)) elif code == 1: # [Tab] code = ins() if code == 0: # [Tab][Space] label = parse_number(ins) program.append((INS.ZERO, label)) elif code == 1: # [Tab][Tab] label = parse_number(ins) program.append((INS.LESS, label)) else: # [Tab][Line] program.append(INS.BACK) else: # [Line] code = ins() if code == 2: # [Line][Line] program.append(INS.EXIT) else: # [Line][Space] or [Line][Tab] raise StopIteration() ################################################################################ MNEMONIC = '\ push copy swap away add sub mul div mod set get part \ call goto zero less back exit ochr oint ichr iint'.split() HAS_ARG = [getattr(INS, name) for name in 'PUSH COPY AWAY PART CALL GOTO ZERO LESS'.split()] HAS_LABEL = [getattr(INS, name) for name in 'PART CALL GOTO ZERO LESS'.split()] def disassemble(program, names=False): if names: names = create_names(program) for ins in program: if isinstance(ins, tuple): ins, arg = ins assert ins in HAS_ARG has_arg = True else: assert INS.PUSH <= ins <= INS.IINT has_arg = False if ins == INS.PART: if names: print(MNEMONIC[ins], '"' + names[arg] + '"') else: print(MNEMONIC[ins], arg) elif has_arg and ins in HAS_ARG: if ins in HAS_LABEL and names: assert arg in names print(' ' + MNEMONIC[ins], '"' + names[arg] + '"') else: print(' ' + MNEMONIC[ins], arg) else: print(' ' + MNEMONIC[ins]) ################################################################################ def create_names(program): names = {} number = 1 for ins in program: if isinstance(ins, tuple) and ins[0] == INS.PART: label = ins[1] assert label not in names names[label] = number_to_name(number) number += 1 return names def number_to_name(number): name = '' for offset in reversed(list(partition_number(number, 27))): if offset: name += chr(ord('A') + offset - 1) else: name += '_' return name def partition_number(number, base): div, mod = divmod(number, base) yield mod while div: div, mod = divmod(div, base) yield mod ################################################################################ CODE = (' \t\n', ' \n ', ' \t \t\n', ' \n\t', ' \n\n', ' \t\n \t\n', '\t ', '\t \t', '\t \n', '\t \t ', '\t \t\t', '\t\t ', '\t\t\t', '\n \t\n', '\n \t \t\n', '\n \n \t\n', '\n\t \t\n', '\n\t\t \t\n', '\n\t\n', '\n\n\n', '\t\n ', '\t\n \t', '\t\n\t ', '\t\n\t\t') EXAMPLE = ''.join(CODE) ################################################################################ NOTES = '''\ STACK ===== push number copy copy number swap away away number MATH ==== add sub mul div mod HEAP ==== set get FLOW ==== part label call label goto label zero label less label back exit I/O === ochr oint ichr iint''' ################################################################################ ################################################################################ class Stack: def __init__(self): self.__data = [] # Stack Operators def push(self, number): self.__data.append(number) def copy(self, number=None): if number is None: self.__data.append(self.__data[-1]) else: size = len(self.__data) index = size - number - 1 assert 0 <= index < size self.__data.append(self.__data[index]) def swap(self): self.__data[-2], self.__data[-1] = self.__data[-1], self.__data[-2] def away(self, number=None): if number is None: self.__data.pop() else: size = len(self.__data) index = size - number - 1 assert 0 <= index < size del self.__data[index:-1] # Math Operators def add(self): suffix = self.__data.pop() prefix = self.__data.pop() self.__data.append(prefix + suffix) def sub(self): suffix = self.__data.pop() prefix = self.__data.pop() self.__data.append(prefix - suffix) def mul(self): suffix = self.__data.pop() prefix = self.__data.pop() self.__data.append(prefix * suffix) def div(self): suffix = self.__data.pop() prefix = self.__data.pop() self.__data.append(prefix // suffix) def mod(self): suffix = self.__data.pop() prefix = self.__data.pop() self.__data.append(prefix % suffix) # Program Operator def pop(self): return self.__data.pop() ################################################################################ class Heap: def __init__(self): self.__data = {} def set_(self, addr, item): if item: self.__data[addr] = item elif addr in self.__data: del self.__data[addr] def get_(self, addr): return self.__data.get(addr, 0) ################################################################################ import os import zlib import msvcrt import pickle import string class CleanExit(Exception): pass NOP = lambda arg: None DEBUG_WHITESPACE = False ################################################################################ class Program: NO_ARGS = INS.COPY, INS.SWAP, INS.AWAY, INS.ADD, \ INS.SUB, INS.MUL, INS.DIV, INS.MOD, \ INS.SET, INS.GET, INS.BACK, INS.EXIT, \ INS.OCHR, INS.OINT, INS.ICHR, INS.IINT HAS_ARG = INS.PUSH, INS.COPY, INS.AWAY, INS.PART, \ INS.CALL, INS.GOTO, INS.ZERO, INS.LESS def __init__(self, code): self.__data = code self.__validate() self.__build_jump() self.__check_jump() self.__setup_exec() def __setup_exec(self): self.__iptr = 0 self.__stck = stack = Stack() self.__heap = Heap() self.__cast = [] self.__meth = (stack.push, stack.copy, stack.swap, stack.away, stack.add, stack.sub, stack.mul, stack.div, stack.mod, self.__set, self.__get, NOP, self.__call, self.__goto, self.__zero, self.__less, self.__back, self.__exit, self.__ochr, self.__oint, self.__ichr, self.__iint) def step(self): ins = self.__data[self.__iptr] self.__iptr += 1 if isinstance(ins, tuple): self.__meth[ins[0]](ins[1]) else: self.__meth[ins]() def run(self): while True: ins = self.__data[self.__iptr] self.__iptr += 1 if isinstance(ins, tuple): self.__meth[ins[0]](ins[1]) else: self.__meth[ins]() def __oint(self): for digit in str(self.__stck.pop()): msvcrt.putwch(digit) def __ichr(self): addr = self.__stck.pop() # Input Routine while msvcrt.kbhit(): msvcrt.getwch() while True: char = msvcrt.getwch() if char in '\x00\xE0': msvcrt.getwch() elif char in string.printable: char = char.replace('\r', '\n') msvcrt.putwch(char) break item = ord(char) # Storing Number self.__heap.set_(addr, item) def __iint(self): addr = self.__stck.pop() # Input Routine while msvcrt.kbhit(): msvcrt.getwch() buff = '' char = msvcrt.getwch() while char != '\r' or not buff: if char in '\x00\xE0': msvcrt.getwch() elif char in '+-' and not buff: msvcrt.putwch(char) buff += char elif '0' <= char <= '9': msvcrt.putwch(char) buff += char elif char == '\b': if buff: buff = buff[:-1] msvcrt.putwch(char) msvcrt.putwch(' ') msvcrt.putwch(char) char = msvcrt.getwch() msvcrt.putwch(char) msvcrt.putwch('\n') item = int(buff) # Storing Number self.__heap.set_(addr, item) def __goto(self, label): self.__iptr = self.__jump[label] def __zero(self, label): if self.__stck.pop() == 0: self.__iptr = self.__jump[label] def __less(self, label): if self.__stck.pop() < 0: self.__iptr = self.__jump[label] def __exit(self): self.__setup_exec() raise CleanExit() def __set(self): item = self.__stck.pop() addr = self.__stck.po

    Read the article

  • Windows 7 Seems to break SWT Control.print(GC)

    - by GreenKiwi
    A bug has been filed and fixed (super quickly) in SWT: https://bugs.eclipse.org/bugs/show_bug.cgi?id=305294 Just to preface this, my goal here is to print the two images into a canvas so that I can animate the canvas sliding across the screen (think iPhone), sliding the controls themselves was too CPU intensive, so this was a good alternative until I tested it on Win7. I'm open to anything that will help me solve my original problem, it doesn't have to be fixing the problem below. Does anyone know how to get "Control.print(GC)" to work with Windows 7 Aero? I have code that works just fine in Windows XP and in Windows 7, when Aero is disabled, but the command: control.print(GC) causes a non-top control to be effectively erased from the screen. GC gc = new GC(image); try { // As soon as this code is called, calling "layout" on the controls // causes them to disappear. control.print(gc); } finally { gc.dispose(); } I have stacked controls and would like to print the images from the current and next controls such that I can "slide" them off the screen. However, upon printing the non-top control, it is never redrawn again. Here is some example code. (Interesting code bits are at the top and it will require pointing at SWT in order to work.) Thanks for any and all help. As a work around, I'm thinking about swapping controls between prints to see if that helps, but I'd rather not. import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StackLayout; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; public class SWTImagePrintTest { private Composite stack; private StackLayout layout; private Label lblFlip; private Label lblFlop; private boolean flip = true; private Button buttonFlop; private Button buttonPrint; /** * Prints the control into an image * * @param control */ protected void print(Control control) { Image image = new Image(control.getDisplay(), control.getBounds()); GC gc = new GC(image); try { // As soon as this code is called, calling "layout" on the controls // causes them to disappear. control.print(gc); } finally { gc.dispose(); } } /** * Swaps the controls in the stack */ private void flipFlop() { if (flip) { flip = false; layout.topControl = lblFlop; buttonFlop.setText("flop"); stack.layout(); } else { flip = true; layout.topControl = lblFlip; buttonFlop.setText("flip"); stack.layout(); } } private void createContents(Shell shell) { shell.setLayout(new GridLayout(2, true)); stack = new Composite(shell, SWT.NONE); GridData gdStack = new GridData(GridData.FILL_BOTH); gdStack.horizontalSpan = 2; stack.setLayoutData(gdStack); layout = new StackLayout(); stack.setLayout(layout); lblFlip = new Label(stack, SWT.BOLD); lblFlip.setBackground(Display.getCurrent().getSystemColor( SWT.COLOR_CYAN)); lblFlip.setText("FlIp"); lblFlop = new Label(stack, SWT.NONE); lblFlop.setBackground(Display.getCurrent().getSystemColor( SWT.COLOR_BLUE)); lblFlop.setText("fLoP"); layout.topControl = lblFlip; stack.layout(); buttonFlop = new Button(shell, SWT.FLAT); buttonFlop.setText("Flip"); GridData gdFlip = new GridData(); gdFlip.horizontalAlignment = SWT.RIGHT; buttonFlop.setLayoutData(gdFlip); buttonFlop.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { flipFlop(); } }); buttonPrint = new Button(shell, SWT.FLAT); buttonPrint.setText("Print"); GridData gdPrint = new GridData(); gdPrint.horizontalAlignment = SWT.LEFT; buttonPrint.setLayoutData(gdPrint); buttonPrint.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { print(lblFlip); print(lblFlop); } }); } /** * @param args */ public static void main(String[] args) { Shell shell = new Shell(); shell.setText("Slider Test"); shell.setSize(new Point(800, 600)); shell.setLayout(new GridLayout()); SWTImagePrintTest tt = new SWTImagePrintTest(); tt.createContents(shell); shell.open(); Display display = Display.getDefault(); while (shell.isDisposed() == false) { if (display.readAndDispatch() == false) { display.sleep(); } } display.dispose(); } }

    Read the article

  • How to Avoid Your Next 12-Month Science Project

    - by constant
    While most customers immediately understand how the magic of Oracle's Hybrid Columnar Compression, intelligent storage servers and flash memory make Exadata uniquely powerful against home-grown database systems, some people think that Exalogic is nothing more than a bunch of x86 servers, a storage appliance and an InfiniBand (IB) network, built into a single rack. After all, isn't this exactly what the High Performance Computing (HPC) world has been doing for decades? On the surface, this may be true. And some people tried exactly that: They tried to put together their own version of Exalogic, but then they discover there's a lot more to building a system than buying hardware and assembling it together. IT is not Ikea. Why is that so? Could it be there's more going on behind the scenes than merely putting together a bunch of servers, a storage array and an InfiniBand network into a rack? Let's explore some of the special sauce that makes Exalogic unique and un-copyable, so you can save yourself from your next 6- to 12-month science project that distracts you from doing real work that adds value to your company. Engineering Systems is Hard Work! The backbone of Exalogic is its InfiniBand network: 4 times better bandwidth than even 10 Gigabit Ethernet, and only about a tenth of its latency. What a potential for increased scalability and throughput across the middleware and database layers! But InfiniBand is a beast that needs to be tamed: It is true that Exalogic uses a standard, open-source Open Fabrics Enterprise Distribution (OFED) InfiniBand driver stack. Unfortunately, this software has been developed by the HPC community with fastest speed in mind (which is good) but, despite the name, not many other enterprise-class requirements are included (which is less good). Here are some of the improvements that Oracle's InfiniBand development team had to add to the OFED stack to make it enterprise-ready, simply because typical HPC users didn't have the need to implement them: More than 100 bug fixes in the pieces that were not related to the Message Passing Interface Protocol (MPI), which is the protocol that HPC users use most of the time, but which is less useful in the enterprise. Performance optimizations and tuning across the whole IB stack: From Switches, Host Channel Adapters (HCAs) and drivers to low-level protocols, middleware and applications. Yes, even the standard HPC IB stack could be improved in terms of performance. Ethernet over IB (EoIB): Exalogic uses InfiniBand internally to reach high performance, but it needs to play nicely with datacenters around it. That's why Oracle added Ethernet over InfiniBand technology to it that allows for creating many virtual 10GBE adapters inside Exalogic's nodes that are aggregated and connected to Exalogic's IB gateway switches. While this is an open standard, it's up to the vendor to implement it. In this case, Oracle integrated the EoIB stack with Oracle's own IB to 10GBE gateway switches, and made it fully virtualized from the beginning. This means that Exalogic customers can completely rewire their server infrastructure inside the rack without having to physically pull or plug a single cable - a must-have for every cloud deployment. Anybody who wants to match this level of integration would need to add an InfiniBand switch development team to their project. Or just buy Oracle's gateway switches, which are conveniently shipped with a whole server infrastructure attached! IPv6 support for InfiniBand's Sockets Direct Protocol (SDP), Reliable Datagram Sockets (RDS), TCP/IP over IB (IPoIB) and EoIB protocols. Because no IPv6 = not very enterprise-class. HA capability for SDP. High Availability is not a big requirement for HPC, but for enterprise-class application servers it is. Every node in Exalogic's InfiniBand network is connected twice for redundancy. If any cable or port or HCA fails, there's always a replacement link ready to take over. This requires extra magic at the protocol level to work. So in addition to Weblogic's failover capabilities, Oracle implemented IB automatic path migration at the SDP level to avoid unnecessary failover operations at the middleware level. Security, for example spoof-protection. Another feature that is less important for traditional users of InfiniBand, but very important for enterprise customers. InfiniBand Partitioning and Quality-of-Service (QoS): One of the first questions we get from customers about Exalogic is: “How can we implement multi-tenancy?” The answer is to partition your IB network, which effectively creates many networks that work independently and that are protected at the lowest networking layer possible. In addition to that, QoS allows administrators to prioritize traffic flow in multi-tenancy environments so they can keep their service levels where it matters most. Resilient IB Fabric Management: InfiniBand is a self-managing network, so a lot of the magic lies in coming up with the right topology and in teaching the subnet manager how to properly discover and manage the network. Oracle's Infiniband switches come with pre-integrated, highly available fabric management with seamless integration into Oracle Enterprise Manager Ops Center. In short: Oracle elevated the OFED InfiniBand stack into an enterprise-class networking infrastructure. Many years and multiple teams of manpower went into the above improvements - this is something you can only get from Oracle, because no other InfiniBand vendor can give you these features across the whole stack! Exabus: Because it's not About the Size of Your Network, it's How You Use it! So let's assume that you somehow were able to get your hands on an enterprise-class IB driver stack. Or maybe you don't care and are just happy with the standard OFED one? Anyway, the next step is to actually leverage that InfiniBand performance. Here are the choices: Use traditional TCP/IP on top of the InfiniBand stack, Develop your own integration between your middleware and the lower-level (but faster) InfiniBand protocols. While more bandwidth is always a good thing, it's actually the low latency that enables superior performance for your applications when running on any networking infrastructure: The lower the latency, the faster the response travels through the network and the more transactions you can close per second. The reason why InfiniBand is such a low latency technology is that it gets rid of most if not all of your traditional networking protocol stack: Data is literally beamed from one region of RAM in one server into another region of RAM in another server with no kernel/drivers/UDP/TCP or other networking stack overhead involved! Which makes option 1 a no-go: Adding TCP/IP on top of InfiniBand is like adding training wheels to your racing bike. It may be ok in the beginning and for development, but it's not quite the performance IB was meant to deliver. Which only leaves option 2: Integrating your middleware with fast, low-level InfiniBand protocols. And this is what Exalogic's "Exabus" technology is all about. Here are a few Exabus features that help applications leverage the performance of InfiniBand in Exalogic: RDMA and SDP integration at the JDBC driver level (SDP), for Oracle Weblogic (SDP), Oracle Coherence (RDMA), Oracle Tuxedo (RDMA) and the new Oracle Traffic Director (RDMA) on Exalogic. Using these protocols, middleware can communicate a lot faster with each other and the Oracle database than by using standard networking protocols, Seamless Integration of Ethernet over InfiniBand from Exalogic's Gateway switches into the OS, Oracle Weblogic optimizations for handling massive amounts of parallel transactions. Because if you have an 8-lane Autobahn, you also need to improve your ramps so you can feed it with many cars in parallel. Integration of Weblogic with Oracle Exadata for faster performance, optimized session management and failover. As you see, “Exabus” is Oracle's word for describing all the InfiniBand enhancements Oracle put into Exalogic: OFED stack enhancements, protocols for faster IB access, and InfiniBand support and optimizations at the virtualization and middleware level. All working together to deliver the full potential of InfiniBand performance. Who else has 100% control over their middleware so they can develop their own low-level protocol integration with InfiniBand? Even if you take an open source approach, you're looking at years of development work to create, test and support a whole new networking technology in your middleware! The Extras: Less Hassle, More Productivity, Faster Time to Market And then there are the other advantages of Engineered Systems that are true for Exalogic the same as they are for every other Engineered System: One simple purchasing process: No headaches due to endless RFPs and no “Will X work with Y?” uncertainties. Everything has been engineered together: All kinds of bugs and problems have been already fixed at the design level that would have only manifested themselves after you have built the system from scratch. Everything is built, tested and integrated at the factory level . Less integration pain for you, faster time to market. Every Exalogic machine world-wide is identical to Oracle's own machines in the lab: Instant replication of any problems you may encounter, faster time to resolution. Simplified patching, management and operations. One throat to choke: Imagine finger-pointing hell for systems that have been put together using several different vendors. Oracle's Engineered Systems have a single phone number that customers can call to get their problems solved. For more business-centric values, read The Business Value of Engineered Systems. Conclusion: Buy Exalogic, or get ready for a 6-12 Month Science Project And here's the reason why it's not easy to "build your own Exalogic": There's a lot of work required to make such a system fly. In fact, anybody who is starting to "just put together a bunch of servers and an InfiniBand network" is really looking at a 6-12 month science project. And the outcome is likely to not be very enterprise-class. And it won't have Exalogic's performance either. Because building an Engineered System is literally rocket science: It takes a lot of time, effort, resources and many iterations of design/test/analyze/fix to build such a system. That's why InfiniBand has been reserved for HPC scientists for such a long time. And only Oracle can bring the power of InfiniBand in an enterprise-class, ready-to use, pre-integrated version to customers, without the develop/integrate/support pain. For more details, check the new Exalogic overview white paper which was updated only recently. P.S.: Thanks to my colleagues Ola, Paul, Don and Andy for helping me put together this article! var flattr_uid = '26528'; var flattr_tle = 'How to Avoid Your Next 12-Month Science Project'; var flattr_dsc = 'While most customers immediately understand how the magic of Oracle's Hybrid Columnar Compression, intelligent storage servers and flash memory make Exadata uniquely powerful against home-grown database systems, some people think that Exalogic is nothing more than a bunch of x86 servers, a storage appliance and an InfiniBand (IB) network, built into a single rack.After all, isn't this exactly what the High Performance Computing (HPC) world has been doing for decades?On the surface, this may be true. And some people tried exactly that: They tried to put together their own version of Exalogic, but then they discover there's a lot more to building a system than buying hardware and assembling it together. IT is not Ikea.Why is that so? Could it be there's more going on behind the scenes than merely putting together a bunch of servers, a storage array and an InfiniBand network into a rack? Let's explore some of the special sauce that makes Exalogic unique and un-copyable, so you can save yourself from your next 6- to 12-month science project that distracts you from doing real work that adds value to your company.'; var flattr_tag = 'Engineered Systems,Engineered Systems,Infiniband,Integration,latency,Oracle,performance'; var flattr_cat = 'text'; var flattr_url = 'http://constantin.glez.de/blog/2012/04/how-avoid-your-next-12-month-science-project'; var flattr_lng = 'en_GB'

    Read the article

  • How to keep track of previous scenes and return to them in libgdx

    - by MxyL
    I have three scenes: SceneTitle, SceneMenu, SceneLoad. (The difference between the title scene and the menu scene is that the title scene is what you see when you first turn on the game, and the menu scene is what you can access during the game. During the game, meaning, after you've hit "play!" in the title scene.) I provide the ability to save progress and consequently load a particular game. An issue that I've run into is being able to easily keep track of the previous scene. For example, if you enter the load scene and then decide to change your mind, the game needs to go back to where you were before; this isn't something that can be hardcoded. Now, an easy solution off the top of my head is to simply maintain a scene stack, which basically keeps track of history for me. A simple transaction would be as follows I'm currently in the menu scene, so the top of the stack is SceneMenu I go to the load scene, so the game pushes SceneLoad onto the stack. When I return from the load scene, the game pops SceneLoad off the stack and initializes the scene that's currently at the top, which is SceneMenu I'm coding in Java, so I can't simply pass around Classes as if they were objects, so I've decided implemented as enum for eac scene and put that on the stack and then have my scene managing class go through a list of if conditions to return the appropriate instance of the class. How can I implement my scene stack without having to do too much work maintaining it?

    Read the article

< Previous Page | 28 29 30 31 32 33 34 35 36 37 38 39  | Next Page >