Search Results

Search found 1105 results on 45 pages for 'thx'.

Page 43/45 | < Previous Page | 39 40 41 42 43 44 45  | Next Page >

  • Design-time failure: WPF, Usercontrols and Namespaces

    - by Simon Woods
    Hi I have a very simple WPF project comprising a Window and Usercontrol. I'm very much in a learning phase. It works fine when I run it. However, I am unable to see the form in design time. The problem, I believe is something to do with namespaces, but I don't understand where. It may well be a simple error Main Window XML <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:views="clr-namespace:UserLogin" x:Class="UserLogin.MainView" x:Name="MainViewWindow" mc:Ignorable="d" Title="Login" Height="141" Width="347" > <Grid> <views:LoginView /> </Grid> </Window> Main Window CodeBehind Imports Microsoft.VisualBasic Imports System Imports System.Windows Imports UserLogin Namespace UserLogin Partial Public Class MainView Inherits System.Windows.Window Public Sub New() InitializeComponent() End Sub End Class End Namespace Usercontrol XAML <UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" x:Class="UserLogin.LoginView" x:Name="LoginViewControl" mc:Ignorable="d" d:DesignHeight="96" d:DesignWidth="298"> <Grid Height="96" Width="298"> <Button Command="{Binding OKCommand}" Height="21" Margin="0,0,90,16" Name="btnOK" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="76">OK</Button> <Button Command="{Binding CancelCommand}" Height="21" HorizontalAlignment="Right" Margin="0,0,9,16" Name="btnCancel" VerticalAlignment="Bottom" Width="75">Cancel</Button> <Label Height="23" HorizontalAlignment="Left" Margin="10,5,0,0" Name="Label1" VerticalAlignment="Top" Width="85">Name:</Label> <Label HorizontalAlignment="Left" Margin="10,32,0,0" Name="Label2" Width="85" Height="29" VerticalAlignment="Top">Password:</Label> <TextBox Margin="0,31,6,0" Name="txtPassword" Height="22" VerticalAlignment="Top" HorizontalAlignment="Right" Width="182" /> <ComboBox Height="22" Margin="110,6,6,0" Name="cboNames" VerticalAlignment="Top" /> </Grid> </UserControl> Usercontrol CodeBehind Imports Microsoft.VisualBasic Imports System Imports UserLogin Namespace UserLogin Partial Public Class LoginView Inherits System.Windows.Controls.UserControl Public Sub New() InitializeComponent() End Sub End Class End Namespace I think I'm missing something this namespace xmlns:views="clr-namespace:UserLogin" since intellisense doesn't give me the usercontrol declared within it in the XAML designer but rather reports the error "Unable to load the metadata for the assembly ... etc etc" Thx for any suggestions Simon

    Read the article

  • Lucene: Wildcards are missing from index

    - by Eleasar
    Hi - i am building a search index that contains special names - containing ! and ? and & and + and ... I have to tread the following searches different: me & you me + you But whatever i do (did try with queryparser escaping before indexing, escaped it manually, tried different indexers...) - if i check the search index with Luke they do not show up (question marks and @-symbols and the like show up) The logic behind is that i am doing partial searches for a live suggestion (and the fields are not that large) so i split it up into "m" and "me" and "+" and "y" and "yo" and "you" and then index it (that way it is way faster than a wildcard query search (and the index size is not a big problem). So what i would need is to also have this special wildcard characters be inserted into the index. This is my code: using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using Lucene.Net.Analysis; using Lucene.Net.Util; namespace AnalyzerSpike { public class CustomAnalyzer : Analyzer { public override TokenStream TokenStream(string fieldName, TextReader reader) { return new ASCIIFoldingFilter(new LowerCaseFilter(new CustomCharTokenizer(reader))); } } public class CustomCharTokenizer : CharTokenizer { public CustomCharTokenizer(TextReader input) : base(input) { } public CustomCharTokenizer(AttributeSource source, TextReader input) : base(source, input) { } public CustomCharTokenizer(AttributeFactory factory, TextReader input) : base(factory, input) { } protected override bool IsTokenChar(char c) { return c != ' '; } } } The code to create the index: private void InitIndex(string path, Analyzer analyzer) { var writer = new IndexWriter(path, analyzer, true); //some multiline textbox that contains one item per line: var all = new List<string>(txtAllAvailable.Text.Replace("\r","").Split('\n')); foreach (var item in all) { writer.AddDocument(GetDocument(item)); } writer.Optimize(); writer.Close(); } private static Document GetDocument(string name) { var doc = new Document(); doc.Add(new Field( "name", DeNormalizeName(name), Field.Store.YES, Field.Index.ANALYZED)); doc.Add(new Field( "raw_name", name, Field.Store.YES, Field.Index.NOT_ANALYZED)); return doc; } (Code is with Lucene.net in version 1.9.x (EDIT: sorry - was 2.9.x) but is compatible with Lucene from Java) Thx

    Read the article

  • Is my fragment usage correct, seems to be slow on adnroid

    - by Robertoq
    My app structure is that i have a menu with 5 menu-point om the left side, and the content on the right side. MainActivity.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <fragment android:id="@+id/fragmentMenu" android:name="com.example.FragmentMenu" android:layout_width="@dimen/MenuWidth" android:layout_height="match_parent" /> <LinearLayout android:id="@+id/content" android:layout_width="match_parent" android:layout_height="match_parent" android_layout_toRightOf="@+id/fragmentMenu" android:orientation="vertical"/> </RelativeLayout> MainActivity.java public class FragmentActivityMain extends FragmentActivity { @Override protected void onCreate(final Bundle arg0) { super.onCreate(arg0); setContentView(R.layout.fragment_activity_main); FragmentManager fm = getSupportFragmentManager(); FragmentMenu fragmentMenu = (FragmentMenu) fm.findFragmentById(R.id.fragmentMenu); fragmentMenu.init(); } } And certainly I have a FragmenMenu class, public class FragmentMenu extends ListFragment { @Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_menu, container, false); return view; } public init() { FragmentManager fm = getFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); FragmentNowListView lw = new FragmentCarListView(); ft.add(R.id.content, lw); ft.commit(); } } The FragmentCarList is a simple list, now with static test data, only five items in a List My Problem: Slow. I tested the app on my phone (Galaxy S3) and I see white screen when app starting, around 0,5 second and this is the log: 10-29 11:43:44.093: D/dalvikvm(29710): GC_CONCURRENT freed 267K, 5% free 13903K/14535K, paused 10ms+2ms 10-29 11:43:44.133: D/dalvikvm(29710): GC_FOR_ALLOC freed 215K, 6% free 13896K/14663K, paused 12ms 10-29 11:43:44.233: D/dalvikvm(29710): GC_FOR_ALLOC freed 262K, 6% free 13901K/14663K, paused 12ms 10-29 11:43:44.258: D/dalvikvm(29710): GC_FOR_ALLOC freed 212K, 6% free 13897K/14663K, paused 13ms 10-29 11:43:44.278: D/dalvikvm(29710): GC_FOR_ALLOC freed 208K, 6% free 13897K/14663K, paused 12ms 10-29 11:43:44.328: D/dalvikvm(29710): GC_FOR_ALLOC freed 131K, 4% free 14098K/14663K, paused 12ms 10-29 11:43:44.398: D/dalvikvm(29710): GC_CONCURRENT freed 20K, 3% free 14559K/14919K, paused 1ms+4ms And when I tested on Xperia Ray, the whit screen appear longer time. How can I optimize my fragments? Thx

    Read the article

  • c#: Design advice. Using DataTable or List<MyObject> for a generic rule checker

    - by Andrew White
    Hi, I have about 100,000 lines of generic data. Columns/Properties of this data are user definable and are of the usual data types (string, int, double, date). There will be about 50 columns/properties. I have 2 needs: To be able to calculate new columns/properties using an expression e.g. Column3 = Column1 * Column2. Ultimately I would like to be able to use external data using a callback, e.g. Column3 = Column1 * GetTemperature The expression is relatively simple, maths operations, sum, count & IF are the only necessary functions. To be able to filter/group the data and perform aggregations e.g. Sum(Data.Column1) Where(Data.Column2 == "blah") As far as I can see I have two options: 1. Using a DataTable. = Point 1 above is achieved by using DataColumn.Expression = Point 2 above is acheived by using DataTable.DefaultView.RowFilter & C# code 2. Using a List of generic Objects each with a Dictionary< string, object to store the values. = Point 1 could be achieved by something like NCalc = Point 2 is achieved using LINQ DataTable: Pros: DataColumn.Expression is inbuilt Cons: RowFilter & coding c# is not as "nice" as LINQ, DataColumn.Expression does not support callbacks(?) = workaround could be to get & replace external value when creating the calculated column GenericList: Pros: LINQ syntax, NCalc supports callbacks Cons: Implementing NCalc/generic calc engine Based on the above I would think a GenericList approach would win, but something I have not factored in is the performance which for some reason I think would be better with a datatable. Does anyone have a gut feeling / experience with LINQ vs. DataTable performance? How about NCalc? As I said there are about 100,000 rows of data, with 50 columns, of which maybe 20 are calculated. In total about 50 rules will be run against the data, so in total there will be 5 million row/object scans. Would really appreciate any insights. Thx. ps. Of course using a database + SQL & Views etc. would be the easiest solution, but for various reasons can't be implemented.

    Read the article

  • Assembly Load and loading the "sub-modules" dependencies - "cannot find the file specified"

    - by Ted
    There are several questions out there that ask the same question. However the answers they received I cannot understand, so here goes: Similar questions: http://stackoverflow.com/questions/1874277/dynamically-load-assembly-and-manually-force-path-to-get-referenced-assemblies ; http://stackoverflow.com/questions/22012/loading-assemblies-and-its-dependencies-closed The question in short: I need to figure out how dependencies, ie References in my modules can be loaded dynamically. Right now I am getting "The system cannot find the file specified" on Assemblies referenced in my so called modules. I cannot really get how to use the AssemblyResolve event... The longer version I have one application, MODULECONTROLLER, that loads separate modules. These "separate modules" are located in well-known subdirectories, like appBinDir\Modules\Module1 appBinDir\Modules\Module2 Each directory contains all the DLLs that exists in the bin-directory of those projects after a build. So the MODULECONTROLLER loads all the DLLs contained in those folders using this code: byte[] bytes = File.ReadAllBytes(dllFileFullPath); Assembly assembly = null; assembly = Assembly.Load(bytes); I am, as you can see, loading the byte[]-array (so I dont lock the DLL-files). Now, in for example MODULE1, I have a static reference called MyGreatXmlProtocol. The MyGreatXmlProtocol.dll then also exists in the directory appBinDir\Modules\Module1 and is loaded using the above code When code in the MODULE1 tries to use this MyGreatXmlProtocol, I get: Could not load file or assembly 'MyGreatXmlProtocol, Version=1.0.3797.26527, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. So, in a post (like this one) they say that To my understanding reflection will load the main assembly and then search the GAC for the referenced assemblies, if it cannot find it there, you can then incorparate an assemblyResolve event: First; is it really needed to use the AssemblyResolve-event to make this work? Shouldnt my different MODULEs themself load their DLLs, as they are statically referenced? Second; if AssemblyResolve is the way to go - how do I use it? I have attached a handler to the Event but I never get anything on MyGreatXmlProctol... === EDIT === CODE regarding the AssemblyResolve-event handler: public GUI() { InitializeComponent(); AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); ... } // Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) { Console.WriteLine(args.Name); return null; } Hope I wasnt too fuzzy =) Thx

    Read the article

  • How to keep a local value from being set when a binding fails (so inherited values will propagate)

    - by redoced
    Consider the following scenario: I want to bind the TextElement.FontWeight property to an xml attribute. The xml looks somewhat like this and has arbitrary depth. <text font-weight="bold"> bold text here <inlinetext>more bold text</inlinetext> even more bold text </text> I use hierarchical templating to display the text, no problem there, but having a Setter in the template style like: <Setter Property="TextElement.FontWeight" Value="{Binding XPath=@font-weight}"/> sets the fontweight correctly on the first level, but overwrites the second level with null (as the binding can't find the xpath) which reverts to Fontweight normal. I tried all sorts of things here but nothing quite seems to work. e.g. i used a converter to return UnsetValue, which didn't work. I'm currently trying with: <Setter Property="custom:AttributeInserter.Wrapper" Value="{custom:AttributeInserter Property=TextElement.FontWeight, Binding={Binding XPath=@font-weight}}"/> Codebehind: public static class AttributeInserter { public static AttributeInserterExtension GetWrapper(DependencyObject obj) { return (AttributeInserterExtension)obj.GetValue(WrapperProperty); } public static void SetWrapper(DependencyObject obj, AttributeInserterExtension value) { obj.SetValue(WrapperProperty, value); } // Using a DependencyProperty as the backing store for Wrapper. This enables animation, styling, binding, etc... public static readonly DependencyProperty WrapperProperty = DependencyProperty.RegisterAttached("Wrapper", typeof(AttributeInserterExtension), typeof(AttributeInserter), new UIPropertyMetadata(pcc)); static void pcc(DependencyObject o,DependencyPropertyChangedEventArgs e) { var n=e.NewValue as AttributeInserterExtension; var c = o as FrameworkElement; if (n == null || c==null || n.Property==null || n.Binding==null) return; var bex = c.SetBinding(n.Property, n.Binding); bex.UpdateTarget(); if (bex.Status == BindingStatus.UpdateTargetError) c.ClearValue(n.Property); } } public class AttributeInserterExtension : MarkupExtension { public override object ProvideValue(IServiceProvider serviceProvider) { return this; } public DependencyProperty Property { get; set; } public Binding Binding { get; set; } } which kinda works, but can't track changes of the property Any ideas? Any links? thx for the help

    Read the article

  • Restore previously serialized JFrame-object, how?

    - by elementz
    Hi all. I have managed to serialize my very basic GUI-object containing a JTextArea and a few buttons to a file 'test.ser'. Now, I would like to completely restore the previously saved state from 'test.ser', but seem to have a misconception of how to properly deserialize an objects state. The class MyFrame creates the JFrame and serializes it. public class MyFrame extends JFrame implements ActionListener { // Fields JTextArea textArea; String title; static MyFrame gui = new MyFrame(); private static final long serialVersionUID = 1125762532137824262L; /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub gui.run(); } // parameterless default contructor public MyFrame() { } // constructor with title public MyFrame(String title) { } // creates Frame and its Layout public void run() { JFrame frame = new JFrame(title); JPanel panel_01 = new JPanel(); JPanel panel_02 = new JPanel(); JTextArea textArea = new JTextArea(20, 22); textArea.setLineWrap(true); JScrollPane scrollPane = new JScrollPane(textArea); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); panel_01.add(scrollPane); // Buttons JButton saveButton = new JButton("Save"); saveButton.addActionListener(this); JButton loadButton = new JButton("Load"); loadButton.addActionListener(this); panel_02.add(loadButton); panel_02.add(saveButton); // Layout frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(BorderLayout.CENTER, panel_01); frame.getContentPane().add(BorderLayout.SOUTH, panel_02); frame.setSize(300, 400); frame.setVisible(true); } /* * */ public void serialize() { try { ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("test.ser")); oos.writeObject(gui); oos.close(); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); } } public void actionPerformed(ActionEvent ev) { System.out.println("Action received!"); gui.serialize(); } } Here I try to do the deserialization: public class Deserialize { static Deserialize ds; static MyFrame frame; public static void main(String[] args) { try { ObjectInputStream ois = new ObjectInputStream(new FileInputStream("test.ser")); frame = (MyFrame) ois.readObject(); ois.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } Maybe somebody could point me into the direction where my misconception is? Thx in advance!

    Read the article

  • [C#] Problems with implementing generic IEnumerator and IComparable

    - by r0h
    Hi all! I'm working on an AVL Tree. The tree itself seems to be working but I need a iterator to walk through the values of the tree. Therefore I tried to implement the IEnumerator interace. Unfortunately I get a compile time error implementing IEnumerator and IComparable. First the code and below that the error. class AvlTreePreOrderEnumerator<T> : IEnumerator<T> where T :IComparable<T> { private AvlTreeNode<T> current = default(T); private AvlTreeNode<T> tree = null; private Queue<AvlTreeNode<T>> traverseQueue = null; public AvlTreePreOrderEnumerator(AvlTreeNode<T> tree) { this.tree = tree; //Build queue traverseQueue = new Queue<AvlTreeNode<T>>(); visitNode(this.tree.Root); } private void visitNode(AvlTreeNode<T> node) { if (node == null) return; else { traverseQueue.Enqueue(node); visitNode(node.LeftChild); visitNode(node.RightChild); } } public T Current { get { return current.Value; } } object IEnumerator.Current { get { return Current; } } public void Dispose() { current = null; tree = null; } public void Reset() { current = null; } public bool MoveNext() { if (traverseQueue.Count > 0) current = traverseQueue.Dequeue(); else current = null; return (current != null); } } The error given by VS2008: Error 1 The type 'T' cannot be used as type parameter 'T' in the generic type or method 'Opdr2_AvlTreeTest_Final.AvlTreeNode'. There is no boxing conversion or type parameter conversion from 'T' to 'System.IComparable'. For now I've not included the tree and node logic. I anybody thinks is necessary to resolve this probleem, just say so! Thx!

    Read the article

  • Assembly Load and loading the "sub-modules" dependencies - "cannot fild the file specified"

    - by Ted
    There are several questions out there that ask the same question. However the answers they received I cannot understand, so here goes: Similar questions: http://stackoverflow.com/questions/1874277/dynamically-load-assembly-and-manually-force-path-to-get-referenced-assemblies ; http://stackoverflow.com/questions/22012/loading-assemblies-and-its-dependencies-closed The question in short: I need to figure out how dependencies, ie References in my modules can be loaded dynamically. Right now I am getting "The system cannot find the file specified" on Assemblies referenced in my so called modules. I cannot really get how to use the AssemblyResolve event... The longer version I have one application, MODULECONTROLLER, that loads separate modules. These "separate modules" are located in well-known subdirectories, like appBinDir\Modules\Module1 appBinDir\Modules\Module2 Each directory contains all the DLLs that exists in the bin-directory of those projects after a build. So the MODULECONTROLLER loads all the DLLs contained in those folders using this code: byte[] bytes = File.ReadAllBytes(dllFileFullPath); Assembly assembly = null; assembly = Assembly.Load(bytes); I am, as you can see, loading the byte[]-array (so I dont lock the DLL-files). Now, in for example MODULE1, I have a static reference called MyGreatXmlProtocol. The MyGreatXmlProtocol.dll then also exists in the directory appBinDir\Modules\Module1 and is loaded using the above code When code in the MODULE1 tries to use this MyGreatXmlProtocol, I get: Could not load file or assembly 'MyGreatXmlProtocol, Version=1.0.3797.26527, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. So, in a post (like this one) they say that To my understanding reflection will load the main assembly and then search the GAC for the referenced assemblies, if it cannot find it there, you can then incorparate an assemblyResolve event: First; is it really needed to use the AssemblyResolve-event to make this work? Shouldnt my different MODULEs themself load their DLLs, as they are statically referenced? Second; if AssemblyResolve is the way to go - how do I use it? I have attached a handler to the Event but I never get anything on MyGreatXmlProctol... === EDIT === CODE regarding the AssemblyResolve-event handler: public GUI() { InitializeComponent(); AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); ... } // Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) { Console.WriteLine(args.Name); return null; } Hope I wasnt too fuzzy =) Thx

    Read the article

  • How do I pass the value of the previous form element into an "onchange" javascript function?

    - by Jen
    Hello, I want to make some UI improvements to a page I am developing. Specifically, I need to add another drop down menu to allow the user to filter results. This is my current code: HTML file: <select name="test_id" onchange="showGrid(this.name, this.value, 'gettestgrid')"> <option selected>Select a test--></option> <option value=1>Test 1</option> <option value=2>Test 2</option> <option value=3>Test 3</option> </select> This is pseudo code for what I want to happen: <select name="test_id"> <option selected>Select a test--></option> <option value=1>Test 1</option> <option value=2>Test 2</option> <option value=3>Test 3</option> </select> <select name="statistics" onchange="showGrid(PREVIOUS.name, PREVIOUS.VALUE, THIS.value)"> <option selected>Select a data display --></option> <option value='gettestgrid'>Show averages by student</option> <option value='gethomeroomgrid'>Show averages by homeroom</option> <option value='getschoolgrid'>Show averages by school</option> </select> How do I access the previous field's name and value? Any help much appreciated, thx! Also, JS function for reference: function showGrid(name, value, phpfile) { xmlhttp=GetXmlHttpObject(); if (xmlhttp==null) { alert ("Browser does not support HTTP Request"); return; } var url=phpfile+".php"; url=url+"?"+name+"="+value; url=url+"&sid="+Math.random(); xmlhttp.onreadystatechange=stateChanged; xmlhttp.open("GET",url,true); xmlhttp.send(null); }

    Read the article

  • grdb not working variables

    - by stupid_idiot
    hi, i know this is kinda retarded but I just can't figure it out. I'm debugging this: xor eax,eax mov ah,[var1] mov al,[var2] call addition stop: jmp stop var1: db 5 var2: db 6 addition: add ah,al ret the numbers that I find on addresses var1 and var2 are 0x0E and 0x07. I know it's not segmented, but that ain't reason for it to do such escapades, because the addition call works just fine. Could you please explain to me where is my mistake? I see the problem, dunno how to fix it yet though. The thing is, for some reason the instruction pointer starts at 0x100 and all the segment registers at 0x1628. To address the instruction the used combination is i guess [cs:ip] (one of the segment registers and the instruction pointer for sure). The offset to var1 is 0x10 (probably because from the begining of the code it's the 0x10th byte in order), i tried to examine the memory and what i got was: 1628:100 8 bytes 1628:108 8 bytes 1628:110 <- wtf? (assume another 8 bytes) 1628:118 ... whatever tricks are there in the memory [cs:var1] points somewhere else than in my code, which is probably where the label .data would usually address ds.... probably.. i don't know what is supposed to be at 1628:10 ok, i found out what caused the assness and wasted me whole fuckin day. the behaviour described above is just correct, the code is fully functional. what i didn't know is that grdb debugger for some reason sets the begining address to 0x100... the sollution is to insert the directive ORG 0x100 on the first line and that's the whole thing. the code was working because instruction pointer has the right address to first instruction and goes one by one, but your assembler doesn't know what effective address will be your program stored at so it pretty much remains relative to first line of the code which means all the variables (if not using label for data section) will remain pointing as if it started at 0x0. which of course wouldn't work with DOS. and grdb apparently emulates some DOS features... sry for the language, thx everyone for effort, hope this will spare someone's time if having the same problem... heheh.. at least now i know the reason why to use .data section :))))

    Read the article

  • C++ DLL creation for C# project - No functions exported

    - by Yeti
    I am working on a project that requires some image processing. The front end of the program is C# (cause the guys thought it is a lot simpler to make the UI in it). However, as the image processing part needs a lot of CPU juice I am making this part in C++. The idea is to link it to the C# project and just call a function from a DLL to make the image processing part and allow to the C# environment to process the data afterwards. Now the only problem is that it seems I am not able to make the DLL. Simply put the compiler refuses to put any function into the DLL that I compile. Because the project requires some development time testing I have created two projects into a C++ solution. One is for the Dll and another console application. The console project holds all the files and I just include the corresponding header into my DLL project file. I thought the compiler should take out the functions that I marked as to be exported and make the DLL from them. Nevertheless this does not happens. Here it is how I defined the function in the header: extern "C" __declspec(dllexport) void _stdcall RobotData(BYTE* buf, int** pToNewBackgroundImage, int* pToBackgroundImage, bool InitFlag, ObjectInformation* robot1, ObjectInformation* robot2, ObjectInformation* robot3, ObjectInformation* robot4, ObjectInformation* puck); extern "C" __declspec(dllexport) CvPoint _stdcall RefPointFinder(IplImage* imgInput, CvRect &imgROI, CvScalar &refHSVColorLow, CvScalar &refHSVColorHi ); Followed by the implementation in the cpp file: extern "C" __declspec(dllexport) CvPoint _stdcall RefPointFinder(IplImage* imgInput, CvRect &imgROI,&refHSVColorLow, CvScalar &refHSVColorHi ) { \\... return cvPoint((int)( M10/M00) + imgROI.x, (int)( M01/M00 ) + imgROI.y) ;} extern "C" __declspec(dllexport) void _stdcall RobotData(BYTE* buf, int** pToNewBackgroundImage, int* pToBackgroundImage, bool InitFlag, ObjectInformation* robot1, ObjectInformation* robot2, ObjectInformation* robot3, ObjectInformation* robot4, ObjectInformation* puck) { \\ ...}; And my main file for the DLL project looks like: #ifdef _MANAGED #pragma managed(push, off) #endif /// <summary> Include files. </summary> #include "..\ImageProcessingDebug\ImageProcessingTest.h" #include "..\ImageProcessingDebug\ImageProcessing.h" BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { return TRUE; } #ifdef _MANAGED #pragma managed(pop) #endif Needless to say it does not work. A quick look with DLL export viewer 1.36 reveals that no function is inside the library. I don't get it. What I am doing wrong ? As side not I am using the C++ objects (and here it is the C++ DLL part) such as the vector. However, only for internal usage. These will not appear in the headers of either function as you can observe from the previous code snippets. Any ideas? Thx, Bernat

    Read the article

  • javascript-aware html parser for Python ~

    - by znetor
    <html> <head> <script type="text/javascript"> document.write('<a href="http://www.google.com">f*** js</a>'); document.write("f*** js!"); </script> </head> <body> <script type="text/javascript"> document.write('<a href="http://www.google.com">f*** js</a>'); document.write("f*** js!"); </script> <div><a href="http://www.google.com">f*** js</a></div> </body> </html> I want use xpath to catch all lable object in the html page above... In [1]: import lxml.html as H In [2]: f = open("test.html","r") In [3]: c = f.read() In [4]: doc = H.document_fromstring(c) In [5]: doc.xpath('//a') Out[5]: [<Element a at a01d17c>] In [6]: a = doc.xpath('//a')[0] In [7]: a.getparent() Out[7]: <Element div at a01d41c> I only get one don't generate by js~ but firefox xpath checker can find all lable!? http://i.imgur.com/0hSug.png how to do that??? thx~! <html> <head> </head> <body> <script language="javascript"> function over(){ a.innerHTML="mouse me" } function out(){ a.innerHTML="<a href='http://www.google.com'>google</a>" } </script> <body><li id="a"onmouseover="over()" onmouseout="out()">mouse me</li> </body> </html>

    Read the article

  • No Method Error Undefined method 'save' for nil:NilClass

    - by BennyB
    I'm getting this error when i try to create a "Lecture" via my Lecture controller's create method. This used to work but i went on to work on other parts of the app & then of course i come back & something is now throwing this error when a user tries to create a Lecture in my app. I'm sure its something small i'm just overlooking (been at it a while & probably need to take a break)...but I'd appreciate if someone could let me know why this is happening...let me know if i need to post anything else...thx! The error I get NoMethodError in LecturesController#create undefined method `save' for nil:NilClass Rails.root: /Users/name/Sites/rails_projects/app_name Application Trace | Framework Trace | Full Trace app/controllers/lectures_controller.rb:13:in `create' My view to create a new Lecture views/lectures/new.html.erb <% provide(:title, 'Start a Lecture') %> <div class="container"> <div class="content-wrapper"> <h1>Create a Lecture</h1> <div class="row"> <div class="span 6 offset3"> <%= form_for(@lecture) do |f| %> <%= render 'shared/error_messages', :object => f.object %> <div class="field"> <%= f.text_field :title, :placeholder => "What will this Lecture be named?" %> <%= f.text_area :content, :placeholder => "Describe this Lecture & what will be learned..." %> </div> <%= f.submit "Create this Lecture", :class => "btn btn-large btn-primary" %> <% end %> </div> </div> </div> </div> Then my controller where its saying the error is coming from controllers/lectures_controller.rb class LecturesController < ApplicationController before_filter :signed_in_user, :only => [:create, :destroy] before_filter :correct_user, :only => :destroy def index end def new @lecture = current_user.lectures.build if signed_in? end def create if @lecture.save flash[:success] = "Lecture created!" redirect_to @lecture else @activity_items = [ ] render 'new' end end def show @lecture = Lecture.find(params[:id]) end def destroy @lecture.destroy redirect_to root_path end private def correct_user @lecture = current_user.lectures.find_by_id(params[:id]) redirect_to root_path if @lecture.nil? end

    Read the article

  • [iPhone Obj-C] How to move a label with the wave of the iPhone?

    - by Didi
    The code below is from the book Beginning iPhone 3 Development, chapter 15, using the accelerometer to control a ball. I want to use a label instead of the ball, and only move in the x direction. However, I donno how to revise the code to achieve this goal. Can anyone please help me? THX so much!!!! (id)initWithCoder:(NSCoder *)coder { if (self = [super initWithCoder:coder]) { self.image = [UIImage imageNamed:@"ball.png"]; self.currentPoint = CGPointMake((self.bounds.size.width / 2.0f) + (image.size.width / 2.0f), (self.bounds.size.height / 2.0f) + (image.size.height / 2.0f)); ballXVelocity = 0.0f; ballYVelocity = 0.0f; } return self; } (id)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { // Initialization code } return self; } (void)drawRect:(CGRect)rect { // Drawing code [image drawAtPoint:currentPoint]; } (void)dealloc { [image release]; [acceleration release]; [super dealloc]; } //#pragma mark - - (CGPoint)currentPoint { return currentPoint; } - (void)setCurrentPoint:(CGPoint)newPoint { previousPoint = currentPoint; currentPoint = newPoint; if (currentPoint.x < 0) { currentPoint.x = 0; //ballXVelocity = 0; ballXVelocity = - (ballXVelocity / 2.0); } if (currentPoint.y < 0){ currentPoint.y = 0; //ballYVelocity = 0; ballYVelocity = - (ballYVelocity / 2.0); } if (currentPoint.x > self.bounds.size.width - image.size.width) { currentPoint.x = self.bounds.size.width - image.size.width; //ballXVelocity = 0; ballXVelocity = - (ballXVelocity / 2.0); } if (currentPoint.y > self.bounds.size.height - image.size.height) { currentPoint.y = self.bounds.size.height - image.size.height; //ballYVelocity = 0; ballYVelocity = - (ballYVelocity / 2.0); } CGRect currentImageRect = CGRectMake(currentPoint.x, currentPoint.y, currentPoint.x + image.size.width, currentPoint.y + image.size.height); CGRect previousImageRect = CGRectMake(previousPoint.x, previousPoint.y, previousPoint.x + image.size.width, currentPoint.y + image.size.width); [self setNeedsDisplayInRect:CGRectUnion(currentImageRect, previousImageRect)]; } (void)draw { static NSDate *lastDrawTime; if (lastDrawTime != nil) { NSTimeInterval secondsSinceLastDraw = -([lastDrawTime timeIntervalSinceNow]); ballYVelocity = ballYVelocity + -(acceleration.y * secondsSinceLastDraw); ballXVelocity = ballXVelocity + acceleration.x * secondsSinceLastDraw; CGFloat xAcceleration = secondsSinceLastDraw * ballXVelocity * 500; CGFloat yAcceleration = secondsSinceLastDraw * ballYVelocity * 500; self.currentPoint = CGPointMake(self.currentPoint.x + xAcceleration, self.currentPoint.y +yAcceleration); } // Update last time with current time [lastDrawTime release]; lastDrawTime = [[NSDate alloc] init]; }

    Read the article

  • Windows MAchine Debugging

    - by PrettyFlower
    I've been learning how to program for Windows for some time now and am getting pretty comfy with COM. I had thought to go over to Linux and do some C++ programming there and I wished to run Rosetta Commons so I installed Fedora. I had tried installing Ubuntu a few months ago and things got messy. I had a glitch, maybe caused by one of the live cd creators, my video card or something I don't know. Who Crashed suggested it was my video card and I had regular messages about ntfs.sys and page file issues. At any rate I just installed Fedora and the same thing is happening again. I would like to think with the twenty five years of doing this that I might finally make some headway into debugging my system. I think I may have overlooked a lot of what could be done in favor of simply uninstalling, reinstalling and formatting and starting from scratch. I have opened up the folder windows debugging tools, quite accidentally and just before I was going to clean sweep again, and I found KD and WinDbg. I had never seen these before and I felt that maybe I should look into this. I am quite familiar with the modern machine that is known as the computer, I know what a Kernel is and am now pretty familiar with at the very least Windows Operating System Services. I wish to begin tracking my own machines errors. I understand that most kernel debugging is done on a second machine but I don't have one. And also I understand the goal of the debugger seems to be less about run of the mill errors and more about development time strategies but I'm sure there is more to this. This is my first go at this and I thought maybe I could get some suggestions on where to go from here. I would really like to learn ways to fix my machine and also maybe pick up some tricks on the dev side as well. I hope this isn't too broad a question or too generalized. I'm really just looking for the keywords and an overview of the more routine strategies used. thx

    Read the article

  • PHP uploads and checking

    - by user147685
    Hi all, I want to update/insert file by using upload box to the database but before that it will check for the file type thats only pdf can be upload. Somthing wrong with the codes and i dont know what..Please help here are part of my updates codes: $id=$rs['id']; $qry = "SELECT a.faillampiran FROM {$CFG->prefix}ptk_lampiran a, {$CFG->prefix}ptk b WHERE a.ptkid=$id and b.id=$id"; $sql = get_records_sql($qry); if($_POST['check']){ $ext = pathinfo($faillampiran,PATHINFO_EXTENSION); $err = "Upload Only PDF File. "; if ($ext =='pdf'){ $qry="UPDATE {$CFG->prefix}ptk_lampiran SET faillampiran='".$faillampiran."' WHERE ptkid='".$_GET['id']."'"; $sql=mysql_query($qry); $qry = "SELECT a.faillampiran FROM {$CFG->prefix}ptk_lampiran a, {$CFG->prefix}ptk b WHERE b.id = '".$rs[id]."' AND a.ptkid = '".$rs[id]."' "; $sql = get_records_sql($qry); foreach($sql as $rs){ ?> <?=basename($rs->faillampiran); ?><br> <? } ?> <tr><td></td><td></td><td> <input type="file" size="50" name="faillampiran" alt="faillampiran" value= "<?=$faillampiran;?>" /> <input type="submit" name="edit" value="Muat naik fail ini" /><br /> </td></tr> } else { echo "<script>alert('$err')</script>"; } } else { foreach($sql as $rs){ ?> <?=basename($rs->faillampiran); ?><br> <? } ?> <input type="file" size="50" name="faillampiran" alt="faillampiran" value= "<?=$faillampiran;?>" /> <input type="submit" name="edit" value="Muat naik fail ini" /><br /> <?} Sori bout the messiness of the codes, im still a beginner in this languages. thx

    Read the article

  • Getting Frequency Components with FFT

    - by ruhig brauner
    so I was able to solv my last problem but i stubmled upon the next already. So I want to make a simple spectrogram but in oder to do so I want to understand how FFT-libaries work and what they actually calculate and return. (FFT and Signal Processing is the number 1 topic I will get into as soon as I have time but right now, I only have time for some programming exercises in the evening. ;) ) Here I just summarized the most important parts: int framesPerSecond; int samplesPerSecond; int samplesPerCycle; // right now i want to refresh the spectogram every DoubleFFT_1D fft; WAVReader audioIn; double audioL[], audioR[]; double fftL[], fftR[]; ..... framesPerSecond = 30; audioIn= new WAVReader("Strobe.wav"); int samplesPerSecond = (int)audioIn.GetSampleRate(); samplesPerCycle = (int)(audioIn.GetSampleRate()/framesPerSecond); audioL = new double[samplesPerCycle*2]; audioR = new double[samplesPerCycle*2]; fftL = new double[samplesPerCycle]; fftR = new double[samplesPerCycle]; for(int i = 0; i < samplesPerCycle; i++) { // don't even know why,... fftL[i] = 0; fftR[i] = 0; } fft = new DoubleFFT_1D(samplesPerCycle); ..... for(int i = 0; i < samplesPerCycle; i++) { audioIn.GetStereoSamples(temp); audioL[i]=temp[0]; audioR[i]=temp[1]; } fft.realForwardFull(audioL); //still stereo fft.realForwardFull(audioR); System.out.println("Check"); for(int i = 0; i < samplesPerCycle; i++) { //storing the magnitude in the fftL/R arrays fftL[i] = Math.sqrt(audioL[2*i]*audioL[2*i] + audioL[2*i+1]*audioL[2*i+1]); fftR[i] = Math.sqrt(audioR[2*i]*audioR[2*i] + audioR[2*i+1]*audioR[2*i+1]); } So the question is, if I want to know, what frequencys are in the sampled signal, how do I calculate them? (When I want to print the fftL / fftR arrays, I get some exponential formes at both ends of the array.) Thx :)

    Read the article

  • How can i use the Orientation correct for images

    - by user3578109
    I´m learning android/java by myself @the moment and i have a problem with a part of my app i´m learning on. I made the code with help of the www and my problem is that if i open an image from the gallery it´s send to the edit activity but in the activity pictures what are made in portrait mode are displayed always wrong (90° to the right side).... The codes are Matrix private Bitmap rotateBitmapToOrientation(Bitmap b, int orientation){ Matrix matrix = new Matrix(); matrix.postRotate(orientation); Canvas offscreenCanvas = new Canvas(); offscreenCanvas.drawBitmap(b, matrix, null); return b; } and the other one @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case PICK_IMAGE_FROM_GALLERY: { if (resultCode == RESULT_OK) { Log.d(TAG, "Got Picture!"); Log.d(TAG,"File type - " + data.getType()); Uri photoUri = data.getData(); if (photoUri != null) { try { String[] filePathColumn = {MediaStore.Images.Media.DATA}; String[] orientationColumn = {MediaStore.Images.Media.ORIENTATION}; int orientation = -1; Cursor cursor = getContentResolver().query(photoUri, filePathColumn, null, null, null); cursor.moveToFirst(); int columnIndex = cursor.getColumnIndex(filePathColumn[0]); String filePath = cursor.getString(columnIndex); cursor.close(); cursor = getContentResolver().query(photoUri, orientationColumn, null, null, null); if(cursor != null && cursor.moveToFirst()){ orientation = cursor.getInt(cursor.getColumnIndex(orientationColumn[0])); } cursor.close(); HashMap<String, Integer> pRes = this.getImageResolutionSetting(); Bitmap shrunkenBitmap = FileUtilsHelper.shrinkBitmap(filePath, pRes.get("width"), pRes.get("height")); shrunkenBitmap = rotateBitmapToOrientation(shrunkenBitmap, orientation); String res = FileUtilsHelper.saveBitmapAsJpeg(shrunkenBitmap, this); Log.d(TAG,"File Path: " + res); shrunkenBitmap.recycle(); Intent editImage = new Intent(this, EditImage.class); editImage.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT); editImage.putExtra("stuff.path", res); startActivity(editImage); }catch(Exception e){ Toast.makeText(this, R.string.cant_save_image,Toast.LENGTH_SHORT).show(); } } } } break; } }} I don´t know what i´m doing wrong... I could really need a teacher on that :) Thx for your help dudes!!

    Read the article

  • apache2 how to trace caller of SIGTERM

    - by art vanderlay
    I have a dex x64 on a virtualbox win7pro host. My apache2 will stop responding after a page request or other activity such as upload via ftp. The php.cgi becomes non responsive and a restart is required any help tracking down the culprit sending the SIGTERM would be much appreciated. thx Art my apache2.conf has <IfModule mpm_prefork_module> ServerLimit 1024 StartServers 10 MinSpareServers 10 MaxSpareServers 20 MaxClients 1024 MaxRequestsPerChild 0 </IfModule> ` From the apache2 log I have [Wed Jun 20 05:07:01 2012] [notice] caught SIGTERM, shutting down [Wed Jun 20 05:07:03 2012] [notice] FastCGI: process manager initialized (pid 4369) [Wed Jun 20 05:07:03 2012] [notice] Apache/2.2.16 (Debian) mod_fastcgi/2.4.6 PHP/5.3.3-7+squeeze13 with Suhosin-Patch mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations and from the accounting output with lastcomm php.cgi www-data __ 0.13 secs Wed Jun 20 04:49 lastcomm root pts/2 0.10 secs Wed Jun 20 04:49 php.cgi www-data __ 0.18 secs Wed Jun 20 04:49 php.cgi www-data __ 0.18 secs Wed Jun 20 04:47 apache2 root pts/1 0.02 secs Wed Jun 20 04:46 tput root pts/1 0.00 secs Wed Jun 20 04:46 apache2 F root pts/1 0.00 secs Wed Jun 20 04:46 apache2ctl root pts/1 0.00 secs Wed Jun 20 04:46 apache2 S root pts/1 0.77 secs Wed Jun 20 04:46 rm root pts/1 0.01 secs Wed Jun 20 04:46 install root pts/1 0.01 secs Wed Jun 20 04:46 mkdir root pts/1 0.00 secs Wed Jun 20 04:46 apache2ctl F root pts/1 0.00 secs Wed Jun 20 04:46 sleep root pts/1 0.00 secs Wed Jun 20 04:46 apache2 SF root __ 0.54 secs Wed Jun 20 04:34 apache2 SF www-data __ 0.14 secs Wed Jun 20 04:34 apache2 SF www-data __ 0.07 secs Wed Jun 20 04:34 apache2 SF www-data __ 0.06 secs Wed Jun 20 04:36 apache2 SF www-data __ 0.07 secs Wed Jun 20 04:34 apache2 SF www-data __ 0.11 secs Wed Jun 20 04:34 apache2 SF www-data __ 0.02 secs Wed Jun 20 04:34 apache2 SF www-data __ 0.04 secs Wed Jun 20 04:34 apache2 SF www-data __ 0.06 secs Wed Jun 20 04:34 apache2 SF www-data __ 0.08 secs Wed Jun 20 04:34 apache2 SF www-data __ 0.03 secs Wed Jun 20 04:34 apache2 SF www-data __ 0.02 secs Wed Jun 20 04:34 apache2 SF www-data __ 0.01 secs Wed Jun 20 04:34 grep root pts/1 0.00 secs Wed Jun 20 04:46 apache2ctl root pts/1 0.02 secs Wed Jun 20 04:46 apache2 root pts/1 0.24 secs Wed Jun 20 04:46 apache2 SF www-data __ 0.00 secs Wed Jun 20 04:34 apache2ctl F root pts/1 0.00 secs Wed Jun 20 04:46 apache2ctl root pts/1 0.00 secs Wed Jun 20 04:46 apache2 root pts/1 0.22 secs Wed Jun 20 04:46 apache2ctl F root pts/1 0.01 secs Wed Jun 20 04:46 apache2 F root pts/1 0.00 secs Wed Jun 20 04:46 grep root pts/1 0.00 secs Wed Jun 20 04:46 tr root pts/1 0.00 secs Wed Jun 20 04:46 pidof S root pts/1 0.11 secs Wed Jun 20 04:46 cat root pts/1 0.00 secs Wed Jun 20 04:46 apache2 F root pts/1 0.00 secs Wed Jun 20 04:46 grep root pts/1 0.00 secs Wed Jun 20 04:46 tr root pts/1 0.00 secs Wed Jun 20 04:46 pidof S root pts/1 0.05 secs Wed Jun 20 04:46 cat root pts/1 0.01 secs Wed Jun 20 04:46 apache2 F root pts/1 0.00 secs Wed Jun 20 04:46 apache2ctl root pts/1 0.00 secs Wed Jun 20 04:46 apache2 root pts/1 0.34 secs Wed Jun 20 04:46 apache2ctl F root pts/1 0.00 secs Wed Jun 20 04:46 apache2 F root pts/1 0.00 secs Wed Jun 20 04:46 apache2 F root pts/1 0.00 secs Wed Jun 20 04:46 smbd SF root __ 0.25 secs Wed Jun 20 04:46 php.cgi www-data __ 0.14 secs Wed Jun 20 04:45 php.cgi www-data __ 0.19 secs Wed Jun 20 04:42 cron SF root __ 0.02 secs Wed Jun 20 04:39 sh S root __ 0.00 secs Wed Jun 20 04:39 find root __ 0.00 secs Wed Jun 20 04:39 maxlifetime root __ 0.02 secs Wed Jun 20 04:39 php5 root __ 0.13 secs Wed Jun 20 04:39 which root __ 0.00 secs Wed Jun 20 04:39 exim4 S root __ 0.01 secs Wed Jun 20 04:37 php.cgi www-data __ 0.04 secs Wed Jun 20 04:36 php.cgi www-data __ 0.12 secs Wed Jun 20 04:35 php.cgi www-data __ 0.11 secs Wed Jun 20 04:35 php.cgi www-data __ 0.14 secs Wed Jun 20 04:34 lastcomm root pts/2 0.09 secs Wed Jun 20 04:34 apache2 root pts/1 0.02 secs Wed Jun 20 04:34 tput root pts/1 0.00 secs Wed Jun 20 04:34 apache2 F root pts/1 0.00 secs Wed Jun 20 04:34 apache2ctl root pts/1 0.00 secs Wed Jun 20 04:34 apache2 S root pts/1 0.54 secs Wed Jun 20 04:34 rm root pts/1 0.00 secs Wed Jun 20 04:34 install root pts/1 0.00 secs Wed Jun 20 04:34 mkdir root pts/1 0.00 secs Wed Jun 20 04:34 apache2ctl F root pts/1 0.00 secs Wed Jun 20 04:34 sleep root pts/1 0.00 secs Wed Jun 20 04:34 apache2 SF root __ 0.80 secs Wed Jun 20 03:58 sleep root pts/1 0.00 secs Wed Jun 20 04:34 apache2 SF www-data __ 0.26 secs Wed Jun 20 03:58 apache2 SF www-data __ 0.12 secs Wed Jun 20 03:59 apache2 SF www-data __ 0.13 secs Wed Jun 20 03:58 apache2 SF www-data __ 0.13 secs Wed Jun 20 03:59 apache2 SF www-data __ 0.15 secs Wed Jun 20 03:58 apache2 SF www-data __ 0.18 secs Wed Jun 20 03:58 apache2 SF www-data __ 0.07 secs Wed Jun 20 04:21 apache2 SF www-data __ 0.18 secs Wed Jun 20 03:58 apache2 SF www-data __ 0.17 secs Wed Jun 20 03:58 apache2 SF www-data __ 0.30 secs Wed Jun 20 03:58 apache2 SF www-data __ 0.09 secs Wed Jun 20 03:58 apache2 SF www-data __ 0.02 secs Wed Jun 20 04:13

    Read the article

  • arp problems with transparent bridge on linux

    - by Mink
    I've been trying to secure my virtual machines on my esx server by putting them behind a transparent bridge with 2 interfaces, one in front, one at the back. My intention is to put all the firewall rules in one place (instead of on each virtual server). I've been using as bridge a blank new virtual machine based on arch linux (but I suspect it doesn't matter which brand of linux it is). What I have is 2 virtual switchs (thus two Virtual Network, VN_front and VN_back), each with 2 types of ports (switched/separated or promiscious/where the machine can see all packets). On my bridge machine, I've set up 2 virtual NIC, one on VN_front, one on VN_back, both in promisc mode. I've created a bridge br0 with both NIC in it: brctl addbr br0 brctl stp br0 off brctl addif br0 front_if brctl addif br0 back_if Then brought them up: ifconfig front_if 0.0.0.0 promisc ifconfig back_if 0.0.0.0 promisc ifconfig br0 0.0.0.0 (I use promisc mode, because I'm not sure I can do without, thinking that maybe the packets don't reach the NICs) Then I took one of my virtual server sitting on VN_front, and plugged it to VN_back instead (that's the nifty use case I'm thinking about, being able to move my servers around just by changing the VN they are plugged into, without changing anything in the configuration). Then I looked into the macs "seen" by my addressless bridge using brctl showmacs br0 and it did show my server from both sides: I get something that looks like this : port no mac addr is local? ageing timer 2 00:0c:29:e1:54:75 no 9.27 1 00:0c:29:fd:86:0c no 9.27 2 00:50:56:90:05:86 no 73.38 1 00:50:56:90:05:88 no 0.10 2 00:50:56:90:05:8b yes 0.00 << FRONT VN 1 00:50:56:90:05:8c yes 0.00 << BACK VN 2 00:50:56:90:19:18 no 13.55 2 00:50:56:90:3c:cf no 13.57 the thing is that the server that are plugged in front/back are not shown on the correct port. I suspect some horrible thing happening in the ARP-world... :-/ If I ping from a front virtual server to a back virtual server, I can only see the back machine if that back machine pings something in the front. As soon as I stop the ping from the back machine, the ping from the front machine stops getting through... I've noticed that if the back machine pings, then its port on the bridge is the correct one... I've tried to play with the arp_ switch of /proc/sys, but with no clear effect on the end result... /proc/sys/net/ipv4/ip_forward doesn't seem to be of any use when using a bridge (seems it's all taken care of by brctl) /proc/sys/net/ipv4/conf//arp_ don't seem to change much either... (tried arp_announce to 2 or 8 - like suggested elsewhere - and arp_ignore to 0 or 1 ) All the examples I've seen have a different subnet on either side like 10.0.1.0/24 and 10.0.2.0/24... In my case I want 10.0.1.0/24 on both side (just like a transparent switch - except it's a hidden fw ). Turning stp on/off doesn't seem to have any impact on my issue. It's as if the arp packets where getting through the bridge, corrupting the other side with false data... I've tried to use the -arp on each interface, br0, front, back... it breaks the thing altogether... I suspect it has something to do with both side being on the same subnet... I've thought about putting all my machine behind the fw, so as to have all the same subnet at the back... but I'm stuck with my provider's gateway standing at the front with part of my subnet (in fact 3 appliance to route the whole subnet), so I'll always have ips from the same subnet on both side, whatever I do... (I'm using fixed front IPs on my delegated subnet). I'm at a loss... -_-'' Thx for your help. (As anyone tried something like this? from within ESXi?) (It's not just a stunt, the idea is to have something like fail2ban running on some servers, sending their banned IP to the bridge/fw so that it too could ban them - saving all the other servers from that same attacker in one go, allowing for some honeypot that would trigger the fw from any kind of suitable response, and stuffs of the sort... I am aware I could use something like snort, but it addresses some completely different kind of problems, in a completely different way... )

    Read the article

  • Moving a Drupal between linux servers, best practice to avoid file-ownership problems

    - by zero
    I want to port over a Drupal commons 6x24 from a local LAMP-stack to a production webserver. Both systems run OpenSuse Linux. How do I do this, what are the most important steps. How should I handle file-ownership. It's important for me to have to have full control of the file ownership. If I use the wwwrun account, I frequently run into problems, due to a very strict webserver-admin. See for example the long history of looking for fixes and solutions see this thread and even more interesting see this very long and impressive thread here. All troubles I run into have to do with file-owernship and permissions. This is my current setup; Note: This was just a quick hacked installation - quick and dirty. Well my interest is after the general options i have in the port of a drupal from linux to linux linux-vi17:/srv/www/htdocs/com624 # ls -l insgesamt 224 -rwxrwxrwx 1 root www 45285 19. Jan 00:54 CHANGELOG.txt -rwxrwxrwx 1 root www 925 19. Jan 00:54 COPYRIGHT.txt -rwxrwxrwx 1 root www 206 19. Jan 00:54 cron.php drwxrwxrwx 2 root www 4096 19. Jan 00:54 includes -rwxrwxrwx 1 root www 923 19. Jan 00:54 index.php -rwxrwxrwx 1 root www 1244 19. Jan 00:54 INSTALL.mysql.txt -rwxrwxrwx 1 root www 1011 19. Jan 00:54 INSTALL.pgsql.txt -rwxrwxrwx 1 root www 47073 19. Jan 00:54 install.php -rwxrwxrwx 1 root www 15572 19. Jan 00:54 INSTALL.txt -rwxrwxrwx 1 root www 14940 19. Jan 00:54 LICENSE.txt -rwxrwxrwx 1 root www 1858 19. Jan 00:54 MAINTAINERS.txt drwxrwxrwx 3 root www 4096 19. Jan 00:54 misc drwxrwxrwx 35 root www 4096 19. Jan 00:54 modules drwxrwxrwx 4 root www 4096 19. Jan 00:54 profiles -rwxrwxrwx 1 root www 1470 19. Jan 00:54 robots.txt drwxrwxrwx 2 root www 4096 19. Jan 00:54 scripts drwxrwxrwx 4 root www 4096 19. Jan 00:54 sites drwxrwxrwx 7 root www 4096 19. Jan 00:54 themes -rwxrwxrwx 1 root www 26250 19. Jan 00:54 update.php -rwxrwxrwx 1 root www 4864 19. Jan 00:54 UPGRADE.txt -rwxrwxrwx 1 root www 294 19. Jan 00:54 xmlrpc.php linux-vi17:/srv/www/htdocs/com624 # thx to BetaRides answer here a quick overview on the drush functionality with rsync http://drush.ws/ core-rsync Rsync the Drupal tree to/from another server using ssh. Examples: drush rsync @dev @stage Rsync Drupal root from dev to stage (one of which must be local). drush rsync ./ @stage:%files/img Rsync all files in the current directory to the 'img' directory in the file storage folder on stage. Arguments: source May be rsync path or site alias. See rsync documentation and example.aliases.drushrc.php. destination May be rsync path or site alias. See rsync documentation and example.aliases.drushrc.php. Options: --mode The unary flags to pass to rsync; --mode=rultz implies rsync -rultz. Default is -az. --RSYNC-FLAG Most rsync flags passed to drush sync will be passed on to rsync. See rsync documentation. --exclude-conf Excludes settings.php from being rsynced. Default. --include-conf Allow settings.php to be rsynced --exclude-files Exclude the files directory. --exclude-sites Exclude all directories in "sites/" except for "sites/all". --exclude-other-sites Exclude all directories in "sites/" except for "sites/all" and the site directory for the site being synced. Note: if the site directory is different between the source and destination, use --exclude-sites followed by "drush rsync @from:%site @to:%site" --exclude-paths List of paths to exclude, seperated by : (Unix-based systems) or ; (Windows). --include-paths List of paths to include, seperated by : (Unix-based systems) or ; (Windows). Topics: docs-aliases Site aliases overview with examples Aliases: rsync

    Read the article

  • Uploading images from Flex to Rails using Paperclip

    - by 23tux
    Hi everyone, I'm looking for a way to upload images that were created in my flex app to rails. I've tried to use paperclip, but it don't seem to work. I've got this tutorial here: http://blog.alexonrails.net/?p=218 The problem is, that they are using a FileReference to browse for files on the clients computer. They call the .upload(...) function and send the data to the upload controller. But I'm using a URLLoader to upload a image, that is modified in my Flex-App. First, here is the code from the tutorial: private function selectHandler(event:Event):void { var vars:URLVariables = new URLVariables(); var request:URLRequest = new URLRequest(uri); request.method = URLRequestMethod.POST; vars.description = "My Description"; request.data = vars; var uploadDataFieldName:String = 'filemanager[file]'; fileReference.upload(request, uploadDataFieldName); } I don't know how to set that var uploadDataFieldName:String = 'filemanager[file]'; in a URLLoader. I've got the image data compressed as a JPEG in a ByteArray. It looks like this: public function savePicture():void { var filename:String = "blubblub.jpg"; var vars:URLVariables = new URLVariables(); vars.position = layoutView.currentPicPosition; vars.url = filename; vars.user_id = 1; vars.comic_id = 1; vars.file_content_type = "image/jpeg"; vars.file_file_name = filename; var rawBytes:ByteArray = new JPGEncoder(75).encode(bitmapdata); vars.picture = rawBytes; var request:URLRequest = new URLRequest(Data.SERVER_ADDR + "pictures/upload"); request.method = URLRequestMethod.POST; request.data = vars; var loader:URLLoader = new URLLoader(request); loader.addEventListener(Event.COMPLETE, savePictureHandler); loader.addEventListener(IOErrorEvent.IO_ERROR, errorHandlerUpload); loader.load(request); } If I set the var.picture URLVariable to the bytearray, then I get the error, that the upload is nil. Here is the Rails part: Picture-Model: require 'paperclip' class Picture < ActiveRecord::Base # relations from picture belongs_to :comic belongs_to :user has_many :picture_bubbles has_many :bubbles, :through => :picture_bubbles # attached file for picture upload -> with paperclip plugin has_attached_file :file, :path => "public/system/pictures/:basename.:extension" end and the picture controller with the upload function: class PicturesController < ApplicationController protect_from_forgery :except => :upload def upload @picture = Picture.new(params[:picture]) @picture.position = params[:position] @picture.comic_id = params[:comic_id] @picture.url = params[:url] @picture.user_id = params[:user_id] if @picture.save render(:nothing => true, :status => 200) else render(:nothing => true, :status => 500) end end end Does anyone know how to solve this problem? thx, tux

    Read the article

  • facebook iframe stream.Publish cannot close dialog or skip

    - by fooyee
    am pulling my hair over this :( spent 10 hrs but nothing came out I read this thread http://forum.developers.facebook.com/viewtopic.php?pid=198128 but it didn't help much. I'm running a local dev App Engine server ( localhost:8080 ) iframe app so I have a couple of problems. 1) on safari 4.0.4, the publish story dialog comes up nicely with all images/data/action_links. upon posting a story (or skipping), the dialog goes blank and wouldn't close. 2) I tested the same code on firefox 3.5.8, the dialog comes up with all images/data/action_links, but then the whole thing freezes. Clicking anywhere on the dialog doesn't help at all. If i'm patient enough and click "publish", I have to wait for abt 10 seconds before the dialog says "story is published". then it freezes. (clicking on skip doesn't make a difference). btw, there is no "button clicking effect" : ie: the buttons don't look like they "sink down" upon clicking. I checked the firefox memory using the command "top" on the terminal, it all seems okay, no spike in CPU processes ( i could open other firefox tabs and work on them) My futile attempts at solving the problems... 1) so i thought, hmm could this be because of local dev (localhost) problem? I uploaded the code to the production server, the same thing happens. 2) I tried an older firefox (3.1) and the same problem persisted ( the freezing ) 3) I noticed that i kind of used 2 different FB features ( Connect and XFBML). The Connect Feature I used in the PostStory function. The XFBML feature I used before the tag. So I thought, hmm ... I tried replacing the FB_RequireFeatures["Connect"] feature with FB_RequireFeatures["XFBML"]. nothing changed. I still can't close the story dialog. 4) Is there a possibility that I didn't connect to xd_receiver.htm properly? my xd_receiver.htm is stored in my folder /media/fbconnect in my app.yaml handler: - url: /fbconnect static_dir: media/fbconnect so i thought a connection has to be established with xd_receiver.htm. any way I can test that? here're all the codes: <script type="text/javascript"> //post story function function PostStory() { //init facebook FB_RequireFeatures(["Connect"], function() { FB.Facebook.init('my_app_key', "/fbconnect/xd_receiver.htm"); FB.ensureInit(function() { var message = 'the message'; var attachment = { 'name': 'a simple app to send gifts', 'href': 'http://apps.facebook.com/my_app_name', 'caption': '{*actor*} sent u something', 'description': 'some description', "media": [{ "type": "image", "src": "http://bit.ly/105QYr", "href": "http://bit.ly/105QYr"}] }; //action links can only be seen AFTER the feed is published var action_links = [{ 'text': 'Send him/her a gift back!', 'href': 'http://somelink.com'}]; FB.Connect.streamPublish(message, attachment, action_links, null, "Share the gift with your friends", callback, false, null); }); }); function callback(post_id, exception) { //alert('Wall Post Complete'); } } </script> just before the end of the /body tag, i have this: <script type="text/javascript"> function callFBInit() { FB_RequireFeatures( ["XFBML"], function(){ FB.Facebook.init("my_app_key", "/fbconnect/xd_receiver.htm"); } ); } callFBInit(); btw, my xd_receiver.htm contains: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns=? http://www.w3.org/1999/xhtml? > <head> <title>cross-domain receiver page</title> </head> <body> <script src=?http://static.ak.facebook.com/js/api_lib/v0.4/xdcommreceiver.debug.js? type=? text/javascript? ></script> </body> </html> hope you guys can help out. thx

    Read the article

  • How to prevent jQuery FancyBox from closing immediately after submit?

    - by Dimitri
    Hi! I'm loading an inline registration form in a FancyBox from jQuery. However after submitting the form, the box immediately closes while there is some feedback that I want to show the user in the FancyBox itself. This feedback is generated on the server side and is printed in the FancyBox. How can I make the box only closing when their is no feedback anymore? I was thinking about using ajax to just refresh the FancyBox itself and not the whole page after refreshing. But I just can't figure out how this ajax $.ajax({type, cache, url, data, success}); works... Also it seems like there's no reaction from the 'submit bind' in the javascript. I hope someone can help me with this problem. I paste my code below. If any questions, plz ask.. Thx in advance! This is the javascript: <script type="text/javascript"> $(document).ready(function() { $("#various1").fancybox({ 'transitionIn' : 'none', 'transitionOut' : 'none', 'scrolling' : 'no', 'titleShow' : false, 'onClosed' : function() { $("#registration_error").hide(); } }); }); $("#registration_form").bind("submit", function() { if ($("#registration_error").val() != "Registration succeeded!") { $("#registration_error").show(); $.fancybox.resize(); return false; } $.fancybox.showActivity(); $.ajax({ type : "POST", cache : false, url : "/data/login.php", data : $(this).serializeArray(), success : function(data) { $.fancybox(data); } }); return false; }); This is the inline form that I show in the FancyBox: <div style="display: none;"> <div id="registration" style="width:227px;height:250px;overflow:auto;padding:7px;"> <?php echo "<p id=\"registration_error\">".$feed."</p>"; ?> <form id="registration_form" action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post"> <p> <label for="username">Username: </label> <input type="text" id="login_name" name="username" size="30" /> </p> <p> <label for="password">Password: </label> <input type="password" id="pass" name="pw" size="30" /> </p> <p> <label for="repeat_password">Repeat password: </label> <input type="password" id="rep_pass" name="rep_pw" size="30" /> </p> <p> <input type="submit" value="Register" name="register" id="reg" /> </p> <p> <em></em> </p> </form> </div> </div>

    Read the article

< Previous Page | 39 40 41 42 43 44 45  | Next Page >