Saturday, 31 August 2013

AngularJS - Why select drop down doesn't have $event on change

AngularJS - Why select drop down doesn't have $event on change

I am newbie to AngularJS. I have a question, why does select doesn't
passes the $event?
HTML
<div ng-controller="foo">
<select ng-model="item" ng-options="opts as opts.name for opts in
sels" ng-change="lstViewChange($event)"
ng-click="listViewClick($event)"></select>
</div>
Script
var myApp = angular.module('myApp', []);
angular.element(document).ready(function() {
angular.bootstrap(document, ['myApp']);
});
function foo($scope) {
$scope.sels = [{id: 1, name: 'a'}, {id: 2, name: 'b'}];
$scope.lstViewChange = function($event){
console.log('change', $event);
}
$scope.listViewClick = function($event){
console.log('click', $event);
}
}
Have a look at this fiddle http://jsfiddle.net/dkrotts/BtrZH/7/. Click
passes a event but change doesn't.

iOS how to use .p12 certification?

iOS how to use .p12 certification?

my teacher only gave me a .p12 certification but no developer account. How
can I use it to test my app on the real device? Even publish the app?
Thanks!

How input in a string a XML content:encode

How input in a string a XML content:encode

I have this XML
<rss>
<channel>
<item>
<title>
Title content
</title>
<link>
http://www2.XXXXXX
</link>
<dc:creator>YYYYY</dc:creator>
<category>FFFFF</category>
<description>
<![CDATA[<P>O XXXXX (...)]]>
</description>
<content:encoded>
<![CDATA[<P>O XXXXXXX XXXXXXXXXX XXXXX XXXXX XXXXX XXXXXXXXXX XXXXX
XXXXX</P>]]>
</content:encoded>
</item>
....
I use this code to read this XML, and I want get the content value from XML
$rawFeed = (file_get_contents($url_feed));
$xmldoc = new SimpleXmlElement($rawFeed);
foreach ($xmldoc->channel->item as $xmlinfo){
$title = $xmlinfo->title);
$content = $xmlinfo->content);
}
The problem is: I can recover the string $title = 'Title content', but I
cant return in a string $content
PS: I try use content:encoded, but doesn't work too
PS2. when I print_r($xmlinfo), I get
SimpleXMLElement Object ( [title] => TITLE XXXXXX [link] =>
http://www2.XXXXX.php? [category] => YYY [description] =>
SimpleXMLElement Object ( ) )

Using exceptions for control flow

Using exceptions for control flow

I have read that using exceptions for control flow is not good, but how
can I achieve the following easily without throwing exceptions? So if user
enters username that is already in use, I want to show error message next
to the input field. Here is code from my sign up page:
public String signUp() {
User user = new User(username, password, email);
try {
if ( userService.save(user) != null ) {
// ok
}
else {
// not ok
}
}
catch ( UsernameInUseException e ) {
// notify user that username is already in use
}
catch ( EmailInUseException e ) {
// notify user that email is already in use
}
catch ( DataAccessException e ) {
// notify user about db error
}
return "index";
}
save method of my userService:
@Override
@Transactional
public User save(User user) {
if ( userRepository.findByUsername(user.getUsername()) != null ) {
LOGGER.debug("Username '{}' is already in use", user.getUsername());
throw new UsernameInUseException();
}
else if ( userRepository.findByEmail(user.getEmail()) != null ) {
LOGGER.debug("Email '{}' is already in use", user.getEmail());
throw new EmailInUseException();
}
user.setPassword(BCrypt.hashpw(user.getPassword(), BCrypt.gensalt()));
user.setRegisteredOn(DateTime.now(DateTimeZone.UTC));
return userRepository.save(user);
}

How to find the file containing certain function in R

How to find the file containing certain function in R

In R, I want to modify function, however I forget which file the function
is defined. Is there any way to find the file containing certain function?
Thank you!

Wordpress : display ACF checkbox label on front end

Wordpress : display ACF checkbox label on front end

I have creted a chekbox with ACF, now I can display the values
&#8203;&#8203;of the checkboxes on my front end but I would like to show
the associated labels to.
Here is my code :
echo "<ul>";
$profession = get_field('profession');
foreach($profession as $key => $check){
echo "<li>".$check."</li>";
};
echo "</ul>";
Thanks a lot !

Not Getting proper price wise data descanding order using order by query

Not Getting proper price wise data descanding order using order by query

I am using given below line for fetch data in ordering mode but i will not
able show data in proper descanding order Here is my code
cmd = new SqlCommand("select * from product_tb where sub_id='" +
bl.sub_id + "' ORDER BY price DESC", con);

Que Append and Served

Que Append and Served

Guys i'm new to queues and finding it difficult to understand how it
works, all i understood is it Appends items and serves the first item that
was Appended.
from the given below, what i understood is everytime it appends the Link
is always NuLL is that correct? And also when does it becomes Tail !=NULL?
i'm confused cause everytime we append Tail is set to NULL...
int item;
struct Node
{
int Data;
struct Node *Link;
}; typedef struct Node *QueuePointer;
void Append(QueuePointer &Head,QueuePointer &Tail, int Num)
{
QueuePointer NewNode;
NewNode= (QueuePointer)malloc(sizeof(struct Node));
NewNode->Data = Num;
NewNode->Link = NULL;
if(Tail == NULL)
{
Head = NewNode;
// printf("Queue is empty"); //checks if queue is empty
// printf("\n");
}
else
{
Tail->Link = NewNode;
}
Tail = NewNode;
printf("Inserted number %d \n", item); //checks if Appends into Queue
working
}
void Serve(QueuePointer &Head, QueuePointer &Tail, int item)
{
QueuePointer Temp;
printf("Served ");
while(Head != NULL)
{
item = Head->Data;
Temp = Head;
Head = Head->Link;
if(Head == NULL)
{
Tail = NULL;
}
free(Temp);
printf("%d ", item); //prints out SERVED
}
}
int main()
{
QueuePointer Head, Tail;
Head=NULL;
Tail=NULL;
item=1;
for(item=1; item<=4; item++)
{
// if(item%2==0)
// {
Append(Head,Tail,item); //Appends For Every Even Number
Detected
// }
}
Serve(Head, Tail, item);//Calls out Serve Function, See LOOPING,
please refer serve function
//****NOTE: the loop for Removing items is inside Serve Function
getch();
}

Friday, 30 August 2013

Loop, Read stops after one record with GUI (doesn't loop)

Loop, Read stops after one record with GUI (doesn't loop)

I have a script for entering records in our system that was originally
working fine with a MsgBox, but I added a GUI to show the record entry.
Now the script stops after the first record.
In the example below I've stripped out all of the actions and record lines
to help make this easier to parse, but I've kept in all the important
stuff and tested this version of the script.
Loop, read, C:\_AutoHotKey\AA_test.txt
{
StringSplit, LineArray, A_LoopReadLine, %A_Tab%
aaduedate := LineArray1
aauniqueid := LineArray2
aaprefix := LineArray3
aasequence := LineArray4
aadescript := LineArray5
aaelig := LineArray6
;-------------------------------------------------------------------------------------
;Use these to test the file match in the Input File.
;Remove surrounding comments and surround the rest of the script up to the
last brace.
SendInput, Prefix: %aaprefix% {enter}
SendInput, Sequence: %aasequence% {enter}
SendInput, Description: %aadescript% {enter}
SendInput, Eligibility: %aaelig% {enter}
SendInput, ID Card: %aaidcard% {enter}
;---------------------------------------------------------------------------------------
;Pop-up validation menu
Gui, Add, Button, x22 y380 w100 h30 , &Submit
Gui, Add, Button, x362 y380 w100 h30 , &Cancel
Gui, Font, S14 CDefault, Verdana
Gui, Add, Text, x152 y10 w210 h30 +Center, Is the entry correct?
Gui, Font, S10 CDefault, Verdana
Gui, Add, Text, x102 y40 w90 h20 , %aaprefix%
Gui, Add, Text, x102 y70 w130 h20 , %aaelig%
Gui, Add, Text, x312 y70 w30 h20 , %aadescript%
Gui, Add, Text, x432 y70 w30 h20 , %aaidcard%
Gui, Font, S8 CDefault, Verdana
Gui, Add, Text, x132 y380 w230 h40 +Center, Click Submit/press S to
continue. Click cancel to stop script.
; Generated using SmartGUI Creator 4.0
Gui, Show, x9 y250 h428 w480, Auto Action Validation
Return
ButtonCancel:
ExitApp
ButtonSubmit:
Gui, Submit ;
MouseMove, 630,55
Sleep, 100
SendInput, {Click 630,55}
SendInput ^S
Return
}
The buttons do work and clicking Submit will send the MouseMove and
SendInput. But after that it just stops and doesn't load the next record
in the text file.
Thanks in advance!

Kiran under pressure to float new party - The Hindu

Kiran under pressure to float new party - The Hindu


The Hindu


Kiran under pressure to float new party
The Hindu
Chief Minister N. Kiran Kumar Reddy is increasingly under pressure from a
section of his party MLAs from the Seemandhra region to launch a new party
as they see bleak prospects for themselves after the CWC's decision to
divide the State. These leaders ...
Month after Telangana announcement, Seemandhra remains on boilDaily News &
Analysis
Andhra Pradesh has a new Leader of Opposition - Kiran Kumar Reddy?India Today
Telangana issue back in contention, TDP members stall proceedings of the
Lok ...Indian Express
IBNLive -Economic Times -Business Standard
all 71 news articles »

Thursday, 29 August 2013

XPath select all but not self::strong and self::strong/following-sibling::text()

XPath select all but not self::strong and
self::strong/following-sibling::text()

So I have following example html to parse.
<div>
<strong>Title:</strong>
Sub Editor at NEWS ABC
<strong>Name:</strong>
John
<strong>Where:</strong>
Everywhere
<strong>When:</strong>
Anytime
<strong>Everything can go down there..</strong>
Lorem Ipsum blah blah blah....
</div>
I want to extract this whole div except I don't want Title and Where and
When heading with their following values.
I have tested following XPaths so far.
a) Without following sibling (1: don't work. 2: works)
1. //div/node()[not(strong[contains(text(), "Title")])]
2. //div/node()[not(self::strong and contains(text(), "Title"))]
a) With following sibling (1: don't work. 2: don't work)
1. //div/node()[not(strong[contains(text(), "Title")]) and
not(strong[contains(text(), "Title")]/following-sibling::text())]
2. //div/node()[not(self::strong and contains(text(), "Title") and
following-sibling::text())]
How to achieve what I am after?

Upload in WebView of Windows8.1

Upload in WebView of Windows8.1

Is there any way to upload any document as a attachment or as a simple
upload? Whenever i try to upload i click on browse button and SkyDrive
gets launched. Is there any way to circumvent this and allow code to
handle picking from harddisk and not from Skydrive?

Wednesday, 28 August 2013

Build errors in eclipse

Build errors in eclipse

i have a big problem, i can't compile my eclipse projects.
Idon't understand whta is the problem. I have already searched for answer
but i stay helpless!
Hier the build error in eclipse:

Thank you!

Can't install network printer - Access is Denied?

Can't install network printer - Access is Denied?

I have a single user in a remote site with their own print server (in
reality just one of the Server 2003 DCs) who can't install any printers
from that server. They are running Windows 7 Professional. I've checked
permissions and Everyone has permissions to print to these printers. I can
install and print to them without issue, and no other users seem to be
having this problem.
Can anyone suggest why this might be happening?

Java Date Class NullPointerException

Java Date Class NullPointerException

I am trying to set and return the earliest date from a string and I think
I am missing something when setting my date as I keep getting a
nullreferenceexception whenever I try to set the values for Date. Thanks
for any help
private static Date createDate(String input)
{
Date date = null;
if (input == null)
return null;
// Split formatted input into separate values
String tempDates[] = input.split(dateSep);
// Store values as integers
int[] dateValues = {0, 0, 0};
dateValues[0] = Integer.parseInt(tempDates[0]);
dateValues[1] = Integer.parseInt(tempDates[1]);
dateValues[2] = Integer.parseInt(tempDates[2]);
// Sort integers from lowest to highest
Arrays.sort(dateValues);
// Set return date
date.setMonth(dateValues[0]);
date.setDate(dateValues[1]);
date.setYear(dateValues[2]);
System.out.println(date);
// Checking basic date restrictions
if (date.getMonth() <= 0 || date.getMonth() > 12)
throw new IllegalArgumentException("Month is not valid " + month);
if (date.getDay() <= 0 || date.getDay() > 31)
throw new IllegalArgumentException("Day is not valid " + day);
if (date.getYear() <= 0)
throw new IllegalArgumentException("Year is not valid " + year);
return date;
}
}

How to solve this error ":(.text+0x4d): undefined reference to `_imp___ZN10Management11OpenEm'"

How to solve this error ":(.text+0x4d): undefined reference to
`_imp___ZN10Management11OpenEm'"

I need to call some methods from a c++ program in a C program. But I just
have one shared library (.dll) to use those methods. To make it, first a
create a wrapper in C to call de methods from the dll to be use in the C
program. I have attention and I make sure that i declare the functions
with "extern "C" to avoid name mangling.
But when a compile I have a set o erros (shown in down) when a linking
wall de .o:
g++ -o bonnie++ bonnie++.o bon_io.o bon_file.o bon_time.o semaphore.o
sync.o thread.o bon_suid.o duration.o rand.o util.o utils.o super.o
pcm_file.o inode.o iname.o dir.o pcm.o -lpthread -L./ -lSmart
pcm.o:pcm.c:(.text+0x4d): undefined reference to
`_imp___ZN10Management11OpenEm'
pcm.o:pcm.c:(.text+0x64): undefined reference to
`_imp___ZN10Management12CloseEm'
pcm.o:pcm.c:(.text+0x73): undefined reference to
`_imp___ZN10Management17EnumerateEv'
pcm.o:pcm.c:(.text+0xb9): undefined reference to
`_imp___ZN18DemonstratorDevC1Ev'
pcm.o:pcm.c:(.text+0xf7): undefined reference to
`_imp___ZN18DemonstratorDevD1Ev'
pcm.o:pcm.c:(.text+0x121): undefined reference to
`_imp___ZN18DemonstratorDevice11OpenEi'
pcm.o:pcm.c:(.text+0x138): undefined reference to
`_imp___ZN18DemonstratorDev12CloseAdapterEv'
pcm.o:pcm.c:(.text+0x15f): undefined reference to
`_imp___ZN18DemonstratorDev23ConfigureClockFrequencyEi15_ClockFrequency'
pcm.o:pcm.c:(.text+0x176): undefined reference to
`_imp___ZN18DemonstratorDev21AdaptationBlockEnableEv'
pcm.o:pcm.c:(.text+0x1a1): undefined reference to
`_imp___ZN18CommandsManagementC1ER18DemonstratorDev'
pcm.o:pcm.c:(.text+0x1df): undefined reference to
`_imp___ZN18CommandsManagementD1Ev'
pcm.o:pcm.c:(.text+0x21a): undefined reference to
`_imp___ZN18CommandsManagement20DeviceInitializationEim9TimerCtrl'
pcm.o:pcm.c:(.text+0x253): undefined reference to
`_imp___ZN18CommandsManagement24EnableEmbeddedOperationsER8OWStatusim9TimerCtrl'
pcm.o:pcm.c:(.text+0x290): undefined reference to
`_imp___ZN18CommandsManagement12RegionUnlockEmmim9TimerCtrl'
pcm.o:pcm.c:(.text+0x2da): undefined reference to
`_imp___ZN18CommandsManagement17BufferedOverwriteEmmPKhiiim9TimerCtrl'
pcm.o:pcm.c:(.text+0x32c): undefined reference to
`_imp___ZN18CommandsManagement9BurstReadEmPtmih9BurstTypeim9TimerCtrl'
/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../../i686-pc-cygwin/bin/ld:
pcm.o: bad reloc address 0x20 in section `.eh_frame$_ZN10ManagementC1Ev'
collect2: error: ld returned 1 exit status
Makefile:37: recipe for target `bonnie++' failed
make: *** [bonnie++] Error 1
Someone Know what I am doing wrong?

Differences between MSBuild v4.0 and VS 2010 Build

Differences between MSBuild v4.0 and VS 2010 Build

Our developers use VS 2010 to build locally; however, our CI server uses
MSBuild v4.0 scripts to build code in source.
I'm aware that VS uses MSBuild behind the scenes but what are the
differences between the two, if any?

Parent & Child Node with different images & Clickable Event - Treeview Blackberry

Parent & Child Node with different images & Clickable Event - Treeview
Blackberry

I am using tree view in app to show the client server data in blackberry.
Same thing i chieved in android app by using expanable listview items. But
here i facing two issues
One is:
I want to add parent node icone like a folder icon & Child node must have
different icone For example if Parent item is images then child nodes must
have Images icon, if parent item is video Then child have video icons.
Second:
When i click on any child node(Like image child node), This node open in
new screen & show the clickable item wether i click on image, video.
Here is my code that i used to Get the desired result:
package mypackage;
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.FontFamily;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.component.TreeField;
import net.rim.device.api.ui.component.TreeFieldCallback;
class CustomTreeFieldCallback implements TreeFieldCallback {
public void drawTreeItem(TreeField _tree, Graphics g, int node,
int y,
int width, int indent) {
// FontFamily
FontFamily fontFamily[] = FontFamily.getFontFamilies();
Font font = fontFamily[1].getFont(FontFamily.CBTF_FONT, 18);
g.setFont(font);
String text = (String) _tree.getCookie(node);
Bitmap b = Bitmap.getBitmapResource("images.png");
g.drawText(text, indent + b.getWidth(), y);
g.drawBitmap(indent, y - 15, b.getWidth(), b.getHeight(), b,
0, 0);
}
}
package mypackage;
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.component.TreeField;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.decor.Background;
import net.rim.device.api.ui.decor.BackgroundFactory;
public class FilesManager extends MainScreen {
public FilesManager() {
// Set the linear background.
Bitmap background = Bitmap.getBitmapResource("background.png");
Background bg =
BackgroundFactory.createBitmapBackground(background);
this.getMainManager().setBackground(bg);
String parentNode = new String("Images");
String firstChild = new String("first child");
String secondChild = new String("second child");
String thirdChild = new String("third child");
CustomTreeFieldCallback myCallback = new
CustomTreeFieldCallback();
myTree = new TreeField(myCallback, Field.FOCUSABLE);
int node2 = myTree.addChildNode(0, parentNode);
myTree.addChildNode(node2, firstChild);
myTree.addChildNode(node2, secondChild);
myTree.addChildNode(node2, thirdChild);
add(myTree);
}
}
I also attached the screenShot that i make in android. Any one give me
guideline to achieve this thing in bb.
Attached Image: http://postimg.org/image/m3owjfl8h/

Oracle STS (Security Token Service) has anyone used it? [on hold]

Oracle STS (Security Token Service) has anyone used it? [on hold]

Has anyone out there actually implemented Oracle STS? I am curious, their
own documentation is purposefully light on implementation details.
I'd like to know what you're using it for?
Is it only useful in a pure Oracle environment?
Can it be used as a replacement for Oracle Access SDK in some cases?
I can't find anyone who has ever used this feature of Oracle Fusion
Middleware.

Tuesday, 27 August 2013

Beginner Clang/LLVM/Ubuntu

Beginner Clang/LLVM/Ubuntu

I am required to use LLVM and Clang for a compilers class I am enrolled
in. This is not a question about the content of the class, merely how to
get the required software installed.
I am running gcc version 4.6.3 and have downloaded, built, tested, and
updated what I believe to be LLVM suite version 3.4 (the latest svn
edition). I do a simple "hello world" application, as referenced on the
LLVM getting started page, but on the line
lli helloworld.bc
I get the error "lli:helloworld.bc: Invalid MODULE_CODE_GLOBALVAR record"
I am a complete beginner with this stuff so I don't know if I gave you
everything you would need to fix my error, drop me a comment if you need
to know something else. Also please try to give me as detailed
instructions as possible...I've been thrown into the world of Ubuntu and
Clang without any instruction and can't bear to read another "solution"
that says "read the man pages".
Thank you so so much for your help. I just want to get this set up so I
can at least try the homework.

per-task data structure in linux kernel module

per-task data structure in linux kernel module

I am writing a loadable kernel module for Linux. And I need to store some
data for each task in Linux kernel (These data would be used in a
scheduler callback).
I know that I can modify struct task_struct and insert my own fields. But
since I am willing to write a relatively clean kernel module, I cannot
modify any code resides in original Linux source tree.
It is also possible to maintain some sort of mapping from struct
task_struct to my data in a hash table. But it seem to be a little too
heavy-weight.
My question is: is there any simple and clean way that allows me
registering per-task data-structure in Linux kernel without modifying
struct task_struct?
Many thanks!

How to call the post action of a form from outside it

How to call the post action of a form from outside it

Hi Guys i have a form that will be submitted when a button one my toolbar
is clicked. That button is outside the form. How do i achieve this, below
is what i have tried so far. Thanks
The Button
<li>
<a id="frmsub" title="" data-placement="bottom" data-title="Save"
onclick="$('#testfrm').submit()">
<span class="glyphicon glyphicon-floppy-save"></span>
</a>
</li>
My Form
<div class="vx-ds-widget">
<div class="container">
@using (Html.BeginForm("EditCreateProfile", "Manage",
FormMethod.Post, new { @id = "testfrm" }))
i have also tried this but not is working so far
$('#frmsub').click(function () {
$('#testfrm').submit();
});
{

How do i break the loop when connection fails?

How do i break the loop when connection fails?

Im working on a ping batch program. What i wanna learn is how do i skip
the loop when the connection is dead? For an example:
@echo off
:1
ping www.stackoverflow.com
(I guess) if errorlevel 1 set errorlev=1
If errorlevel 1 goto 2
goto 1
:2
Echo ping failed!
Title ping failed!
color c

How to get Authentication code from google plus when login in c#

How to get Authentication code from google plus when login in c#

how to get Authentication Code from google plus when login in c#,I use
this code below but it error and It gets authentication code is null
protected PlusService plusService;
protected Person me;
private IAuthorizationState _authstate;
public MainWindow()
{
InitializeComponent();
me = null;
_authstate = null;
}
public static class ClientCredentials
{
static public string ClientID = "521993821366.apps.googleusercontent.com";
static public string ClientSecret = "zeBqO2pghQAWeef_wUV6b365";
}
private OAuth2Authenticator<NativeApplicationClient> CreateAuthenticator()
{
var provider = new
NativeApplicationClient(GoogleAuthenticationServer.Description);
provider.ClientIdentifier = ClientCredentials.ClientID;
provider.ClientSecret = ClientCredentials.ClientSecret;
var authenticator =new
OAuth2Authenticator<NativeApplicationClient>(provider,GetAuthorization1);
return authenticator;
}
private static IAuthorizationState
GetAuthorization1(NativeApplicationClient arg)
{
// Get the auth URL:
IAuthorizationState state = new AuthorizationState(new[] {
PlusService.Scopes.PlusLogin.GetStringValue()});
state.Callback = new Uri(NativeApplicationClient.OutOfBandCallbackUrl);
Uri authUri = arg.RequestUserAuthorization(state);
// Request authorization from the user (by opening a browser window):
Process.Start(authUri.ToString());
Console.Write(" Authorization Code: ");
string authCode = Console.ReadLine();
Console.WriteLine();
var result = arg.ProcessUserAuthorization(authCode, state);
return result;
}
//Function to get Friend List and ProfileInfo public void Authenticate() {
var auth = CreateAuthenticator(); plusService = new PlusService(new
BaseClientService.Initializer() { Authenticator = auth }); if (plusService
!= null) { PeopleResource.GetRequest getReq =
plusService.People.Get("me"); PeopleResource.ListRequest listRequest =
plusService.People.List("me", PeopleResource.CollectionEnum.Visible);
PeopleFeed friendFeed = listRequest.Fetch(); Person me = getReq.Fetch();
if (me != null)
{
statusText.Text = "You successfully Authenticated!";
resultText.Text = "UserName: " + me.DisplayName + "\nURL: " +
me.Url +
"\nProfile id: " + me.Id + "\nLocation:" + me.Gender +
me.Emails;
}
Dictionary<string, string> dd = new Dictionary<string, string>();
foreach (Person friend in friendFeed.Items)
{
dd.Add(friend.DisplayName, friend.Id);
}
}
}

Reading CSV file into SQLite into ListView (SimpleAdapter). It's terribly slow. Am I doing this right?

Reading CSV file into SQLite into ListView (SimpleAdapter). It's terribly
slow. Am I doing this right?

I'm kind of new to handling data with multiple kinds of storages, and I'm
not sure if I'm doing this right.
So I have a CSV file with 6 rows, and ~20 columns. I parse it, then read
it into a database. (using OpenCSV)
When I have this database, I create a hash map of it, and use a
SimpleAdapter to display it in a ListView.
Said listview has items which are pretty complex, each of them has around
~20 textviews ("click to expand"-y thing)
The whole thing of course runs depending if the database has already been
created or not.
so if database already exists --> only read the database and do the list
mapping if database doesnt exist, do the whole CSV->database->list job...
My problem is that it's REALLY slow. Doing only 6 rows takes up 13.1777
milliseconds. And this is only my test CSV file, the final app will have
to handle hundreds of rows.
So my question would be simple:
Can I make this thing any faster? I feel like I'm overcomplicating this.
here is some of my code:
Here am I calling the two functions that do the job:
public void showEszkoz() throws Exception {
Cursor c = databaseEszkoz.selectRecords();
System.out.println("row count: " + c.getCount());
if (c.getCount() == 0)
{
System.out.println("read csv to database to list");
readCsvIntoDatabase();
readDatabaseToList();
}
else
{
System.out.println("only database read to list");
readDatabaseToList();
}
}
This the function that reads the CSV files:
public void readCsvIntoDatabase() throws IOException {
InputStream is = getResources().openRawResource(R.raw.eszkoz);
Reader myReader = null;
try {
myReader = new InputStreamReader(is, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
CSVReader reader = new CSVReader(myReader);
reader.readNext();
try {
while ((nextLine = reader.readNext()) != null) {
databaseEszkoz.createRecords(Integer.parseInt(nextLine[0]),
Integer.parseInt(nextLine[1]), nextLine[2],
nextLine[3], nextLine[4], nextLine[5], nextLine[6],
nextLine[7], nextLine[8], nextLine[9], nextLine[10],
nextLine[11], nextLine[12], nextLine[13], nextLine[14],
nextLine[15], nextLine[16], nextLine[17], nextLine[18],
nextLine[19], nextLine[20], nextLine[21], nextLine[22],
nextLine[23], nextLine[24], nextLine[25]);
}
} catch (IOException e) {
e.printStackTrace();
}
}
and this is the function that reads the database and displays it in a list
public void readDatabaseToList() { ArrayList> mylist = new ArrayList>();
HashMap map;
Cursor c = databaseEszkoz.selectRecords();
c.moveToFirst();
while (!c.isAfterLast()) {
System.out.println("This is the current row:" + c.getString(0));
map = new HashMap<String, String>();
map.put("_id", c.getString(0));
map.put("ESZKOZ_ID", c.getString(1));
map.put("ESZKOZ_LELTARSZAM", c.getString(2));
map.put("ESZKOZ_EAN", c.getString(3));
map.put("ESZKOZ_LEIRAS", c.getString(4));
map.put("ESZKOZ_TIPUS", c.getString(5));
map.put("ESZKOZ_FOCSOPORT_KOD", c.getString(6));
map.put("ESZKOZ_CSOPORT_KOD", c.getString(7));
map.put("ESZKOZ_ALCSOPORT_KOD", c.getString(8));
map.put("ESZKOZ_LELTARCSOP_KOD", c.getString(9));
map.put("ESZKOZ_ALLELTARCSOP_KOD", c.getString(10));
map.put("ESZKOZ_HR_KOD", c.getString(11));
map.put("ESZKOZ_SZERVEZET_KOD", c.getString(12));
map.put("ESZKOZ_MENNYISEG", c.getString(13));
map.put("ESZKOZ_MENNYISEGI_EGYSEG", c.getString(14));
map.put("ESZKOZ_STATUSZ", c.getString(15));
map.put("ESZKOZ_AKTIVALT_ERTEK", c.getString(16));
map.put("ESZKOZ_NETTO_ERTEK", c.getString(17));
map.put("ESZKOZ_SZAMVITEL_KAT", c.getString(18));
map.put("ESZKOZ_MEGJEGYZES", c.getString(19));
map.put("ESZKOZ_BESZERZES_DATUM", c.getString(20));
map.put("ESZKOZ_GARANCIA_KEZD_VEG", c.getString(21));
map.put("ESZKOZ_GYARI_SZAM", c.getString(22));
map.put("ESZKOZ_LELTAR_MENNYISEG", c.getString(23));
map.put("ESZKOZ_LELTAR_ALLAPOT", c.getString(24));
map.put("ESZKOZ_LELTAR_MEGJEGYZES", c.getString(25));
mylist.add(map);
c.moveToNext();
}
c.close();
mSchedule = new SimpleAdapter(context, mylist, R.layout.row_eszkoz,
new String[] { "_id", "ESZKOZ_ID", "ESZKOZ_LELTARSZAM",
"ESZKOZ_EAN", "ESZKOZ_LEIRAS", "ESZKOZ_TIPUS",
"ESZKOZ_FOCSOPORT_KOD", "ESZKOZ_CSOPORT_KOD",
"ESZKOZ_ALCSOPORT_KOD", "ESZKOZ_LELTARCSOP_KOD",
"ESZKOZ_ALLELTARCSOP_KOD", "ESZKOZ_HR_KOD",
"ESZKOZ_SZERVEZET_KOD", "ESZKOZ_MENNYISEG",
"ESZKOZ_MENNYISEGI_EGYSEG", "ESZKOZ_STATUSZ",
"ESZKOZ_AKTIVALT_ERTEK", "ESZKOZ_NETTO_ERTEK",
"ESZKOZ_SZAMVITEL_KAT", "ESZKOZ_MEGJEGYZES",
"ESZKOZ_BESZERZES_DATUM", "ESZKOZ_GARANCIA_KEZD_VEG",
"ESZKOZ_GYARI_SZAM", "ESZKOZ_LELTAR_MENNYISEG",
"ESZKOZ_LELTAR_ALLAPOT", "ESZKOZ_LELTAR_MEGJEGYZES" },
new int[] { R.id.row_eszkoz_id, R.id.row_eszkoz_eszkoz_id,
R.id.row_eszkoz_leltar_szam, R.id.row_eszkoz_ean,
R.id.row_eszkoz_leiras, R.id.row_eszkoz_tipus,
R.id.row_eszkoz_focsoport_kod,
R.id.row_eszkoz_csoport_kod,
R.id.row_eszkoz_alcsoport_kod,
R.id.row_eszkoz_leltarcsoport_kod,
R.id.row_eszkoz_alleltarcsoport_kod,
R.id.row_eszkoz_hr_kod,
R.id.row_eszkoz_szervezeti_egyseg_kod,
R.id.row_eszkoz_mennyiseg,
R.id.row_eszkoz_mennyisegi_egyseg,
R.id.row_eszkoz_statusz,
R.id.row_eszkoz_aktivalt_ertek,
R.id.row_eszkoz_netto_ertek,
R.id.row_eszkoz_szamviteli_kategoria,
R.id.row_eszkoz_megjegyzes,
R.id.row_eszkoz_beszerzes_datuma,
R.id.row_eszkoz_garancia_kezd_veg,
R.id.row_eszkoz_gyari_szam,
R.id.row_eszkoz_leltarozott_allapot,
R.id.row_eszkoz_leltarozott_mennyiseg,
R.id.row_eszkoz_leltarozott_megjegyzes });
list.setAdapter(mSchedule);
}

Monday, 26 August 2013

Google Drive API - "Resource metadata required" in inserting comments to a file even though resource is specified

Google Drive API - "Resource metadata required" in inserting comments to a
file even though resource is specified

I'm trying to add a comment to a Google Drive document - the auth tokens
and client IDs are all correct (trying to do everything else works), but
when adding a comment - I get an error:
code: 400,
message: 'Resource metadata required',
data:
[ { domain: 'global',
reason: 'required',
message: 'Resource metadata required' } ] }
No idea what's going on. I'm sending in a resource that contains {
content: 'something' } and also another param for fileId.
Please let me know if you have any ideas.
Thanks!

Make terminal transparent to show wallpaper

Make terminal transparent to show wallpaper

The opacity option of the Gnome terminal in Ubuntu had a neat behavior,
which showed the desktop wallpaper instead of the other windows behind it.
Has anyone been able to make Mac Terminal, or an alternative terminal app,
do this? I know you can set a terminal wallpaper, which squashes and
stretches with the terminal window. Thanks!

nvarchar change max size on the fly

nvarchar change max size on the fly

I've always been bothered by the need for max lengths on SQL string
columns. There is some data for which there is no true max length. For
example, let's say you have a field to store someone's first name, and you
make it NVARCHAR(50). It's always possible (although highly unlikely) that
someone has a name longer than 50 chars.
Would it be feasible to change the field's max length on the fly? What I
mean by this is, when you do an INSERT/UPDATE, you check if the person's
name is longer than 50 chars, and ALTER the table if need be before you do
the INSERT/UPDATE. (Or perhaps, catch an exception and perform an ALTER if
need be).
Would the ALTER be a slow operation if the table had a lot of data in it?
Let's say you alter the column to be NVARCHAR(100). Would a SELECT from
this table be slower than if you'd made it NVARCHAR(100) from the
beginning?

Remote client doesn't receive UDP packets

Remote client doesn't receive UDP packets

I have simple UDP server/client program, I forwarded my ports and server
receives and sends packets via internet,but the client on the remote
machine cant receive them,so im wondering how to receive packets without
forwarding ports on client side(if its even possible)? And if its not
possible , what should i do to make client to receive UDP packets via
internet?

AJAX Record Deletion Using jQuery

AJAX Record Deletion Using jQuery

Hello i just found a code to delete a row from my database using ajax but
the thing is that when the delete is made in the html the table that
should dissapear does not work.
here is the js code
<script type="text/javascript" />
$(document).ready(function() {
$('a.delete').click(function(e) {
e.preventDefault();
var parent = $(this).parent();
$.ajax({
type: 'get',
url: 'index.php',
data: 'ajax=1&delete=' + parent.attr('id').replace('record-',''),
beforeSend: function() {
parent.animate({'backgroundColor':'#fb6c6c'},300);
},
success: function() {
parent.slideUp(300,function() {
parent.remove();
});
}
});
});
});

and the PHP code is this one
<? echo "<div class=\"record\" id=\"record-".$id."\" >
<tr >
<td><span style='color:#eb8500' >".++$i."</span></td>
<td width='270px' style='padding:5px'><div align='left' >
".$name."
</div></td>
<td width='50px' style='padding:5px'><div align='left' >
<input onclick='this.select()' type='text' size='15'
value='".$link."' />
</div>
</td>
<td style='padding:5px'><div align='center'>
".$cat."
</div>
</td>
<td >
<a class=\"delete\" href=\"?delete=".$id."\" >Delete</a>
</td>
</tr>
</div >"; ?>
it should delete all the table displayed in the echo, but it doesnt. thank
for the help...

Dumping Nutch Crawldb

Dumping Nutch Crawldb

How can I get a dump of the Nutch crawldb of all the urls with status 3
(db_gone). The version of Nutch I am using 1.4.
I looked at the wiki but it is unclear on how to do this

Query builder and entity inheritance

Query builder and entity inheritance

I have entities:
abstract class AbstractEntity
{
private $someField;
}
/**
* ...
* @ORM\Entity(repositoryClass="ConcreteEntityRepository")
*/
class ConcreteEntity extends AbstractEntity
{
private $otherField;
}
class ConcreteEntityRepository extends EntityRepository
{
public function getSomething()
{
$qb = $this->getEntityManager()->createQueryBuilder()
->select('t')
->from('MyBundle:ConcreteEntity', 't');
$result = $query->getResult();
}
}
Result will be with correct count of fields but values of parent class
will be null. How can I correctly get all the fields?
And when I try to use:
->select('t.someField') // Error
->select('t.otherField') // Good

$(1+4\sqrt[3]2-4\sqrt[3]4)^n=a_n+b_n\sqrt[3]2+c_n\sqrt[3]4$

$(1+4\sqrt[3]2-4\sqrt[3]4)^n=a_n+b_n\sqrt[3]2+c_n\sqrt[3]4$

For non-negative integer $n$, write
$$(1+4\sqrt[3]2-4\sqrt[3]4)^n=a_n+b_n\sqrt[3]2+c_n\sqrt[3]4$$
where $a_n,b_n,c_n$ are integers. For any non-negative integer $m$, prove
or disprove
$$2^{m+2}|c_n\iff2^m|n$$
So far I have $[a_n, b_n, c_n]^T=[1, -8, 8; 4, 1, -8; -4, 4, 1][a_{n-1},
b_{n-1}, c_{n-1}]^T$ where [1, -8, 8; 4, 1, -8; -4, 4, 1] is a 3 by 3
matrix with rows $(1, -8, 8) ; (4, 1, -8); (-4, 4, 1)$

Sunday, 25 August 2013

Display image with wildcard in src

Display image with wildcard in src

I have a series of photos on a server with a strict naming convention:
"uniqueId-readableName.jpg". I do this because my website database
currently only logs the uniqueID (and some unrelated info), but people
occasionally need to look at the file server directly to browse the photos
(via FTP) so a readable name is useful. For example
001456-War Horse.jpg
003295-Sunshine Daiseys.jpg
129084-Laboring at the farm 2013-08-11.jpg
Now, I'm fairly sure the best option would be to set up the database with
a record of the full file names, but I just wanted to see if anyone had
any ideas I may have missed. This question on SO is similar, but here I
have strict naming conventions - not sure if that opens up any
possibilities or not.
I'm applying this to img, but the same idea could be appled to any file
extension (eg, download "789-My Homework.zip" or "123-Family
vacation.zip").
As an example of what I'm looking for, in Windows Explorer you can do a
file search for
0*.jpg
and all of the following files can be returned
001456-War Horse.jpg
003295-Sunshine Daiseys.jpg
029084-Laboring at the farm 2013-08-11.jpg
In my case the beginning part is always unique, so I'd like to use
something like 001456-*.jpg and have it return 001456-War Horse.jpg.
Is there any way do this on a website?
<img src="001456-*.jpg" />

how to change the word 'preface' in Scientific Workplace 5.5

how to change the word 'preface' in Scientific Workplace 5.5

I'm having a problem with the language in SWP 5.5. I am writting a text in
spanish, so I am using the \usepackage[spanish]{babel} sentence at the
beginning of the document and it works perfectly with all the format.
However, the word 'Preface' still appears in english after the ToC in the
pdf output. Any help is welcome.

WHM VPS - No Domains Working - Can Ping Nameserver

WHM VPS - No Domains Working - Can Ping Nameserver

I recently moved everything from one VPS to another which resulted in me
having to change the nameservers IP address. I'm not sure if I've done
something wrong or I'm missing something as no domains point to the new
VPS and I simply get an unknown host warning when pinging any of them. The
nameservers can be pinged though.
I firstly changed the nameserver IPs in the GoDaddy control panel.
Initially I was using one IP for both and they when pinged both show the
correct IP. I have now changed NS2 to a secondary IP address (this still
hasn't updated and a ping still shows the other IP for NS1).
I have added A records for the nameservers in WHM and also for the
hostname but I'm not sure if I'm missing something somewhere and that is
the reason why it isn't working?
The resolvers I currently have set as the Level3 public ones but I also
tried with the Google Public resolvers and that hasn't seemed to change
anything.
I have CSF running on the VPS and port 53 is open for TCP/UDP traffic.
The domain in question is www.evaske.com. The hostname set is
chocolate.evaske.com and the nameservers are ns1 and ns2.
Anything else I can check to see if it's something I've done wrong?

Saturday, 24 August 2013

Bufferedimages directly to zip file in Java

Bufferedimages directly to zip file in Java

How can I save lots of Bufferedimages directly to zip file? BufferedImages
array to zip file maybe? Just not to disk it is slow!
public static void main(String[] args) throws Exception {
for (int i = 0; i < 10; i++) {
JFrame jf = new JFrame();
Panel a = new Panel();
JRadioButton birdButton = new JRadioButton();
birdButton.setSize(100, 100);
birdButton.setSelected(true);
jf.add(birdButton);
getSaveSnapShot(birdButton, i + ".bmp");
}
}
public static BufferedImage getScreenShot(Component component) {
BufferedImage image = new BufferedImage(component.getWidth(),
component.getHeight(), BufferedImage.TYPE_BYTE_GRAY);
// paints into image's Graphics
component.paint(image.getGraphics());
return image;
}
public static void getSaveSnapShot(Component component, String
fileName) throws Exception {
BufferedImage img = getScreenShot(component);
// BufferedImage img = new
BufferedImage(image.getWidth(),image.getHeight(),BufferedImage.TYPE_BYTE_GRAY);
// write the captured image as a bmp
ImageIO.write(img, "bmp", new File(fileName));
}

YouTube Oauth2 token problems

YouTube Oauth2 token problems

I am wanting to get the current logged in YouTube users details for my site.
After some playing around, I found a way.
The problem is, depending on my "scope" parameter, I do not get all what I
should be getting.
So here is an echo of some info I am looking at.
Author code:
xxxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxx
RESULT code:
"{ "access_token" : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "token_type" :
"Bearer", "expires_in" : 3599 }"
channelId: xxxxxxxxxxxxx
userId: xxxxxxxxxxxxxxxxx
username: xxxxxxxxx
displayname: XxxxxxxXxxxx
So all looks good??? Well no. For my immediate needs it will do, but not
for long term.
The issue is as mentioned, the "scope" parameter. If I set it to
scope=https://www.googleapis.com/auth/youtube
I can access the info, but it does not log it in the "Authorised Access"
list in my Google account.
But if I set the scope to
scope=https://www.googleapis.com/auth/youtube.readonly
it will log the access, but then I cant get the user info.
I will be needing to have it log the user as authorised as well as get
their channel info so that I can get my refresh token for later
developments.

Cocos 2D Stir Animation

Cocos 2D Stir Animation

I'm a newbie so please be gentle.
I'm trying to create animation in Cocos2D that works this way: I have a
cup filled with water and I want to start to stir it with the help of
touch,so when making circular motions with my finger the water will also
move. Any help?

Simple Jquery Color Fade In

Simple Jquery Color Fade In

I've been working on trying to get a simple color fade in using the Jquery
code I have below. I'm basically attempting to activate the 'hover' class
when a user moves his/her mouse over a link. At the moment, the code
doesn't work but I hope it illustrates what I'm trying to accomplish. The
hover class is initially set to 0 opacity and then I want it to fade in.
Any assistance would be greatly appreciated!
Thank you
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<style>
#menu-name li a{
color: black;
text-shadow: 0px 1px 4px #777;
background-color: green;
width: 200px;
}
#menu-name li a .hover {
background: orange;
}
</style>
<script type="text/javascript"?>
$(document).ready(function(){
//Set the anchor link opacity to 0 and begin hover function
$("#menu-name li a").hover(function(){
//Fade to an opacity of 1 at a speed of 200ms
$(this).find('.hover').stop().animate({"opacity" : 1}, 300);
//On mouse-off
}, function(){
//Fade to an opacity of 0 at a speed of 100ms
$(this).find('hover').stop().animate({"opacity" : 0}, 200);
});
});
</script>
</head>
<script src="jquery-1.9.1.js"></script>
<body>
<div id="menu-container">
<ul id="menu-name">
<li><a href="#">Health Care</a></li>
<li><a href="#">Love</a></li>
</ul>
</div>
</body>
</html>

Does operator precedence works the same way for string as for numbers?

Does operator precedence works the same way for string as for numbers?

While code golfing I stumbled on a peculiar issue
>>> print '%'+'-+'[1]+str(5)+'s'%'*'
Traceback (most recent call last):
File "<pyshell#178>", line 1, in <module>
print '%'+'-+'[1]+str(5)+'s'%'*'
TypeError: not all arguments converted during string formatting
My assumption was operator evaluation happens from left to right, but in
this particular case, it seems that even though its string operation, %
takes priority over+ and tries to evaluate 's'%'*' before the
concatenation and fails
Is this a known documented behavior, or there is something more that is
not obvious to me.

AlertDialog.Builder not stay on screen

AlertDialog.Builder not stay on screen

In my application I am showing AlertDialog.Builder
AlertDialog.Builder alert = new AlertDialog.Builder(this);
and in this aleart there is one EditText and PositiveButton.
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setMessage("Enter Text");
final EditText input = new EditText(this);
input.setInputType(InputType.TYPE_CLASS_TEXT |
InputType.TYPE_TEXT_VARIATION_PASSWORD);
alert.setView(input);
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
if(input.getTest().getText().toString().equalsIgnoreCase("")){
Toast.makeText(Activity.this, "Please enter some text",
Toast.LENGTH_LONG).show();
}
}
if nothing is entered then it show Please enter some text on tost and the
dialog is closed but I want the AleartDialog will not close. How this
possible?

Azure package does not include solution libraries in one of two web roles

Azure package does not include solution libraries in one of two web roles

I have a solution in Visual Studio with a bunch of library projects, two
web application projects and a cloud project. One web app has a dependancy
on all libraries and the second web app depends on the first web app only
(this app is not finished yet and will depend on part of the libraries,
eventually).
The problem is, when I publish the solution to azure, only the second web
app includes the libraries in it's bin folder, but the first app has only
external dependencies. Although when I build the solution, all the
necessary files are included.

SlidingPaneLayout does not cover the left side panel

SlidingPaneLayout does not cover the left side panel

how to understand it? why the left panel is not hidden?
My xml file:
<android.support.v4.widget.SlidingPaneLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment android:id="@+id/headlines"
android:layout_height="match_parent"
android:name="by.zubov.task.fragments.TitlesFragment"
android:layout_width="380dp"
/>
<FrameLayout android:id="@+id/details"
android:layout_width="500dp"
android:layout_weight="1"
android:layout_height="match_parent" />
result: Image result
testing this is code on Htc One (display 540x960).

Layout Issue in Android Application for Gogole TV

Layout Issue in Android Application for Gogole TV

I have different layout folder inside for res folder :
layout
layout-large
layout-sw600dp
layout-sw800dp
layout-xlarge
Now i am going to my existing android application in Google TV emultor.
For Google TV layout compatible i have added layout-large-notouch folder,
but my application is render layout from layout-large for Google TV.
I do not want to remove layout-large and i do not want to any change in
layout-large.
Is there any for render layout for Google TV from different folder..?

Friday, 23 August 2013

what's the difference between head and branch using Git in Eclipse

what's the difference between head and branch using Git in Eclipse

I am using git inside Eclipse. Can someone please explain the difference
between HEAD and master[branch] in the drop down menu selected? I usually
choose one completely arbitrarily and so far this arbitrariness hasn't
appeared to make much difference, but I am sure that's gonna come back to
haunt me if I don't figure it out soon.

Warning "Command \@makecol has changed."

Warning "Command \@makecol has changed."

When I compile my documment I get the following warning Command \@makecol
has changed.
TexStudio points to the file footmisc.sty. Of course I've tried to install
its latest version (2011/06/06 v5.5b) but still have the problem :(
MWE:
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage[bottom,hang]{footmisc}
\usepackage[T1]{fontenc}
\begin{document}
mediante DHCP\footnote{Se puede obtener más información sobre esta
utilidad en el documento anexo Guía de usuario de Xen: Instalación,
configuración y primeros pasos}
\end{document}
I've seen that by reordering the fancyhdr and footmisc sentences the
warning doesn't occur, but still not sure if with that there's no error or
it's just that fancyhdr doesn't check well.

Image url in Css file under stylesheets under public Rails 2.3

Image url in Css file under stylesheets under public Rails 2.3

I am working with Rails 2.3.5 and I have images in public/images/ which
are added into css file named as custom.css
#cssmenu ul {
background: url(nav-bg.png) repeat-x 0px 4px;
height: 69px;
}
How can i make this read the image which in inside public/images ? I have
tried this but it did not work
#cssmenu ul {
background: url(<%= asset_path '/images/nav-bg.png' %>) repeat-x 0px 4px;
height: 69px;
}

What is the proper way to manually check and uncheck a RadioButton when the AutoCheck property is set to false in C#?

What is the proper way to manually check and uncheck a RadioButton when
the AutoCheck property is set to false in C#?

I have a set of radio buttons, and two of them need to prompt the user
with a confirmation dialog before allowing the value to change. To do
this, I handle the click event and set the AutoCheck property to false on
each of these radio buttons. However, the previously selected RadioButtons
are no longer unchecked when I set the check property to true on the
clicked RadioButton.
Right now I'm just looping through the controls on this panel and making
sure none of the other RadioButtons are checked, but is there a more
efficient way to do this?

Get the value of the Item in the Listview

Get the value of the Item in the Listview

I have an array of Strings i.e. String [] values ={"Adult 1","Adult
2","Child 1","Child 2","Infant 1","Infant 1"};
With this array I am creating a listView . On click on a listview item, I
am opening a custom dialog that have 2 edit text and on TextView.
So click on the item I want to set the value of edit text with the value
of item, if it is not Adult, Child or Infant.
And I also want to check - if the item is not adult, I have to set the
visibility of textview in the custom dialog visible.
How could I do this?
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
}
});

Unit testing : ViewController has no segue with identifier : "segue id"

Unit testing : ViewController has no segue with identifier : "segue id"

I want to test below method :
- (void)myMethod
{
self.contact = nil;
[self performSegueWithIdentifier:@"segue id" sender:self];
}
This is what I do in test class :
- (void)testMyMethod
{
// Call method to test
[testClass myMethod];
// Tests
GHAssertNil(testClass.contact, @"contact should be nil.");
}
Running the test gives me error :
Reason : Receiver (<RS_MainViewController:0x126b6330>) has no segue with
identifier 'segue id'
Why I get this error and what is the solution?

Thursday, 22 August 2013

How to find the longest memo field in any table of my database?

How to find the longest memo field in any table of my database?

How to find the longest memo field in any table of my database?
Can I do it with a single SQL query?

Copy Excel Table Between Two Worksheets

Copy Excel Table Between Two Worksheets

I have tried various expressions to do [what appears to be] the simple
task of copying an excel table between two worksheets. In addition, I need
to enclose the expression inside a loop. Here are four expressions (all
beginning with "Sheets") I have tried. All of them compile, but then crash
upon running:
For i = 1 To NumTables
p = 6
'Read "OP LLs" table into "EIRP budget"
Sheets("EIRP Budget").[B6:L17] = Sheets("OP LLs").Range(Cells(p, 2),
Cells(p + 11, 12))
Sheets("EIRP Budget").[B6:L17] = Sheets("OP LLs").[Cells(p, 2),
Cells(p + 11, 12)]
Sheets("OP LLs").Range(Cells(p, 2), Cells(p + 11, 12)).Copy
Sheets("EIRP Budget").[B6]
Sheets("OP LLs").["B" & p & : & "L" & p + 11].Copy Sheets("EIRP
Budget").[B6:L17]
p = p + 15
Next
Any help would be greatly appreciated.

Embedded Google Spreadsheet document doesn't render in mobile devices

Embedded Google Spreadsheet document doesn't render in mobile devices

This web page embeds a range of a Google Spreadsheets document. It works
well in a desktop browser and it used to work in iPhone and Adnroid
browsers.
Recently it stopped working on iPhone and Android.
Did Google change something on the way spreadsheets are embedded in a
mobile device?
What can I do to fix it?

Mac app is still running after deleting Info.plist

Mac app is still running after deleting Info.plist

I want to build a Mac App from scratch. I manually created the required
folders of main app, Contents, MacOS, Resources, and dropped the binaries.
The only one I don't know how to create from scratch is "Info.plist". So,
I just copied one from the installed Applications on my machine, removed
all the unfamiliar keys, except the Executable and Package type (as APP).
Then I did a test. Before I copied and editted the Info.plist file, I
double-clicked the app icon in Finder. Not working, which is expected.
After I copied and editted the Info.plist file, it is working, which is
also expected. Next is what I don't understand. I removed the Info.plist
file, and double-clicked the app icon in Finder, it is STILL working!
My question is:
Did the first time running migrate the Info.plist information to some
secret place in the app bundle?
Is copying and editing an existing Info.plist file from other applications
a good practice for building an app from scratch?

Compiling QT with MSVC 2012 fails

Compiling QT with MSVC 2012 fails

I installed QT 5.1 VS2012 release and installed successfuly.
I get error while compilng the project in QT Creator with the 'jom' thingy
saying:
*"jom:
F:\tmp2\build-testprj-Desktop_Qt_5_1_0_MSVC2012_32bit-Debug\Makefile.Debug
[debug\mainwindow.obj] Error 2 jom:
F:\tmp2\build-testprj-Desktop_Qt_5_1_0_MSVC2012_32bit-Debug\Makefile.Debug
[debug\moc_mainwindow.obj] Error 2 jom:
F:\tmp2\build-testprj-Desktop_Qt_5_1_0_MSVC2012_32bit-Debug\Makefile
[debug] Error 2 17:30:06: The process
"C:\Qt\Qt5.1.0\Tools\QtCreator\bin\jom.exe" exited with code 2. Error
while building/deploying project testprj (kit: Desktop Qt 5.1.0 MSVC2012
32bit) When executing step 'Make'"*

How do I exclude first ten and last 1 li from hide() jquery

How do I exclude first ten and last 1 li from hide() jquery

So far I've this:
$(".actor ul li").not($(".actor ul li").slice(0,11)).hide();
I also would like to exclude last li from hide(). How would I do that?
obvious answer would be to also show :last. But there should be an elegant
way to do this :)

How to get reference for TextView which is not in activity_main.xml?

How to get reference for TextView which is not in activity_main.xml?

wordonlist.xml:
<TextView
android:id="@+id/tvHiragana"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="Hiragana"
android:textColor="@color/blackColor"
android:textColorHint="@color/blackColor"
android:textSize="18sp" />
MainActivity:
setContentView(R.layout.activity_main);
tvHiragana = (TextView) findViewById(R.id.tvHiragana);
Typeface tf =
Typeface.createFromAsset(getAssets(),"fonts/JapaneseLetter.ttf");
tvHiragana.setTypeface(tf,Typeface.BOLD);
Result:
NullPointerException in the line tvHiragana.setTypeface(tf,Typeface.BOLD);
I think it is because of TextView which is not in activity_main.xml. How
to get reference for TextView which is in wordonlist.xml?

Wednesday, 21 August 2013

jquery appended objects all have the same left value

jquery appended objects all have the same left value

So I have a javascript/jquery code It appends a bunch of span elements to
the main div container and then animates them to move to the left. I need
to be able to detect the left value of each span element, however when I
output the left value to the console log it shows that they all have the
same value. any ideas?
http://jsbin.com/uKobuja/2/

Items disappearing from array within array

Items disappearing from array within array

I create a NSMutableArray that I need as long as my app lives, lets call
it suseranArray, just after the @implementation of my main class. This
Array will hold several objects of a class called Vassal. A Vassal is
simply:
1) A NSMutableString 2) Another NSMutableString 3) A NSMutableArray 4)
Another NSMutable Array
Each Vassal created is also needed for the life of the app, and they never
change.
These objects are made as (retain) properties in an .h file, synthesized
in the .m file, and each given an alloc+init whenever the object Vassal is
created during the init function. Each vassal has data filled in and
stored in the suzerain Array. the 3rd item always has several elements,
and after a bug appeared, I put a line to check if it is ever empty, but
it never is, and life is good.
Now, later on when a certain Vassal object is needed, we try to access its
3rd property to fetch the data in there, and sometimes that array empty...
I checked to see if it disappeared somehow, but it is always there on the
debug, carrying a nice address like 0x2319f8a0 which makes sense since the
NSMutableString just above it is at address 0x2319fb40 - (I was expecting
00000000 after a lot of headache). What is happening? I my head, I am
creating an RETAINed objects, which retains data put in by default, and
that object is put inside another, but somehow the data inside the array
vanishes. What possible scenario could lead to this? Thank you for your
time :)
Note: the last array currently just holds one item at this stage of
development, and curiously enough, that one item is never missing, despite
the two arrays being 'brothers'

Write operation is happening from 1 Gigabit port instead of 10 Gigabit port in NetGear switch and its random

Write operation is happening from 1 Gigabit port instead of 10 Gigabit
port in NetGear switch and its random

We have a Synology system which is connected with NetGear switch. We
passed 2, 10 gigabit cables from synology to switch. We connected HP
server with switch with 2, 10 gigabit port. We connected one more network
on 1 gigabit port to a switch. We installed VMWare on the server and
testing write test on Synology system. While testing, some time write
operation is going through 1 gigabit port. The NetGear switch is smart
enough to route the traffic to the fastest connection (i.e. from 10
gigabit port). This thing is happening on random. Sometimes write
operation is going through 1 gigabit port and sometime its going through
10 gigabit port. We are performing write test from the server which is
connected with two 10 gigabit port.

Event handling : Accessing another widget's property

Event handling : Accessing another widget's property

OK, this should be easy.
I tried to handle drop event onto a QGraphicsView widget. Incoming data
dragged from a QTreeView widget. For that, I re-implemented these methods:
void QGraphicsScene::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
{
event.accept();
}
void QGraphicsScene::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
{
event.accept();
}
void QGraphicsScene::dropEvent(QGraphicsSceneDragDropEvent *event)
{
event.accept();
}
void QGraphicsView::dropEvent(QDropEvent *event)
{
QPixmap pixmap(event->mimedata()->urls()[0].toString().remove(0,8));
this.scene()->addPixmap(pixmap);
}
This works fine; but how can I change another graphicsview scene within
this widget's drop event? That is:
void QGraphicsView::dropEvent(QDropEvent *event)
{
QPixmap pixmap(event->mimedata()->urls()[0].toString().remove(0,8));
// I cannot access ui; and cannot access my widgets...:
ui->anotherview->scene()->addPixmap(pixmap);
}

Top of screen application menu bar on every monitor in multiple display

Top of screen application menu bar on every monitor in multiple display

I have a two monitor setup but the top of the screen application menu bar
appears only on one (main) monitor. I would like it to appear on both so
that I don't have to travel with my mouse from the other to the main
monitor to use it. Can this be done and how?

Combining php function

Combining php function

This code works:
$host =
parse_url('http://www.cc.joomla.xc.my/paypal.com/myspace.com/login.php',
PHP_URL_HOST);
$host_names = explode(".", $host);
print_r($host_names);
echo "<br>";
$l = array_slice($host_names, -3);
print_r($l);
echo "<br>";
$subdomain = implode(".", $l);
echo $subdomain; //final result

Is it possible to combine function in one line for example like this:
$host_names = implode(array_slice (explode(".", $host)($host_names,
-3)(".", $l);
The example above does not worked. I think I have seen it before where you
can combine function.
Thanks in advance for any help.

Tuesday, 20 August 2013

Persistence ignorance and DDD reality

Persistence ignorance and DDD reality

I'm trying to implement fully valid persistence ignorance with little
effort. I have many questions though:
The simplest option
It's really straightforward - is it okay to have Entities annotated with
Spring Data annotations just like in SOA (but make them really do the
logic)? What are the consequences other than having to use persistance
annotation in the Entities, which doesn't really follow PI principle? I
mean is it really the case with Spring Data - it provides nice
repositories which do what repositories in DDD should do. The problem is
with Entities themself then...
The harder option
In order to make an Entity unaware of where the data it operates on came
from it is natural to inject that data as an interface through
constructor. Another advantage is that we always could perform lazy
loading - which we have by default in Neo4j graph database for instance.
The drawback is that Aggregates (which compose of Entities) will be
totally aware of all data even if they don't use them - possibly it could
led to debugging difficulties as data is totally exposed (DAO's would be
hierarchical just like Aggregates). This would also force us to use some
adapters for the repositories as they doesn't store real Entities
anymore... And any translation is ugly... Another thing is that we cannot
instantiate an Entity without such DAO - though there could be in-memory
implementations in domain... again, more layers. Some say that injecting
DAOs does break PI too.
The hardest option
The Entity could be wrapped around a lazy-loader which decides where data
should come from. It could be both in-memory and in-database, and it could
handle any operations which need transactions and so on. Complex layer
though, but might be generic to some extent perhaps...? Have a read about
it here
Do you know any other solution? Or maybe I'm missing something in
mentioned ones. Please share your thoughts!

How to build exe which puts files in appdata folder and creates a shortcut to the program?

How to build exe which puts files in appdata folder and creates a shortcut
to the program?

I have a javascript application.
index.php runs the application.
I want to create an exe which puts all the files into the appdata folder,
and which creates a shortcut to the index.php so that the application can
be run.
This way users don't know where the application files are so they can't
copy the application (not easily anyway).
How do I do this?

slider works fully local but when online it doenst show

slider works fully local but when online it doenst show

i started yesterday with my portfolio site and i finished the home page.
i put it on my server and found out the slider magically didnt work .
i already checked the links to js and the (window).load i changed in
(document).ready and still no effect.
is there something wrong with the server or did i overlook something ?
website - ( responsive grid systems ) slider - ( blueberry ) online adress
- (jurjenfolkertsma.nl)
im still using original pictures becourse i didnt changed the content yet.
<head>
<link rel="stylesheet" href="blueberry.css" />
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script src="jquery.blueberry.js"></script>
</head>
<body>
<div class="blueberry">
<ul class="slides">
<li><img src="" /></li>
<li><img src="" /></li>
<li><img src="" /></li>
<li><img src="" /></li>
</ul>
<script>
$(window).load(function() {
$('.blueberry').blueberry();
});
</script>
</body>
</div>

Conditional classes applied in ng-repeat using $index inconsistent when filtering

Conditional classes applied in ng-repeat using $index inconsistent when
filtering

I have a ng-repeat which is filtered with an input box. In this list,
there are .active and .disabled items. Everything renders correctly, but
when I filter it with a query, the active and disabled classes are messed
up because the index of the display changed.
Here is a jsFiddle showing the problem. You see that the second row is
highlighted (class active added). Now try to type "iphone" in the input
box. The second line will be highlighted, even if it's not active.
How can I get around this and have reliable data in my ng-repeat?

Message publishing error using Kombu and Rabbitmq

Message publishing error using Kombu and Rabbitmq

I want to start off by saying that I'm new to not just python but
programming in general. With that in mind this is my issue. I am trying to
send some data to my Rabbitmq server. Below is my Python code. The
json_data is just a variable that holds some json formatted data.
with Connection("amqp://username:password@test_server.local:5672/#/") as
conn:
channel = conn.channel()
producer = Producer(channel, exchange = "test_exchange",
serializer="json") <--- Line 43
producer.publish(json_data)
print "Message sent"
This produces the following error:
Traceback (most recent call last): File "test.py", line 43, in <module>
producer = Producer(channel, exchange = "test_exchange",
serializer="json") File
"/Library/Python/2.7/site-packages/kombu/messaging.py", line 83, in
__init__ self.revive(self._channel) File
"/Library/Python/2.7/site-packages/kombu/messaging.py", line 210, in
revive self.exchange = self.exchange(channel) TypeError: 'str' object is
not callable
Any help would be appreciated. Thanks.

onchange open a page in a new tab

onchange open a page in a new tab

I am converting some <ul> into a <select> for small devices, like this:
$("#blog aside .widget, #blog-single aside .widget").each(function() {
var widget = $(this);
$("<select />").appendTo(widget);
/* option en blanco*/
$("<option />", {
"value" : '',
"text" : widget.find('h3').text()+'..'
}).appendTo(widget.find('select'));
widget.find('ul li a').each(function(){
var el = $(this);
$("<option />", {
"value" : el.attr("href"),
"text" : el.text()
}).appendTo(widget.find('select'));
});
});
And i would like to open this links in a new tab, this is how i'm trying:
$("#blog select, #blog-single select").change(function() {
var url = $(this).find("option:selected").val();
/* simulamos target _blank, ya que son externos */
var a = document.createElement('a');
a.href= url;
a.className = 'external';
a.target = '_blank';
document.body.appendChild(a);
a.click();
});
wich seems to do the job in Firefox but in chrome i'm getting the blocked
popup warning (it won't thought if the user clicks instead of simulating
it with JS
any workaround this?

css position with percent

css position with percent

i have a problem with position divs relative in an other div.
I want to make a Div that is position in the horizontal middle of the
screen and in this div i want to place 3 other div with the same height.
But all of them should be responsive.
A picture says more than words :)

<div id="zwrapper">
<div id="z1" class="row"></div>
<div id="z2" class="row"></div>
<div id="z3" class="row"></div>
</div>
The blu element is the HTML
html{
background: steelblue;
height: 100%;
width: 100%;
top:0; left:0; bottom: 0; right:0;
}
The lime one ist that div (#zwrapper) where i want to add the three red divs.
#zwrapper{
height: 81%;
top: 10%;
width: 100%;
left: 0;
position: absolute;
background: lime;
}
The red divs make problems. All divs have a height of 30%. The first one
should be aligned to top and the third to bottom. The middle div with the
id #z2 is the only one which get a margin of 5%.
.row{
position: relative;
width: 80%;
background: red;
height: 30%;
}
#z2{
margin: 5% 0;
}
My idea was to put the 3 divs with a height of 30% into the wrapper and
give the middle one a margin (top / bottom) of 5% so i get a height of
100%. But this does not work.
If i resize the window in width, the height of the red divs changes though
i dont change the height.
I make a fiddle to demonstrate this. http://jsfiddle.net/ELPJM/
Thanks in advance

Monday, 19 August 2013

jquery gallery with authentication

jquery gallery with authentication

I would like to set up a web site with a photo gallery where users can
download only their pictures after they log in. At first I used
FileThingie as a file manager which does basically what I need.
A new requirements says that previews of the pictures should be shown and
I think that doesn't work with the file manager script.
So I would like to know if there is gallery script or plugin where users
can watch and download only photos meant for them. I don't want to use
Wordpress or any CMS if possible.
Thanks for your help in advance.
Frank

which site sele the safe FFXIV GIL and better service

which site sele the safe FFXIV GIL and better service

FFXIV ARR comes, and I love this game,but I have not enough time to farm
gil myself, so i need buy some gil. some one give me a site:
www.buyffxivgil.net. and said that this site provide nice service, but i
am not sure about that, anyone brought ffxiv gil form this site?

selectedIndex UItabBarController not working

selectedIndex UItabBarController not working

I know this is gonna be an easy fix, but for some reason when i try to fix
my issue with other solutions, it just doesnt work. In my app I set up
Push Notifications, and I'm trying to set up the functionality of opening
the app to a certain tabBarItem when the app is opened from a
Notifications. here is the code i have so far, please tell me if I'm even
using the right method. I'm not very experienced with AppDelegate.m so
please forgive me if its completely wrong.
AppDelegate.m
#import <CoreLocation/CoreLocation.h>
@interface AppDelegate : UIResponder
<UIApplicationDelegate,UITabBarControllerDelegate,CLLocationManagerDelegate>{
CLLocationManager *locationManager;
}
@property (strong, nonatomic) UIWindow *window;
@property(nonatomic,readonly) UITabBar *tabBar;
@property(nonatomic,strong) UITabBarController *tabBarController;
@end
AppDelegate.m
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIApplication* app = [UIApplication sharedApplication];
app.networkActivityIndicatorVisible = YES;
[[UIApplication sharedApplication]
registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeBadge |UIRemoteNotificationTypeSound)];
return YES;
}
- (void)application:(UIApplication*)application
didReceiveRemoteNotification:(NSDictionary*)userInfo{
/* this works just fine*/
NSLog(@"opening from a notification!!");
/*this is what doesnt work at all*/
self.tabBarController = [[UITabBarController alloc] init];
[self.tabBarController ];
self.tabBarController.selectedIndex = 3;
/*also when i do nslog the selectedIndex it gives me this value
"2147483647"*/
NSLog(@"%i is the tabbar item",tabBarController.selectedIndex);
}

How can i process this form alone

How can i process this form alone

I have this function on an html form, the form script there is this
<script type="text/javascript">
var conf = {
isVip:false,
isMem:false
};
</script>
and here is the the button, the button is to process two form in the html,
here is the button.
<li class="current">
<a href="#" onclick="submitAction('process.php')">Ãâ·ÑÓÊÏäµÇ¼</a>
</li>
<li>
<a href="#" onclick="submitAction('process.php')"><span
class="vip"></span>VIPSubmit</a>
</li>
<a href="#" class="loginBtn"
Here is the form
<form name="vip_login" method="post" action="process.php">
<input tabindex="1" id="vipname" type="text" class="username"
name="username" value=""/><span class="vipDomain">@name.com</span>
<input tabindex="2" id="vippassword" type="password"
class="password" name="password" value=""/>
My question is, how do i make the btn to process my form alone and send
data to external process.php function.

A passage from a news article..what does this mean?

A passage from a news article..what does this mean?

I found this sentence. I don't understand this.
This is the link.
http://thediplomat.com/flashpoints-blog/2013/08/12/can-india-blockade-china/
Fourth, and finally, the debate over how to respond to China is valuable
because, in being sparked by the decision to raise a mountain corps, it
has been couched as a trade-off, and therefore brings the question of
priorities to the forefront.
What does this mean in the context of this article...The meaning is very
ambiguous.

How to configure wso2 servers logging the same level of detail as console output in wso2carbon.log file

How to configure wso2 servers logging the same level of detail as console
output in wso2carbon.log file

When we run the bin/wso2server.sh file in a terminal, we get nice verbose
logging output in the same terminal which is very useful for debugging.
But the output in the repository/log/wso2carbon.log file is minimal. I
have checked all the other files in the repository/log/ directory and none
have the same level of verbosity as the console output.
I tried settings under Home > Configure > Logging after logging in to the
management console of wso2 application server. Specifically I set the
settings for "Configure Log4J Appenders" for CARBON_LOGFILE to be the same
as for CARBON_CONSOLE but this did not have desired effect. The web
application level info and debug messages are shown on the terminal from
where we started the wso2 application server but this is not shown in the
wso2carbon.log file.
How do we get the same level of detail i.e. verbose output like we get in
the terminal into the repository/log/wso2carbon.log file?

Sunday, 18 August 2013

how to stream a response over HTTP with netty

how to stream a response over HTTP with netty

I'm using Netty 3.6.6 and I'd like to send a large response back to the
caller. I can't copy the response body into a ChannelBuffer as in some
cases it will be very large.
I'm migrating a server from CXF to Netty, previously, I could just use the
OutputStream provided by CXF to write the data.
I originally tried to just send the response without content, and then
continued to write data to the Channel in a series of 8k buffers. This
failed as the client seemed to get the original response and see no data
and complain. I tried setting the response as chunked, but this didnt seem
to make a difference, nor did setting the chunked header, the client
always saw an empty stream.
I saw the file server example for 3.6.6, and that's similar to what I want
to do, except the data will not be a file. I saw the ChunkedStream &
NioStream, which seemed close to what I need, except they take
InputStream/ReadableByteChannel whereas I have an OutputStream; I could
try using the PipedInput & OutputStreams, but that seems like it would
introduce an unfortunate bottleneck.
I'm sure there's a way to stream a lot of data back to the client in
response to a request, but I'm just not seeing how to do it unless I have
a file.

New to Powershell, unfamiliar with scripts. Renaming files in a batch with a counter

New to Powershell, unfamiliar with scripts. Renaming files in a batch with
a counter

I found several answers on this site about renaming files in Powershell so
I'm sorry if this is a repeat. I've spent a good 5 hours on google and
various websites trying to figure this out. I really did try to explain
well.I am not a programmer just someone that is meticulous about their
filing. I have 14,000 picture sorted into files by year and month but
taken with multiple cameras and I want the file name to reflect the date
taken. For example October 16, 1998 pictures are in a folder called 1998
subfolder 10 October subfolder 19981016. I want the all the pictures to be
named 19981016_0001 19981016_0002 etc. I tried multiple suggestions but it
hasn't worked. Probably due to my lack of programmer knowledge haha. Could
someone help me out and give me dummy instructions? I can get to the point
where it list the folder I want to change but I'm unable to actually
change it. All of my pictures are .jpg. I tried to attach a screenshot of
what I did but unfortunately I can't since I'm too new here. Thanks in
advance!
I created a temp file of copies in case I messed it up. I started by
typing cd "C:\Documents and Settings\Brooke LastName\Desktop\Temp" then
after successfully getting my file to load I used a formula I found on
this forum.
ls *jpg | Foreach {$i=1} {Rename-Item _ -NewName
("$($.19981016){0:00000000#} .jpg" -f $i++) -whatif}
The error I got said
Unexpected token ' .19981016' in expression or statement.
At line:1 char:12 + $.19981016 <<<<
The error repeated several times
I found several formulas on the web but most created files that would
number with parenthesis for example vacation (1).jpg I want a four digit
counter after an underscore at the end of my date. ie 19981016_0001

Isend/Irecv doesn`t work but Send/Recv does

Isend/Irecv doesn`t work but Send/Recv does

When I use Send/Recv my code works but when I replace Send/Recv with
Isend/Irecv it yields segmentation fault. But before going anywhere else I
wanted to verify whether the following snippet seems alrite or not.
The rest of the code should be fine as Send/Recv works; but I have pasted
here as its long.
DO I=1,52
REQ(I)=MPI_REQUEST_NULL
ENDDO
IF (TASKID.NE.0) THEN
NT=TASKID
CALL
MPI_ISEND(RCC(IIST:IIEND,JJST:JJEND,KKST:KKEND),SIZE(RCC),MPI_DOUBLE_PRECISION,0,8,MPI_COMM_WORLD,REQ(NT),IERR)
ENDIF
IF (TASKID.EQ.0) THEN
DO NT = 1,26
CALL
MPI_IRECV(CC(RSPANX(NT):RSPANXE(NT),RSPANY(NT):RSPANYE(NT),RSPANZ(NT):RSPANZE(NT)),SIZECC(NT),MPI_DOUBLE_PRECISION,NT,8,MPI_COMM_WORLD,REQ(NT+26),IERR)
ENDDO
ENDIF
CALL MPI_WAITALL(52,REQ,ISTAT,IERR)

echo part of a json code

echo part of a json code

I'm using imgur API to upload an image and then I'd like to echo the link
of the image. Here is the code:
<?php
$client_id = 'xxxxxxxxxxx';
$file = file_get_contents("http://mywebsite.com/image.jpeg");
$url = 'https://api.imgur.com/3/image.json';
$headers = array("Authorization: Client-ID $client_id");
$pvars = array('image' => base64_encode($file));
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL=> $url,
CURLOPT_TIMEOUT => 30,
CURLOPT_POST => 1,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_POSTFIELDS => $pvars
));
$json_returned = curl_exec($curl); // blank response
echo $json_returned;
curl_close ($curl);
?>
The json_returned is something like this:
{"data":{"id":"93MubeE","title":null,"description":null,"datetime":1376842908,"type":"image\/jpeg","animated":false,"width":2197,"height":1463,"size":70884,"views":0,"bandwidth":0,"favorite":false,"nsfw":null,"section":null,"deletehash":"bk5k8HrAeH8aOtW","link":"http:\/\/i.imgur.com\/93MubeE.jpg"},"success":true,"status":200}
How can I echo image's url only? Thank you!

DragNDropListView Custom List view setItemChecked not working

DragNDropListView Custom List view setItemChecked not working

I have found a library on github https://github.com/terlici/DragNDropList
which implements listView among other things.
One particular issue is that setItemChecked doesn't update the UI. I have
checked all the usual gotchas like calling notifyDataSetChanged and
CHOICE_MODE_MULTIPLE
Is there any known quirk with android where setItemChecked doesn't work
properly with classes that implement listView?

How include in php works?

How include in php works?

I have file a.php and data folder in one folder. In data folder, I create
two files: b.php and c.php. Content of each file
a.php
<?php
$a = 1;
include('data/b.php');
?>
b.php
<?php
include('data/c.php');
?>
c.php
<?php
echo $a;
?>
When I run file a.php, result is 1. But I change content of file b.php to
include('c.php'); the result of file a.php is also 1, I think it it show
an error because file a.php and file c.php is not in one folder. Thank
you.

Saturday, 17 August 2013

how to pass custom class parameter in myBatis

how to pass custom class parameter in myBatis

//this is my custom Page class
public class Page<T> {
private int pageNo = 1;
private int pageSize = 5;
private int totalRecord;
private int totalPage;
private List<T> results;
//store the query conditon parameter that could be add dynamically
private Map<String, Object> params = new HashMap<String, Object>();
public int getPageNo() {
return pageNo;
}
public void setPageNo(int pageNo) {
this.pageNo = pageNo;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public int getTotalRecord() {
return totalRecord;
}
public void setTotalRecord(int totalRecord) {
this.totalRecord = totalRecord;
int totalPage = totalRecord%pageSize==0 ? totalRecord/pageSize :
totalRecord/pageSize + 1;
this.setTotalPage(totalPage);
}
public int getTotalPage() {
return totalPage;
}
public void setTotalPage(int totalPage) {
this.totalPage = totalPage;
}
public List<T> getResults() {
return results;
}
public void setResults(List<T> results) {
this.results = results;
}
public Map<String, Object> getParams() {
return params;
}
public void setParams(Map<String, Object> params) {
this.params = params;
}
}
// Mapper XML //here how to get the query parameter value in params (this
is a HashMap in Page Class) select * from vincent_user where name=
#{params.name} and #{params.age}
//test code
@Test
public void findUsersByPage(){
SqlSession sqlSession = sqlSessionFactory.openSession();
try {
UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
Page<User> page = new Page<User>();
page.setPageNo(1);
page.setPageSize(10);
Map<String, Object> params=new HashMap<String, Object>();
params.put("name", "%andy%");
params.put("age", 18);
page.setParams(params);
List<User> users = userMapper.findUsersPage(page);
page.setResults(users);
System.out.println(page);
System.out.println("--------------------------------------------------");
for (User user : users) {
System.out.println(user.getName());
}
} finally {
sqlSession.close();
}
}

Setting a cookie based on query string for split testing

Setting a cookie based on query string for split testing

If a query string is detected, I want to update/set a cookie so a
particular dir is used for that browser session or until the query string
is explicitly set again. Visitor is not to see the dir, but instead will
just see http://mydomain.com/.
This is what I have so far but it doesn't work as expected. Pretty sure
I'm writing the logic wrong, but not sure where.
RewriteCond %{QUERY_STRING} splittest=(A|B)
RewriteRule splittest=(A|B) [CO=splittest:$1:%{HTTP_HOST}:0:/,L]
RewriteCond %{QUERY_STRING} splittest=A [OR]
RewriteCond %{HTTP_COOKIE} splittest=A
# Split test A
RewriteRule ^(.*)$ A/$1 [L]
# Split test B
RewriteRule ^(.*)$ B/$1 [L]

How to restart listening Twitter straming Api Again?

How to restart listening Twitter straming Api Again?

I'm using Twitter4j to get Tweets real time via. Twitter streaming API and
it is working fine . Sometime it throws Exception due to network
connecting issue(or some other reason) which is also OK to me however I'm
not able to recover from this condition & it require server restart . Can
someone please suggest how to restart listening Twitter straming Api Again
without server restart . We have TwitterStreamFactory & TwitterStream
class in Twitter4j. Many thanks in advance .

Questions about STL containers in C++

Questions about STL containers in C++

How often do std::multimap and std::unordered_multimap shuffle entries
around? I'm asking because my code passes around references to distinguish
between entries with the same hash, and I want to know when to run the
reference redirection function on them.
What happens if I do this:
std::multimap Table; //Tyype specification stuff left out
//Code that pus in two entries with the same key, call that key foo
int bar = Table[foo];
Is the result different if it's an unordered_multimap instead?
Back to passing references around to distinguish entries with the same
hash. Is there a safer way to do that?

URL rewrite not working in CodeIgniter hosted with dreamhost

URL rewrite not working in CodeIgniter hosted with dreamhost

So I've gone through dozens of forum posts and websites between dreamhost,
codeingiter etc. I have a file directory set up in codeigniter hosted on
dreamhost as follows: mysite.com > application|system|user_guide|.htaccess
the live site i can access is mysite.com/index.php/site/WhatIwantToKeep
my .htaccess file reads:
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
Currently if i go to mysite.com/site/WhatIwantToKeep it can't find it. If
i place any IfModule tags or options lines, it gives a server 500 error.
Ideally this code would rewrite it so that my urls would be reading:
mysite.com/WhatIwantToKeep
Thanks!

PHP - MySQL - How to check if value updated or not

PHP - MySQL - How to check if value updated or not

I have a php code to update / change value of already existing record like;
$con = mysql_connect("server","username","password");
if (!$con){
die('Could not connect: ' . mysql_error());
}
mysql_select_db("database", $con);
$query = mysql_query("UPDATE table SET field1='$newvalue1',
field2='$newvalue2' WHERE key = '$key'") or exit(mysql_error());
echo "true";
I want to echo "true" if data is updated and echo "false" if there is some
syntax error or if record don't exist or something else, where record
value remain unchanged. How can I do this?
Note: I know mysqli* and I prefer it over mysql*, but here for traditional
mysql*
Thanks in advance...:)