I'm currently a senior in high school, about to matriculate and pursue a major in Computer Science (possibly dual-major with electrical engineering. Comments?). I already program regularly as a hobby, but I would like to get a jump start this summer by perhaps attending a seminar, helping out on an open source project...you know, something legitimate that will bolster my knowledge of the computer science field.
Any ideas?
I've got an IDictionary field that I would like to expose via a property of type IDictionary<string, dynamic> the conversion is surprisingly difficult since I have no idea what I can .Cast<>() the IDictionary to.
Best I've got:
IDictionary properties;
protected virtual IDictionary<string, dynamic> Properties {
get {
return _properties.Keys.Cast<string>()
.ToDictionary(name=>name, name=> _properties[name] as dynamic);
}
}
I'm retrieving an array of objects from a hidden html inputfield. The string I'm getting is:
"{"id":"1234","name":"john smith","email":"[email protected]"},{"id":"4431","name":"marry doe","email":"[email protected]"}"
Now I need to pass this as an array of objects again. How do I convert this string into array of objects?
Hello,
In some applications like Mail, when you have a UITextField, there is a little + button to the right. When you tap it, a modal view controller comes up which you can select a phone number, address, etc from, and it will appear in the text field. I was wondering how to implement this in my own app. Thanks,
Isaac
I've "integrated" SMF into Wordpress by querying the forum for a list of the most recent videos from a specific forum board and displaying them on the Wordpress homepage. However when I add the ORDER BY clause, the query (which I tested on other parts of the same page successfully), breaks.
To add to the mix, I am using the Auto Embed plugin to allow the videos to be played on the homepage, as well as using a jCarousel feature to rotate them. People were kind enough to help me here last time with the regexp to filter the video urls, I'm hoping for the same luck this time!
Here is the entire function (remove the DESC and it works...):
function SMF_getRecentVids($limit=10){
global $smf_settingsphp_d;
if(file_exists($smf_settingsphp_d)) include($smf_settingsphp_d);
include "AutoEmbed-1.4/AutoEmbed.class.php";
$AE = new AutoEmbed();
$connect = new wpdb($db_user,$db_passwd,$db_name,$db_server);
$connect->query("SET NAMES 'UTF8'");
$sql = SELECT m.subject, m.ID_MSG, m.body, m.ID_TOPIC, m.ID_BOARD, t.ID_FIRST_MSG
FROM {$db_prefix}messages AS m
LEFT JOIN {$db_prefix}topics AS t ON (m.ID_TOPIC = t.ID_TOPIC)
WHERE (m.ID_BOARD = 8)
ORDER BY t.ID_FIRST_MSG DESC";
$vids = $connect->get_results($sql);
$c = 0;
$content = "imageCarousel_itemList = [";
foreach ($vids as $vid) {
if ($c > $limit) continue;
//extract video code from body
$input = $vid->body;
$regexp = "/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i";
if(preg_match_all($regexp, $input, $matches)) {
$AE->parseUrl($matches[0][0]);
$imageURL = $AE->getImageURL();
$AE->setWidth(290);
$AE->setHeight(240);
$content .= "{url: '".$AE->getEmbedCode()."', title: '".$vid->subject."', caption: '', description: ''},";
}
$c++;
}
$content .= "]";
echo $content;
$wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
}
Hi all, another question about jqgrid.
I have a jqgrid table and i have a button in each row. When user clicks on that button, i need to call an action in my mvc controller and i need to change value of my object's field from true to false or opposite and then reload grid.
What is the best way to implement this?
Thanks.
I have an Excel VBA add-in with a public method in a bas file. This method currently creates a VB6 COM object, which exists in a running VB6 exe/vbp. The VB6 app loads in data and then the Excel add-in method can call methods on the VB6 COM object to load the data into an existing Excel xls. This is all currently working.
We have since converted our VB6 app to C#.
My question is: What is the best/easiest way to mimic this behavior with the C#/.NET app?
I'm thinking I may not be able to pull the data from the .NET app into Excel from the add-in method since the .Net app needs to be running with data loaded (so no using a stand-alone C# class library). Maybe we can, instead, push the data from .NET to Excel by accessing the VBA add-in method from the C# code?
The following is the existing VBA method accessing the VB6 app:
Public Sub UpdateInDataFromApp()
Dim wkbInData As Workbook
Dim oFPW As Object
Dim nMaxCols As Integer
Dim nMaxRows As Integer
Dim j As Integer
Dim sName As String
Dim nCol As Integer
Dim nRow As Integer
Dim sheetCnt As Integer
Dim nDepth As Integer
Dim sPath As String
Dim vData As Variant
Dim SheetRange As Range
Set wkbInData = wkbOpen("InData.xls")
sPath = g_sPathXLSfiles & "\"
'Note: the following will bring up fpw app if not already running
Set oFPW = CreateObject("FPW.CProfilesData")
If oFPW Is Nothing Then
MsgBox "Unable to reference " & sApp
Else
.
.
.
sheetCnt = wkbInData.Sheets.Count 'get number of sheets in indata workbook
For j = 2 To sheetCnt 'set counter to loop over all sheets except the first one which is not input data fields
With wkbInData.Worksheets(j)
Set SheetRange = .UsedRange
End With
With SheetRange
nMaxRows = .Rows.Count 'get range of sheet(j)
nMaxCols = .Columns.Count 'get range of sheet(j)
Range(.Cells(2, 2), .Cells(nMaxRows, nMaxCols)).ClearContents 'Clears data from data range (51 Columns)
Range(.Cells(2, 2), .Cells(nMaxRows, nMaxCols)).ClearComments
End With
With oFPW 'vb6 object
For nRow = 2 To nMaxRows ' loop through rows
sName = SheetRange.Cells(nRow, 1) 'Field name
vData = .vntGetSymbol(sName, 0) 'Check if vb6 app identifies the name
nDepth = .GetInputTableDepth(sName) 'Get number of data items for this field name from vb6 app
nMaxCols = nDepth + 2 'nDepth=0, is single data item
For nCol = 2 To nMaxCols 'loop over deep screen fields
nDepth = nCol - 2 'current depth
vData = .vntGetSymbol(sName, nDepth) 'Get Data from vb6 app
If LenB(vData) > 0 And IsNumeric(vData) Then 'Check if data returned
SheetRange.Cells(nRow, nCol) = vData 'Poke the data in
Else
SheetRange.Cells(nRow, nCol) = vData 'Poke a zero in
End If
Next 'nCol
Next 'nRow
End With
Set SheetRange = Nothing
Next 'j
End If
Set wkbInData = Nothing
Set oFPW = Nothing
Exit Sub
.
.
.
End Sub
Any help would be appreciated.
I am asking for your input and/help on a classification problem. If anyone have any references that I can read to help me solve my problem even better.
I have a classification problem of four discrete and very well separated classes. However my input is continuous and has a high frequency (50Hz), since its a real-time problem.
The circles represent the clusters of the classes, the blue line the decision boundary and Class 5 equals the (neutral/resting do nothing class). This class is the rejected class. However the problem is that when I move from one class to the other I activate a lot of false positives in the transition movements, since the movement is clearly non-linear.
For example, every time I move from class 5 (neutral class) to 1 I first see a lot of 3's before getting to the 1 class.
Ideally, I will want my decision boundary to look like the one in the picture below where the rejected class is Class =5. Has a higher decision boundary than the others classes to avoid misclassification during transition. I am currently implementing my algorithm in Matlab using naive bayes, kNN, and SVMs optimized algorithms using Matlab.
Question: What is the best/common way to handle abstain/rejected classes classes? Should I use (fuzzy logic, loss function, should I include resting cluster in the training)?
Anyone have a good regex for Age verification?
I have a date field where I am validating that what the user enters is a date.
basically I wanted to figure out if that date is valid, and then further refine the date to be within x number of years
Perhaps this may be too complicated to tack onto whatever I have too far, but I figured it wouldn't be.
^([1][012]|[0]?[1-9])[/-]([3][01]|[12]\d|[0]?[1-9])[/-](\d{4}|\d{2})$
This is a difficult and open-ended question I know, but I thought I'd throw it to the floor and see if anyone had any interesting suggestions.
I have developed a code-generator that takes our python interface to our C++ code (generated via SWIG) and generates code needed to expose this as WebServices. When I developed this code I did it using TDD, but I've found my tests to be brittle as hell. Because each test essentially wanted to verify that for a given bit of input code (which happens to be a C++ header) I'd get a given bit of outputted code I wrote a small engine that reads test definitions from XML input files and generates test cases from these expectations.
The problem is I dread going in to modify the code at all. That and the fact that the unit tests themselves are a: complex, and b: brittle.
So I'm trying to think of alternative approaches to this problem, and it strikes me I'm perhaps tackling it the wrong way. Maybe I need to focus more on the outcome, IE: does the code I generate actually run and do what I want it to, rather than, does the code look the way I want it to.
Has anyone got any experiences of something similar to this they would care to share?
I all.
I have the following form used to temporarily upload a photo on a j2ee server and then crop it with imageAreaSelect plugin :
<form name="formAvatarName" id="formAvatar" method="post"
action="../admin/admin-avatar-upload"
enctype="multipart/form-data">
<label>Upload a Picture of Yourself</label>
<input type="file" name="upload" id="upload" size="20" />
<input type="button" id="formAvatarSubmit" value="formAvatar" onclick="invia()"/>
</form>
I am using jquery form plugin to do ajax submission, this is my last :) attempt :
$('#formAvatar').unbind('submit').bind('submit', function() {
alert('aho');
$(this).ajaxSubmit(options);
return false;
});
Only when tested with IE6 I can see that the sumbission to the server is done multiple times (first time I got the uploaded file, the other times the sumbmission seems empty and I got error). With IE7, IE8, FFOX, CHROME is working fine.
Any Ideas?
Many thank in advance!
Hey guys,
I'm trying to do a fixed effecs OLS regression, a random effects OLS Regression and a Hausman test to back up my choice for one of those models. Alas, there does not seem to be a lot of information of what the code looks like when you want to do this.
I found for the Hausman test that
proc model data=one out=fiml2;
endogenous y1 y2;
y1 = py2 * y2 + px1 * x1 + interc;
y2 = py1* y1 + pz1 * z1 + d2;
fit y1 y2 / ols 2sls hausman;
instruments x1 z1;
run;
you do something like this. However, I do not have the equations in the middle, which i assume to be the fixed and random effects models?
On an other site I found that PROC TSCSREG automatically displays the Hausman test, unfortunately this does not work either. When I type PROC TSCSREG data = clean; data does not become blue meaning SAS does not recognize this as a type of data input?
proc tscsreg data = clean;
var nof capm_erm sigma cv fvyrgro meanest tvol bmratio size ab;
run;
I tried this but obviously doesn't work since it does not recognize the data input, I've been searching but I can't seem to find a proper example of how the code of an hausman test looks like.
On the SAS site I neither find the code one has to use to perform a fixed/random effects model.
My data has 1784 observations, 578 different firms (cross section?) and spans over a 2001-2006 period in months.
Any help?
I'm working on a tool which converts PHP code to Scala. As one of the finishing touches, I'm in need of a really good (er, somewhat biased) benchmark.
By dumb luck my first benchmark attempt was with some code which uses bcmath extensively, which unfortunately is 1000x slower in Java, making the Scala code 22x slower overall than the original PHP.
So I'm looking for some meaningful PHP benchmark with the following characteristics:
The PHP source needs to be in a single file.
It should solve a real-world problem. No silly looping over empty methods etc.
I need it to be simple to setup - no databases, hard-to-find input files, etc.
Simple text input and output preferred.
It should not use features that are slow in Java (BigInteger, trigonometric functions, etc).
It should not use exoteric or dynamic PHP functions (e.g. no "eval" or "variable vars").
It should not over-rely on built-in libraries, e.g. MD5, crypt, etc.
It should not be I/O bound. A CPU-bound memory-hungry algorithm is preferred.
Basically, intensive OO operations, integer and string manipulation, recursion, etc would be great.
Thanks
I have two customized cells in an iphone UITableViewController and would like to capture the data in one cell into another.....
I am currently unable to post images and pls assume the following points.
There are two custom UITableViewcells
1) Notes Textfield in one customcell
2) Submit button in another text field.
Now i want to pass data typed in the notes textfield to be available when I click the Submit button.... Is this possible? Please help....:(
How to insert line break in dbunit dataset? Like this:
<user id="1"
story="first line
second line
third line"/>
If I do it in this way field story in db appears divided by spaces only but I need a line break.
After much searching the answer seems to be no, but I thought I'd ask here before giving up. For a project I'm working on that includes recording sound, the input levels sound a little quiet both when the route is external mic + speaker and when it's headphone mic + headphones. Does anyone know definitively whether it is possible to programmatically change mic gain levels on the iPhone in any part of Core Audio?
If not, is it possible that I'm not really in "speakerphone" mode (with the external mic at least) but only think I am? Here is my audio session init code:
OSStatus error = AudioSessionInitialize(NULL, NULL, audioQueueHelperInterruptionListener, r);
[...some error checking of the OSStatus...]
UInt32 category = kAudioSessionCategory_PlayAndRecord; // need to play out the speaker at full volume too so it is necessary to change default route below
error = AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(category), &category);
if (error) printf("couldn't set audio category!");
UInt32 doChangeDefaultRoute = 1;
error = AudioSessionSetProperty (kAudioSessionProperty_OverrideCategoryDefaultToSpeaker, sizeof (doChangeDefaultRoute), &doChangeDefaultRoute);
if (error) printf("couldn't change default route!");
error = AudioSessionAddPropertyListener(kAudioSessionProperty_AudioRouteChange, audioQueueHelperPropListener, r);
if (error) printf("ERROR ADDING AUDIO SESSION PROP LISTENER! %d\n", (int)error);
UInt32 inputAvailable = 0;
UInt32 size = sizeof(inputAvailable);
error = AudioSessionGetProperty(kAudioSessionProperty_AudioInputAvailable, &size, &inputAvailable);
if (error) printf("ERROR GETTING INPUT AVAILABILITY! %d\n", (int)error);
error = AudioSessionAddPropertyListener(kAudioSessionProperty_AudioInputAvailable, audioQueueHelperPropListener, r);
if (error) printf("ERROR ADDING AUDIO SESSION PROP LISTENER! %d\n", (int)error);
error = AudioSessionSetActive(true);
if (error) printf("AudioSessionSetActive (true) failed");
Thanks very much for any pointers.
So I'm using the jQuery date picker, and it works well. I am using AJAX to go and get some content, obviously when this new content is applied the bind is lost, I learnt about this last week and discovered about the .live() method.
But how do I apply that to my date picker? Because this isn't an event therefore .live() won't be able to help... right?
This is the code I'm using to bind the date picker to my input:
$(".datefield").datepicker({showAnim:'fadeIn',dateFormat:'dd/mm/yy',changeMonth:true,changeYear:true});
I do not want to call this metho everytime my AJAX fires, as I want to keep that as generic as possible.
Cheers :-)
EDIT
As @nick requested, below is my wrapper function got the ajax() method:
var ajax_count = 0;
function getElementContents(options) {
if(options.type===null) {
options.type="GET";
}
if(options.data===null) {
options.data={};
}
if(options.url===null) {
options.url='/';
}
if(options.cache===null) {
options.cace=false;
}
if(options.highlight===null || options.highlight===true) {
options.highlight=true;
} else {
options.highlight=false;
}
$.ajax({
type: options.type,
url: options.url,
data: options.data,
beforeSend: function() {
/* if this is the first ajax call, block the screen */
if(++ajax_count==1) {
$.blockUI({message:'Loading data, please wait'});
}
},
success: function(responseText) {
/* we want to perform different methods of assignment depending on the element type */
if($(options.target).is("input")) {
$(options.target).val(responseText);
} else {
$(options.target).html(responseText);
}
/* fire change, fire highlight effect... only id highlight==true */
if(options.highlight===true) {
$(options.target).trigger("change").effect("highlight",{},2000);
}
},
complete: function () {
/* if all ajax requests have completed, unblock screen */
if(--ajax_count===0) {
$.unblockUI();
}
},
cache: options.cache,
dataType: "html"
});
}
What about this solution, I have a rules.js which include all my initial bindings with the elements, if I were to put these in a function, then call that function on the success callback of the ajax method, that way I wouldn't be repeating code...
Hmmm, thoughts please :D
We are getting a weird issue on which we are not sure what exactly cause it. Let me elaborate the issue. Suppose, we have two different html pages a.html and b.html. And a little script written in index.html:
<html>
<head>
<script>
function reloadFrame(iframe, src) { iframe.src = src; }
</script>
</head>
<body>
<form>
<iframe id="myFrame"></iframe>
<input type="button" value="Load a.html" onclick="reloadFrame(document.getElementById('myFrame'), 'a.html')">
<input type="button" value="Load b.html" onclick="reloadFrame(document.getElementById('myFrame'), 'b.html')">
</form>
</body>
</html>
A server component is continuously updating both files a.html and b.html. The problem is the content of both files are successfully updating on the server side. If we open we can see the updated changes but client getting the older content which doesn't show the updated changes.
Any idea?
I don't understand how to get the columns I want from rails. I have two models - A User and a Profile. A User :has_many Profile (because users can revert back to an earlier version of their profile):
> DESCRIBE users;
+----------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| username | varchar(255) | NO | UNI | NULL | |
| password | varchar(255) | NO | | NULL | |
| last_login | datetime | YES | | NULL | |
+----------------+--------------+------+-----+---------+----------------+
> DESCRIBE profiles;
+----------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| user_id | int(11) | NO | MUL | NULL | |
| first_name | varchar(255) | NO | | NULL | |
| last_name | varchar(255) | NO | | NULL | |
| . . . . . . |
| . . . . . . |
| . . . . . . |
+----------------+--------------+------+-----+---------+----------------+
In SQL, I can run the query:
> SELECT * FROM profiles JOIN users ON profiles.user_id = users.id LIMIT 1;
+----+-----------+----------+---------------------+---------+---------------+-----+
| id | username | password | last_login | user_id | first_name | ... |
+----+-----------+----------+---------------------+---------+---------------+-----+
| 1 | john | ****** | 2010-12-30 18:04:28 | 1 | John | ... |
+----+-----------+----------+---------------------+---------+---------------+-----+
See how I get all the columns for BOTH tables JOINED together? However, when I run this same query in Rails, I don't get all the columns I want - I only get those from Profile:
# in rails console
>> p = Profile.joins(:user).limit(1)
>> [#<Profile ...>]
>> p.first_name
>> NoMethodError: undefined method `first_name' for #<ActiveRecord::Relation:0x102b521d0> from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.1/lib/active_record/relation.rb:373:in `method_missing' from (irb):8
# I do NOT want to do this (AKA I do NOT want to use "includes")
>> p.user
>> NoMethodError: undefined method `user' for #<ActiveRecord::Relation:0x102b521d0> from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.1/lib/active_record/relation.rb:373:in method_missing' from (irb):9
I want to (efficiently) return an object that has all the properties of Profile and User together. I don't want to :include the user because it doesn't make sense. The user should always be part of the most recent profile as if they were fields within the Profile model. How do I accomplish this?
Here's my problem :
I have a DataGridView bound to a BindingList of custom objects. A background thread is constantly updating a value of these objects. The udpates are showing correctly, and everything is fine except for one thing - If you try to edit a different field while the background-updated field is being updated, it loses the entered value. Here is a code sample that demonstrates this behavior:
(for new form, drop a new DataGridView on:)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
private BindingList<foo> flist;
private Thread thrd;
private BindingSource b;
public Form1()
{
InitializeComponent();
flist = new BindingList<foo>
{
new foo(){a =1,b = 1, c=1},
new foo(){a =1,b = 1, c=1},
new foo(){a =1,b = 1, c=1},
new foo(){a =1,b = 1, c=1}
};
b = new BindingSource();
b.DataSource = flist;
dataGridView1.DataSource = b;
thrd = new Thread(new ThreadStart(updPRoc));
thrd.Start();
}
private void upd()
{
flist.ToList().ForEach(f=>f.c++);
}
private void updPRoc()
{
while (true)
{
this.BeginInvoke(new MethodInvoker(upd));
Thread.Sleep(1000);
}
}
}
public class foo:INotifyPropertyChanged
{
private int _c;
public int a { get; set; }
public int b { get; set; }
public int c
{
get {return _c;}
set
{
_c = value;
if (PropertyChanged!= null)
PropertyChanged(this,new PropertyChangedEventArgs("c"));
}
}
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
#endregion
}
}
So, you edit column a or b, you will see that the column c update causes you to lose your entry.
Any thoughts appreciated.
Hi Experts,
I am working on a website in asp.net mvc. I have to show a view where user put some search values like tags and titles to search. I want to use the same Index method for that. I have
make my form to use formMethod.Get to send the parameters as querystring.
so here is the method
[HttpGet]
public ActionResult Index(string title, string tags, int? page)
{
if (string.IsNullOrEmpty(title)
return View(null);
var list = GetSomeData();
return View(list);
}
here is my view
<div id="searchBox">
<% using (Html.BeginForm(null, null, FormMethod.Get))
{ %>
<table>
<tr>
<td>
<input type="hidden" id="isPosted" name="isPosted" value="1" />
I am looking for
<%=Html.TextBox("Title")%>
Tags:
<%=Html.TextBox("Tags")%>
<input id="search" type="submit" value="Search" />
</td>
</tr>
</table>
<% } %>
So when the user first visit the page, he will see only two text boxs and a button. but when he types something in the title and tags and click the search button i will load the view with some data.
Now the problem is when i type something in title and tags box and click search, they are received in the method, but are not visible in the url. Is there anything i m doing wrong.
help will be appreciated.
Regards
Parminder
When i use celery + gevent for tasks that uses subprocess module i'm getting following stacktrace:
Traceback (most recent call last):
File "/home/venv/admin/lib/python2.7/site-packages/celery/task/trace.py", line 228, in trace_task
R = retval = fun(*args, **kwargs)
File "/home/venv/admin/lib/python2.7/site-packages/celery/task/trace.py", line 415, in __protected_call__
return self.run(*args, **kwargs)
File "/home/webapp/admin/webadmin/apps/loggingquarantine/tasks.py", line 107, in release_mail_task
res = call_external_script(popen_obj.communicate)
File "/home/webapp/admin/webadmin/apps/core/helpers.py", line 42, in call_external_script
return func_to_call(*args, **kwargs)
File "/usr/lib64/python2.7/subprocess.py", line 740, in communicate
return self._communicate(input)
File "/usr/lib64/python2.7/subprocess.py", line 1257, in _communicate
stdout, stderr = self._communicate_with_poll(input)
File "/usr/lib64/python2.7/subprocess.py", line 1287, in _communicate_with_poll
poller = select.poll()
AttributeError: 'module' object has no attribute 'poll'
My manage.py looks following (doing monkeypatch there):
#!/usr/bin/env python
from gevent import monkey
import sys
import os
if __name__ == "__main__":
if not 'celery' in sys.argv:
monkey.patch_all()
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "webadmin.settings")
from django.core.management import execute_from_command_line
sys.path.append(".")
execute_from_command_line(sys.argv)
Is there a reason why celery tasks act like it wasn't patched properly?
p.s. strange thing that my local setup on Macos works fine while i getting such exceptions under Centos (all package versions are the same, init and config scripts too)
hello and thanks for joining me in my journey to the custom made algorithm
for "guess where the pixel is"
this for Loop set (over Point.X, Point.Y), is formed in consecutive/linear form:
//Original\initial Location
Point initPoint = new Point(150, 100);
// No' of pixels to search left off X , and above Y
int preXsrchDepth, preYsrchDepth;
// No' of pixels to search to the right of X, And Above Y
int postXsrchDepth, postYsrchDepth;
preXsrchDepth = 10; // will start search at 10 pixels to the left from original X
preYsrchDepth = 10; // will start search at 10 pixels above the original Y
postXsrchDepth = 10; // will stop search at 10 pixels to the right from X
postYsrchDepth = 10; // will stop search at 10 pixels below Y
int StopXsearch = initPoint.X + postXsrchDepth; //stops X Loop itarations at initial pointX + depth requested to serch right of it
int StopYsearch = initPoint.Y + postYsrchDepth; //stops Y Loop itarations at initial pointY + depth requested below original location
int CountDownX, CountDownY; // Optional not requierd for loop but will reports the count down how many iterations left (unless break; triggerd ..uppon success)
Point SearchFromPoint = Point.Empty; //the point will be used
for (int StartX = initPoint.X - preXsrchDepth; StartX < StopXsearch; StartX++)
{
SearchFromPoint.X = StartX;
for (int StartY = initPoint.Y - preYsrchDepth; StartY < StpY; StartY++)
{
CountDownX = (initPoint.X - StartX);
CountDownY=(initPoint.Y - StartY);
SearchFromPoint.Y = StartY;
if (SearchSuccess)
{
same = true;
AAdToAppLog("Search Report For: " + imgName + "Search Completed Successfully On Try " + CountDownX + ":" + CountDownY);
break;
}
}
}
<-10 ---- -5--- -1 X +1--- +5---- +10
what i would like to do is try a way of instead
is have a little more clever approach
<+8---+5-- -8 -5 -- +2 +10 X -2 - -10 -8-- -6 ---1-
-3
|
+8
|
-10
Y
+1
-6
|
|
+9
....
I do know there's a wheel already invented in this field (even a full-trailer truck amount of wheels (: )
but as a new programmer,
I really wanted to start of with a simple way and also related to my field of interest in my project.
can anybody show an idea of his, he learnt along the way to Professionalism in algorithm /programming
having tests to do on few approaches (kind'a random cleverness...) will absolutely make the day and perhaps help some others viewing this page in the future to come
it will be much easier for me to understand if you could use as much as possible similar
naming to variables i used or implenet your code example ...it will be Greatly appreciated if used with my code sample, unless my metod is a realy flavorless.
p.s
i think that(atleast as human being) the tricky part is when throwing inconsecutive numbers you loose track of what you didn't yet use, how do u take care of this too .
thanks allot in advance looking forward to your participation !
I've got a database in MSSQL that I'm porting to SQLite/Django. I'm using pymssql to connect to the database and save a text field to the local SQLite database.
However for some characters, it explodes. I get complaints like this:
UnicodeDecodeError: 'ascii' codec can't decode byte 0x97 in position 1916: ordinal not in range(128)
Is there some way I can convert the chars to proper unicode versions? Or strip them out?