Daily Archives

Articles indexed Monday April 26 2010

Page 6/110 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • How can I use Mongrel for my non-rails ruby webapp?

    - by aharon
    I've got a non-RoR but ruby webapp in the works. So far, I've just been using requests, hacks, and mod_ruby; but I'd really like to try out Mongrel--which seems to work really well for RoR sites. I looked at the examples given in GitHub, and none of them does dynamic changing of content w/o having to restart Mongrel like you can do in RoR under dev mode. How can I do this? (Just using load doesn't work.)

    Read the article

  • Technologies used in Remote Administration applications(not RD)

    - by Michael
    I want to know what kind of technologies are used nowadays as underlying screen capture engine for remote administration software like VNC pcAnywhere TeamViewer RAC Remote Administrator etc.. The programming language is not so important as just to know whether a driver needs to be developed which is polling video memory 30 times per second or there are any com objects built in the Windows kernel to help doing this? I'm not interested in 3rd party components for doing this. Do I have to use DirectX facilities? Just want some start point to develop my own screen stream capture engine, which will be less CPU hog.

    Read the article

  • Initializing "new users" in Rails

    - by mathee
    I'm creating a Ruby on Rails application, and I'm trying to create/login/logout users. This is the schema for Users: create_table "users", :force => true do |t| t.string "first_name" t.string "last_name" t.text "reputation" t.integer "questions_asked" t.integer "answers_given" t.string "request" t.datetime "created_at" t.datetime "updated_at" t.string "email_hash" t.string "username" t.string "hashed_password" t.string "salt" end The user's personal information (username, first/last names, email) is populated through a POST. Other things such as questions_asked, reputation, etc. are set by the application, so should be initialized when we create new users. Right now, I'm just setting each of those manually in the create method for UsersController: def create @user = User.new(params[:user]) @user.reputation = 0 @user.questions_asked = 0 @user.answers_given = 0 @user.request = nil ... end Is there a more elegant/efficient way of doing this?

    Read the article

  • html: embed streaming video (crossbrowser)

    - by Fuxi
    hi all, i'm trying to embed a .wmv video into my website but doesnt work :( i've googled and tried <embed> and <video> the video i'm using was created by super converter and i've used WMV7 as video codec. is there a crossbrowser solution for it - or should i better use flash video? thx in advance

    Read the article

  • Python: import the containing package

    - by guy
    In a module residing inside a package, i have the need to use a function defined within the __init__.py of that package. how can i import the package within the module that resides within the package, so i can use that function? Importing __init__ inside the module will not import the package, but instead a module named __init__, leading to two copies of things with different names... Is there a pythonic way to do this?

    Read the article

  • Help with method logic in Java, hw

    - by Crystal
    I have a Loan class that in its printPayment method, it prints the amortization table of a loan for a hw assignment. We are also to implement a print first payment method, and a print last payment method. Since my calculation is done in the printPayment method, I didn't know how I could get the value in the first or last iteration of the loop and print that amount out. One way I can think of is to write a new method that might return that value, but I wasn't sure if there was a better way. Here is my code: public abstract class Loan { public void setClient(Person client) { this.client = client; } public Person getClient() { return client; } public void setLoanId() { loanId = nextId; nextId++; } public int getLoanId() { return loanId; } public void setInterestRate(double interestRate) { this.interestRate = interestRate; } public double getInterestRate() { return interestRate; } public void setLoanLength(int loanLength) { this.loanLength = loanLength; } public int getLoanLength() { return loanLength; } public void setLoanAmount(double loanAmount) { this.loanAmount = loanAmount; } public double getLoanAmount() { return loanAmount; } public void printPayments() { double monthlyInterest; double monthlyPrincipalPaid; double newPrincipal; int paymentNumber = 1; double monthlyInterestRate = interestRate / 1200; double monthlyPayment = loanAmount * (monthlyInterestRate) / (1 - Math.pow((1 + monthlyInterestRate),( -1 * loanLength))); System.out.println("Payment Number | Interest | Principal | Loan Balance"); // amortization table while (loanAmount >= 0) { monthlyInterest = loanAmount * monthlyInterestRate; monthlyPrincipalPaid = monthlyPayment - monthlyInterest; newPrincipal = loanAmount - monthlyPrincipalPaid; loanAmount = newPrincipal; System.out.printf("%d, %.2f, %.2f, %.2f", paymentNumber++, monthlyInterest, monthlyPrincipalPaid, loanAmount); } } /* //method to print first payment public double getFirstPayment() { } method to print last payment public double getLastPayment() { }*/ private Person client; private int loanId; private double interestRate; private int loanLength; private double loanAmount; private static int nextId = 1; } Thanks!

    Read the article

  • Advanced SQL Data Compare throught multiple tables

    - by podosta
    Hello, Consider the situation below. Two tables (A & B), in two environments (DEV & TEST), with records in those tables. If you look the content of the tables, you understand that functionnal data are identical. I mean except the PK and FK values, the name Roger is sill connected to Fruit & Vegetable. In DEV environment : Table A 1 Roger 2 Kevin Table B (italic field is FK to table A) 1 1 Fruit 2 1 Vegetable 3 2 Meat In TEST environment : Table A 4 Roger 5 Kevin Table B (italic field is FK to table A) 7 4 Fruit 8 4 Vegetable 9 5 Meat I'm looking for a SQL Data Compare tool which will tell me there is no difference in the above case. Or if there is, it will generate insert & update scripts with the right order (insert first in A then B) Thanks a lot guys, Grégoire

    Read the article

  • Using a type parameter and a pointer to the same type parameter in a function template

    - by Darel
    Hello, I've written a template function to determine the median of any vector or array of any type that can be sorted with sort. The function and a small test program are below: #include <algorithm> #include <vector> #include <iostream> using namespace::std; template <class T, class X> void median(T vec, size_t size, X& ret) { sort(vec, vec + size); size_t mid = size/2; ret = size % 2 == 0 ? (vec[mid] + vec[mid-1]) / 2 : vec[mid]; } int main() { vector<double> v; v.push_back(2); v.push_back(8); v.push_back(7); v.push_back(4); v.push_back(9); double a[5] = {2, 8, 7, 4, 9}; double r; median(v.begin(), v.size(), r); cout << r << endl; median(a, 5, r); cout << r << endl; return 0; } As you can see, the median function takes a pointer as an argument, T vec. Also in the argument list is a reference variable X ret, which is modified by the function to store the computed median value. However I don't find this a very elegant solution. T vec will always be a pointer to the same type as X ret. My initial attempts to write median had a header like this: template<class T> T median(T *vec, size_t size) { sort(vec, vec + size); size_t mid = size/2; return size % 2 == 0 ? (vec[mid] + vec[mid-1]) / 2 : vec[mid]; } I also tried: template<class T, class X> X median(T vec, size_t size) { sort(vec, vec + size); size_t mid = size/2; return size % 2 == 0 ? (vec[mid] + vec[mid-1]) / 2 : vec[mid]; } I couldn't get either of these to work. My question is, can anyone show me a working implementation of either of my alternatives? Thanks for looking!

    Read the article

  • bitset to dynamic bitset

    - by mr.bio
    Hi.. I have a function where i use bitset.Now i need to convert it to a dynamic bitset.. but i don't know how. Can somebody help me ? set<string> generateCandidates(set<string> ck,unsigned int k){ set<string> nk ; for (set<string>::const_iterator p = ck.begin( );p != ck.end( ); ++p){ for (set<string>::const_iterator q = ck.begin( );q != ck.end( ); ++q){ bitset<4> bs1(*p); bitset<4> bs2(*q); bs1|= bs2 ; if(bs1.count() == k){ nk.insert(bs1.to_string<char,char_traits<char>,allocator<char> >()); } } } return nk; }

    Read the article

  • javascript works with mozilla but not with webkit based browsers

    - by GlassGhost
    Im having problems with a css text variable in this javascript with webkit based browsers(Chrome & Safari) but it works in firefox 3.6 importScript('User:Gerbrant/hidePane.js');//Special thanks to Gerbrant for this wonderful script function addGlobalStyle(css) { var head = document.getElementsByTagName('head')[0]; if (!head) { return; } var style = document.createElement('style'); style.type = 'text/css'; style.rel = 'stylesheet'; style.media = 'screen'; style.href = 'FireFox.css'; style.innerHTML = css; head.appendChild(style); } //The page styling var NewSyleText = "h1, h2, h3, h4, h5 {font-family: 'Verdana','Helvetica',sans-serif; font-style: normal; font-weight:normal;}" + "body, b {background: #fbfbfb; font-style: normal; font-family: 'Cochin','GaramondNo8','Garamond','Big Caslon','Georgia','Times',serif;font-size: 11pt;}" + "p { margin: 0pt; text-indent:1.25em; margin-top: 0.3em; }" + "a { text-decoration: none; color: Navy; background: none;}" + "a:visited { color: #500050;}" + "a:active { color: #faa700;}" + "a:hover { text-decoration: underline;}" + "a.stub { color: #772233;}" + "a.new, #p-personal a.new { color: #ba0000;}" + "a.new:visited, #p-personal a.new:visited { color: #a55858;}" + "a.new, #quickbar a.new { color: #CC2200; }" + /* removes "From Wikipedia, the free encyclopedia" for those of you who actually know what site you are on */ "#siteSub { display: none; }" + /* hides the speaker icon in some articles */ "#spoken-icon .image { display:none;}" + /* KHTMLFix.css */ "#column-content { margin-left: 0; }" + /* Remove contents of the footer, but not the footer itself */ "#f-poweredbyico, #f-copyrightico { display:none;}" + /* Needed to show the star icon in a featured article correctly */ "#featured-star div div { line-height: 10px;}" + /* And the content expands to top and left */ "#content {margin: 0; padding: 0; background:none;}" + "#content div.thumb {border-color:white;}" + /* Hiding the bar under the entry header */ "h1.firstHeading { border-bottom: none;}" + /* Used for US city entries */ "#coordinates { top:1.2em;}"; addGlobalStyle(NewSyleText);//inserts the page styling

    Read the article

  • Samba permissions on a Debian server with Fedora client

    - by norova
    I have a Debian server sharing files via Samba. I can access the files via Windows with no problems whatsoever, but when I try to mount the share on a Fedora client using the same credentials I am unable to write to any files. I have proper read access, but no write permissions. Here are the settings for the share from my smb.conf: [lampp] path = /opt/lampp writable = yes browsable = yes I have to assume that it is an issue on the Fedora side of things because accessing the share from Windows works fine. I have also tried mounting via SSHFS with no luck; it also will allow me to read files but not write. However, in Windows, using a program called WebDrive I am able to access the files (essentially via SSHFS) with no issues whatsoever. I have tried setting up NFS but not much luck there either; I'd rather just stick with Samba if possible. Any suggestions?

    Read the article

  • Sendmail - Relaying denied (state 14)

    - by Ekevoo
    I have my sendmail.cf file configured to send local mail and to receive external mail to local users. So sending mail from the server to the external world works fine, but the other way around does not... I get an error e-mail saying: Delivery to the following recipient failed permanently: [email protected] Technical details of permanent failure: Google tried to deliver your message, but it was rejected by the recipient domain. We recommend contacting the other email provider for further information about the cause of this error. The error that the other server returned was: 550 550 5.7.1 root@75.xxx.xxx.xxx... Relaying denied (state 14). Also I can't find logs in /var/log, all I see is this binary file in /var/log/mail/statistics Thanks!

    Read the article

  • Weird noise while scanning, using scanimage and a Canon Lide 35

    - by Manu
    I'm trying to scan a bunch of images, using xsane's scanimage : scanimage --format=tiff --batch --batch-prompt This command scans the first picture perfectly, but as soon as I press enter, the scanner makes a weird noise, and the scanning "arm" moves very, very slowly. If I stop scanimage and start again, it scans normally again. Is there another scanimage option that I need to add? I've checked the man page, but can't see what I'm missing. Edit: the problem seems to be that the scanning "arm" doesn't go back to it's original position after the first scan.

    Read the article

  • SQLiteDataAdapter Fill exception C# ADO.NET

    - by Lirik
    I'm trying to use the OleDb CSV parser to load some data from a CSV file and insert it into a SQLite database, but I get an exception with the OleDbAdapter.Fill method and it's frustrating: An unhandled exception of type 'System.Data.ConstraintException' occurred in System.Data.dll Additional information: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints. Here is the source code: public void InsertData(String csvFileName, String tableName) { String dir = Path.GetDirectoryName(csvFileName); String name = Path.GetFileName(csvFileName); using (OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + dir + @";Extended Properties=""Text;HDR=No;FMT=Delimited""")) { conn.Open(); using (OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM " + name, conn)) { QuoteDataSet ds = new QuoteDataSet(); adapter.Fill(ds, tableName); // <-- Exception here InsertData(ds, tableName); // <-- Inserts the data into the my SQLite db } } } class Program { static void Main(string[] args) { SQLiteDatabase target = new SQLiteDatabase(); string csvFileName = "D:\\Innovations\\Finch\\dev\\DataFeed\\YahooTagsInfo.csv"; string tableName = "Tags"; target.InsertData(csvFileName, tableName); Console.ReadKey(); } } The "YahooTagsInfo.csv" file looks like this: tagId,tagName,description,colName,dataType,realTime 1,s,Symbol,symbol,VARCHAR,FALSE 2,c8,After Hours Change,afterhours,DOUBLE,TRUE 3,g3,Annualized Gain,annualizedGain,DOUBLE,FALSE 4,a,Ask,ask,DOUBLE,FALSE 5,a5,Ask Size,askSize,DOUBLE,FALSE 6,a2,Average Daily Volume,avgDailyVolume,DOUBLE,FALSE 7,b,Bid,bid,DOUBLE,FALSE 8,b6,Bid Size,bidSize,DOUBLE,FALSE 9,b4,Book Value,bookValue,DOUBLE,FALSE I've tried the following: Removing the first line in the CSV file so it doesn't confuse it for real data. Changing the TRUE/FALSE realTime flag to 1/0. I've tried 1 and 2 together (i.e. removed the first line and changed the flag). None of these things helped... One constraint is that the tagId is supposed to be unique. Here is what the table look like in design view: Can anybody help me figure out what is the problem here?

    Read the article

  • How can I set initial values when using Silverlight DataForm and .Net RIA Services DomainDataSource?

    - by TheDuke
    I'm experimenting with .Net RIA and Silverlight, I have a few of related entities; Client, Project and Job, a Client has many Projects, and a Project has many Jobs. In the Silverlight app, I'm uisng a DomainDataSource, and DataForm controls to perform the CRUD operations. When a Client is selected a list of projects appears, at which point the user can add a new project for that client. I'd like to be able to fill in the value for client automatically, but there doesn't seem to be any way to do that, while there is an AddingNewItem event on the DataForm control, it seems to fire before the DataForm has an instance of the new object and I'm not sure trawling through the ChangeSet from the DomainDataSource SubmittingChanges event is the best way to do this. I would of thought this would of been an obvious feature... anyone know the best way to achieve this functionality?

    Read the article

  • Calculating terrain height in 3d-space

    - by Jonas B
    Hi I'm diving into 3d programming a bit and am currently learning by writing a procedural terrain generator that generates terrain based on a heightmap. I would also want to implement some physics and my first attempt at terrain collision was by simply checking the current position vs the heightmap. This however wont work well against small objects as you'd have to calculate the height by taking the heightdifference of the nearest vertices of the object and doing this every colision check is pretty slow. Beleive me I tried googling for it but there's simply so much crap and millions of blogs posting ripped-of newbie tutorials everywhere with basically no real information on the subject, I can't find anything that explains it or even names any generally used techniques. I'm not asking for code or a complete solution, but if anyone knows a particular technique good for calculating a high-res heightmap out of the already generated and smoothed terrain I would be very happy as I could look into it further when I know what I'm looking for. Thanks

    Read the article

  • How do I add a filter button to this pagination?

    - by ClarkSKent
    Hey, I want to add a button(link), that when clicked will filter the pagination results. I'm new to php (and programming in general) and would like to add a button like 'Automotive' and when clicked it updates the 2 mysql queries in my pagination script, seen here: As you can see, the category automotive is hardcoded in, I want it to be dynamic, so when a link is clicked it places whatever the id or class is in the category part of the query. 1: $record_count = mysql_num_rows(mysql_query("SELECT * FROM explore WHERE category='automotive'")); 2: $get = mysql_query("SELECT * FROM explore WHERE category='automotive' LIMIT $start, $per_page"); This is the entire current php pagination script that I am using: <?php //connecting to the database $error = "Could not connect to the database"; mysql_connect('localhost','root','root') or die($error); mysql_select_db('ajax_demo') or die($error); //max displayed per page $per_page = 2; //get start variable $start = $_GET['start']; //count records $record_count = mysql_num_rows(mysql_query("SELECT * FROM explore WHERE category='automotive'")); //count max pages $max_pages = $record_count / $per_page; //may come out as decimal if (!$start) $start = 0; //display data $get = mysql_query("SELECT * FROM explore WHERE category='automotive' LIMIT $start, $per_page"); while ($row = mysql_fetch_assoc($get)) { // get data $name = $row['id']; $age = $row['site_name']; echo $name." (".$age.")<br />"; } //setup prev and next variables $prev = $start - $per_page; $next = $start + $per_page; //show prev button if (!($start<=0)) echo "<a href='pagi_test.php?start=$prev'>Prev</a> "; //show page numbers //set variable for first page $i=1; for ($x=0;$x<$record_count;$x=$x+$per_page) { if ($start!=$x) echo " <a href='pagi_test.php?start=$x'>$i</a> "; else echo " <a href='pagi_test.php?start=$x'><b>$i</b></a> "; $i++; } //show next button if (!($start>=$record_count-$per_page)) echo " <a href='pagi_test.php?start=$next'>Next</a>"; ?>

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >