How would you explain traits to a new C++ programmer?
How would you explain traits to a C programmer?
How would you explain traits to a Java/Ruby/Python/C# or any other OOP language programmer?
Dear Friends !
I have very definitively come across the 'simulating a 6-faced die' (which produces a random integer between 1 and 6, all outcomes are equally probable) in Java, Python, Ruby and Bash. However, I am yet to see a similar program in Ada. Has anyone come across one ?
Kind regards
Arkapravo
Is there an existing good example, or how should one approach creating a basic Template system (thinking MVC) that supports "Template Inheritance" in PHP5?
For an example of what I define as Template Inheritance, refer to the Django (a Python framework for web development) Templates documentation: http://docs.djangoproject.com/en/dev/topics/templates/#id1
I especially like the idea of PHP itself being the "template language", though it's not necessarily a requirement.
If listing existing solutions that implement "Template Inheritance", please try to form answers as individual systems, for the benefit of 'popular vote'.
I have a date time picker combination in a edit template that can be used like Html.EditorFor(x = x.ETA) but now I want to use the same template somewhere where I don't have a model that contains a DateTime property. So I tried Html.Editor("DateWithTime", "Arrival") which uses the correct template, but doesn't assign a value to ViewData.ModelMetadata.PropertyName which is something that my template relies on. It sets the id of the textbox which is obviously important.
Is there a way to render the template and assign a id value to the ViewData.ModelMetadata.PropertyName so I can re-use the logic in the template instead of having to copy it?
Is there a disadvantage to using a dynamic Python file to generate the CSS for a webpage? I'd like computers with an administrator cookie to show special admin panel CSS, and show regular CSS for all other users. I'm planning to use:
<link rel="stylesheet" href="/css.py" type="text/css" />
I have table which is connected to datagridview and I would like to enter new data by using text boxes. I have following code but it gives me error. Will be appreciated if you help me.
Dim meter As DataTable = Me.DataSet1.Tables.Item("tblmeters")
Dim row As DataRow = meter.NewRow()
row.Item("No") = Me.txtno.Text
row.Item("Turnover") = Me.txtturnover.Text
row.Item("Total Win") = Me.txttotalwin.Text
row.Item("Games Played") = Me.txtgamesplayed.Text
row.Item("Credit In") = Me.txtcreditin.Text
row.Item("Bill In") = Me.txtbillin.Text
row.Item("Hand Pay") = Me.txthandpay.Text
row.Item("Date") = DateTime.Today.ToShortDateString
meter.Rows.Add(row)
Me.TblMeterTableAdapter.Update(Me.DataSet1.tblMeter)
meter.AcceptChanges()
I am wondering if there are any strongly typed scripting languages. Python, JavaScript, etc. are great languages, but they are (to a certain degree) loosely typed. I am just wondering if anyone knows of any strongly typed scripting languages.
And by scripting, I mean a language whose interpreter can be embedded in a C++ application.
Hi,
I am passing the email address as part of the url,
for ex. http://example.com/hello/[email protected]
but, when being passed to the application controller it is changed to " user%40hotmail.com ".
I can't seem to understand this special character escaping; confusion.
please help me explain the problem here, and also what can I do to fix it.
I am using python's "webapp" web application framework.
Hi
I have an asp.net page where i am using LINQdatasource to bind grid. Now whenever, if some one changes something in grid I want to update a history table. which is also shown as child grid for each row
Let say
I have a grid with two column Name and Age. it also has a child row with column field and datetime. so when ever if some one changes something in Name or Age column and saves it. A new row is inserted in child row with the name of field changed and date time when it was changed
I have a table Order, Transaction, Payment. Class Order has the properties:
public virtual Guid Id { get; set; }
public virtual DateTime Created { get; set; }
...
I added properties:
public virtual IList<Transaction> Transactions { get; set; }
public virtual IList<Payment> Payments { get; set; }
These properties contain a record of tables [Transaction] and [Payment].
How to keep these lists in the database?
I'm working on a program in python+pygame with some other developers, and we're seeing the same font rendered differently. It's a free font that we're distributing with the game. On my machine, this particular font is rendering 10px lower than on another developer's machine.
Any thoughts on why this is?
I'm working on a program in python+pygame with some other developers, and we're seeing the same font rendered differently. It's a free font that we're distributing with the game. On my machine, this particular font is rendering 10px lower than on another developer's machine.
Any thoughts on why this is?
Was just wondering if there are any other framework for mobile app development for example using php, ruby, python etc excluding objective C (Iphone and Ipod touch), mono or the use of html and javascript (Phonegap, titanium etc).
I am looking into Javascript programming without a browser. I want to run scripts from the Linux or Mac OS X command line, much like we run any other scripting language (ruby, php, perl, python...)
$ javascript my_javascript_code.js
I looked into spider monkey (Mozilla) and v8 (Google), but both of these appear to be embedded.
Is anyone using Javascript as a scripting language to be executed from the command line?
If anyone is curious why I am looking into this, I've been poking around node.js
When using a nosql type datastore like Cassandra, how would you return a result set based on a column?
e.g.
SELECT *
FROM Articles
WHERE category='blah'
ORDER BY datetime DESC
is this something that you would store in a sql db and then pull the data from cassandra? Or can cassandra handle this type of query? (assuming millions of rows in a db)
From what I understand, cassandra is great at key based lookups, confused if it can and should be used for getting a list of data back and paging that data also (and if it is highly performant)
Will a game written in C# have any speed issues after long periods of play, like for 24 hours at a time? I'm specifically talking about a 2D RPG similar to old Final Fantasy or Dragon Quest games. I know that languages like Python will slow down too much, curious how C# would stand.
I was wondering what's the point of using Ruby (or even Python) in Cocoa application development other that not learning Objective-C (which is pretty simple language and will not take to more than few days to learn). I'm new to this and I'm interested why people do this? What are Pros and Cons.
The code:
strSql = "insert into table2 (transactiondate) values ('" & transactiondate & "')"
seems to be giving me the runtime error:
The conversion of a varchar data type to a smalldatetime data type resulted in an out-of-range value
In the code, strSql is a String object and transactiondate is a Date object.
In the SQL database however, transactiondate is a smalldatetime object.
I've tried changing the smalldatetime to a datetime (in the database) and I've tried transactiondate.toString() but with no success.
How can this be fixed?
Note: I know about the dangers of inline SQL. I am looking for a quick fix solution here and not a discussion about SQL injection.
I am working on a solution where I can convert pdf files to images.
I am using the following example from codeproject:
http://www.codeproject.com/Articles/317700/Convert-a-PDF-into-a-series-of-images-using-Csharp?msg=4134859#xx4134859xx
now I tried with the following code to generate from more then 1000 pdf files new images:
using Cyotek.GhostScript;
using Cyotek.GhostScript.PdfConversion;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RefClass_PDF2Image
{
class Program
{
static void Main(string[] args)
{
string outputPath = Properties.Settings.Default.outputPath;
string pdfPath = Properties.Settings.Default.pdfPath;
if (!Directory.Exists(outputPath))
{
Console.WriteLine("Der angegebene Pfad " + outputPath + " für den Export wurde nicht gefunden. Bitte ändern Sie den Pfad (outputPath) in der App.Config Datei.");
return;
}
else
{
Console.WriteLine("Output Pfad: " + outputPath + " gefunden.");
}
if (!Directory.Exists(pdfPath))
{
Console.WriteLine("Der angegebene Pfad " + pdfPath + " zu den PDF Zeichnungen wurde nicht gefunden. Bitte ändern Sie den Pfad (pdfPath) in der App.Config Datei.");
return;
}
else
{
Console.WriteLine("PDF Pfad: " + pdfPath + " gefunden.");
}
Pdf2ImageSettings settings = GetPDFSettings();
DateTime start = DateTime.Now;
TimeSpan span;
Console.WriteLine("");
Console.WriteLine("Extraktion der PDF Zeichnungen wird gestartet: " + start.ToShortTimeString());
Console.WriteLine("");
DirectoryInfo diretoryInfo = new DirectoryInfo(pdfPath);
DirectoryInfo[] directories = diretoryInfo.GetDirectories();
Console.WriteLine("");
Console.WriteLine("Es wurden " + directories.Length + " verschiedende Verzeichnisse gefunden.");
Console.WriteLine("");
List<string> filenamesPDF = Directory.GetFiles(pdfPath, "*.pdf*", SearchOption.AllDirectories).Select(x => Path.GetFullPath(x)).ToList();
List<string> filenamesOutput = Directory.GetFiles(outputPath, "*.*", SearchOption.AllDirectories).Select(x => Path.GetFullPath(x)).ToList();
Console.WriteLine("");
Console.WriteLine("Es wurden " + filenamesPDF.Count + " verschiedende PDF Zeichnungen gefunden.");
Console.WriteLine("");
List<string> newFileNames = new List<string>();
int cutLength = pdfPath.Length;
for (int i = 0; i < filenamesPDF.Count; i++)
{
string temp = filenamesPDF[i].Remove(0, cutLength);
temp = outputPath + temp;
temp = temp.Replace("pdf", "jpg");
newFileNames.Add(temp);
}
for (int i = 0; i < filenamesPDF.Count; i++)
{
FileInfo fi = new FileInfo(newFileNames[i]);
if (!fi.Exists)
{
if (!Directory.Exists(fi.DirectoryName))
{
Directory.CreateDirectory(fi.DirectoryName);
}
Bitmap firstPage = new Pdf2Image(filenamesPDF[i], settings).GetImage();
firstPage.Save(newFileNames[i], System.Drawing.Imaging.ImageFormat.Jpeg);
firstPage.Dispose();
}
//if (i % 20 == 0)
//{
// GC.Collect();
// GC.WaitForPendingFinalizers();
//}
}
Console.ReadLine();
}
private static Pdf2ImageSettings GetPDFSettings()
{
Pdf2ImageSettings settings;
settings = new Pdf2ImageSettings();
settings.AntiAliasMode = AntiAliasMode.Medium;
settings.Dpi = 150;
settings.GridFitMode = GridFitMode.Topological;
settings.ImageFormat = ImageFormat.Png24;
settings.TrimMode = PdfTrimMode.CropBox;
return settings;
}
}
}
unfortunately, I always get in the Pdf2Image.cs an out of memory exception. here the code:
public Bitmap GetImage(int pageNumber)
{
Bitmap result;
string workFile;
//if (pageNumber < 1 || pageNumber > this.PageCount)
// throw new ArgumentException("Page number is out of bounds", "pageNumber");
if (pageNumber < 1)
throw new ArgumentException("Page number is out of bounds", "pageNumber");
workFile = Path.GetTempFileName();
try
{
this.ConvertPdfPageToImage(workFile, pageNumber);
using (FileStream stream = new FileStream(workFile, FileMode.Open, FileAccess.Read))
{
result = new Bitmap(stream); // --->>> here is the out of memory exception
stream.Close();
stream.Dispose();
}
}
finally
{
File.Delete(workFile);
}
return result;
}
how can I fix that to avoid this exception?
thanks for any help,
tro
I've got a really big number: 5799218898. And want to shift it right to 13 bits.
So, windows-calculator or python gives me:
5799218898 13 | 100010100100001110011111100001 13
70791 | 10001010010000111
As expected.
But Javascript:
5799218898 13 | 100010100100001110011111100001 13
183624 | 101100110101001000
I think it because of internal integer representation in javascript, but cannot find anything about that.
How could I write a simple program using OpenType tables in order to dynamically render text?
please answer in :
assembly , C , C++ , C# , java or Python (and a little WPF:-)
or introduce libraries of them.
comments and answers about text rendering system of common Operating Systems, or designing text engines compatible with unicode 5.02 protocol are welcomed.
I just came across a new BASIC implementation for Google Android application called Simple. You can read about it here:
http://google-opensource.blogspot.com/2009/07/programming-made-simple.html
Clearly, a lot of time and effort has been recently put into enabling this functionality for Android.
Should the software industry continue to encourage non-programmers into learning BASIC, or are modern languages like C#, Python, Ruby more appropriate at this time?
Hi,
Is there a library of data structures and operations for quadratic bezier curves? I need to implement:
bezier to bitmap converting with arbitrary quality
optimizing bezier curves
common operations like subtraction, extraction, rendering etc.
languages: c,c++,.net,python
Algorithms without implementation (pseudocode or etc) could be useful too. (especially optimization)
I have a table Order, Transaction, Payment. Class Order has the properties:
public virtual Guid Id { get; set; }
public virtual DateTime Created { get; set; }
...
I added properties:
public virtual IList<Transaction> Transactions { get; set; }
public virtual IList<Payment> Payments { get; set; }
These properties contain a record of tables [Transaction] and [Payment].
How to keep these lists in the database?