Mention 2 modifications that can be done to a linked list data structure
so that it is converted into a binary tree data structure?
It's an A level question. I looked it out on google but only programs are
found. I need theory explanation.
Saturday, 31 August 2013
Does EF not using the same old concept of creating large query that leads to degrade performance?
Does EF not using the same old concept of creating large query that leads
to degrade performance?
I know this could be a stupid question, but a beginner I must ask this
question to experts to clear my doubt. When we use Entity Framework to
query data from database by joining multiple tables it creates a sql query
and this query is then fired to database to fetch records.
"We know that if we execute large query from .net code it will increase
network traffic and performance will be down. So instead of writing large
query we create and execute stored procedure and that significantly
increases the performance."
My question is - does EF not using the same old concept of creating large
query that leads to degrade performance.
Experts please clear my doubts. Thanks.
to degrade performance?
I know this could be a stupid question, but a beginner I must ask this
question to experts to clear my doubt. When we use Entity Framework to
query data from database by joining multiple tables it creates a sql query
and this query is then fired to database to fetch records.
"We know that if we execute large query from .net code it will increase
network traffic and performance will be down. So instead of writing large
query we create and execute stored procedure and that significantly
increases the performance."
My question is - does EF not using the same old concept of creating large
query that leads to degrade performance.
Experts please clear my doubts. Thanks.
How to rename a column of a pandas.core.series.TimeSeries object?
How to rename a column of a pandas.core.series.TimeSeries object?
Substracting the 'Settle' column of a pandas.core.frame.DataFrame from the
'Settle' column of another pandas.core.frame.DataFrame resulted in a
pandas.core.series.TimeSeries object (the 'subs' object).
Now, when I plot subs and add a legend, it reads 'Settle'.
How can I change the name of a column of a pandas.core.series.TimeSeries
object?
thank you.
Substracting the 'Settle' column of a pandas.core.frame.DataFrame from the
'Settle' column of another pandas.core.frame.DataFrame resulted in a
pandas.core.series.TimeSeries object (the 'subs' object).
Now, when I plot subs and add a legend, it reads 'Settle'.
How can I change the name of a column of a pandas.core.series.TimeSeries
object?
thank you.
Rails will_paginater and result refresh
Rails will_paginater and result refresh
I use will_paginate for my project and it works fine but.. When i search
for users ordered by current_sign_in_at i have correct results for first
page, but when in the meantime somebody login and i go to second page -
second page doesnt return correct results. Last result on second page is
replaced with last from first page. I know what is a problem - new logged
user is moved on first position soo the last user from first page is moved
+1.
How can i resolve this? Some results query cache?
I use will_paginate for my project and it works fine but.. When i search
for users ordered by current_sign_in_at i have correct results for first
page, but when in the meantime somebody login and i go to second page -
second page doesnt return correct results. Last result on second page is
replaced with last from first page. I know what is a problem - new logged
user is moved on first position soo the last user from first page is moved
+1.
How can i resolve this? Some results query cache?
java.awt.image.BufferedImage.getRBG not returning expected values
java.awt.image.BufferedImage.getRBG not returning expected values
I'm trying to use the BufferedImage.getRGB method with seven parameters to
read an area of pixels and to get their colors. Sounds simple enough, but
for some reason it just won't work for me. Here's a short, self contained,
compilable example:
import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class BufferedImageTest extends JPanel {
BufferedImage image;
public static void main(String[] args) {
BufferedImageTest mainClass = new BufferedImageTest();
mainClass.run();
}
private void run() {
initWindow();
// Create image:
image = new BufferedImage(5, 5, BufferedImage.TYPE_INT_RGB);
int[] red = new int[25];
for (int i = 0; i < 25; i++)
red[i] = Color.RED.getRGB();
image.setRGB(1, 0, 3, 5, red, 0, 0);
// Read image:
int[] rgbArray = new int[25];
int w = image.getWidth();
int h = image.getHeight();
image.getRGB(0, 0, w, h, rgbArray, 0, 0);
for (int i = 0; i < rgbArray.length; i++) {
Color c = new Color(rgbArray[i]);
System.out.print("(" + c.getRed() + "," + c.getGreen() + "," +
c.getBlue() + ")");
if (i % 5 == 4)
System.out.println("");
}
}
@Override
public void paint(Graphics g) {
g.drawImage(image, 5, 5, null);
}
private void initWindow() {
JFrame frame = new JFrame();
frame.getContentPane().add(this);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(40, 60);
frame.setVisible(true);
}
}
In the run() method I first create a very simple 5 by 5 pixel image like
this:
That goes fine. I then try to read in the pixels of that image, and that
doesn't work almost at all. It only gets the first line of pixels
correctly, then displays the rest as black. The output of the printing
loop is:
(0,0,0)(255,0,0)(255,0,0)(255,0,0)(0,0,0)
(0,0,0)(0,0,0)(0,0,0)(0,0,0)(0,0,0)
(0,0,0)(0,0,0)(0,0,0)(0,0,0)(0,0,0)
(0,0,0)(0,0,0)(0,0,0)(0,0,0)(0,0,0)
(0,0,0)(0,0,0)(0,0,0)(0,0,0)(0,0,0)
when I would expect it to be entirely like the first line. What am I
missing here? I have tried writing it all over from the scratch and
playing with the "scanline" and "offset" parameters in the getRGB call,
but nothing seems to work. I'm running Java 7 on Windows 7, if that makes
any difference.
I'm trying to use the BufferedImage.getRGB method with seven parameters to
read an area of pixels and to get their colors. Sounds simple enough, but
for some reason it just won't work for me. Here's a short, self contained,
compilable example:
import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class BufferedImageTest extends JPanel {
BufferedImage image;
public static void main(String[] args) {
BufferedImageTest mainClass = new BufferedImageTest();
mainClass.run();
}
private void run() {
initWindow();
// Create image:
image = new BufferedImage(5, 5, BufferedImage.TYPE_INT_RGB);
int[] red = new int[25];
for (int i = 0; i < 25; i++)
red[i] = Color.RED.getRGB();
image.setRGB(1, 0, 3, 5, red, 0, 0);
// Read image:
int[] rgbArray = new int[25];
int w = image.getWidth();
int h = image.getHeight();
image.getRGB(0, 0, w, h, rgbArray, 0, 0);
for (int i = 0; i < rgbArray.length; i++) {
Color c = new Color(rgbArray[i]);
System.out.print("(" + c.getRed() + "," + c.getGreen() + "," +
c.getBlue() + ")");
if (i % 5 == 4)
System.out.println("");
}
}
@Override
public void paint(Graphics g) {
g.drawImage(image, 5, 5, null);
}
private void initWindow() {
JFrame frame = new JFrame();
frame.getContentPane().add(this);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(40, 60);
frame.setVisible(true);
}
}
In the run() method I first create a very simple 5 by 5 pixel image like
this:
That goes fine. I then try to read in the pixels of that image, and that
doesn't work almost at all. It only gets the first line of pixels
correctly, then displays the rest as black. The output of the printing
loop is:
(0,0,0)(255,0,0)(255,0,0)(255,0,0)(0,0,0)
(0,0,0)(0,0,0)(0,0,0)(0,0,0)(0,0,0)
(0,0,0)(0,0,0)(0,0,0)(0,0,0)(0,0,0)
(0,0,0)(0,0,0)(0,0,0)(0,0,0)(0,0,0)
(0,0,0)(0,0,0)(0,0,0)(0,0,0)(0,0,0)
when I would expect it to be entirely like the first line. What am I
missing here? I have tried writing it all over from the scratch and
playing with the "scanline" and "offset" parameters in the getRGB call,
but nothing seems to work. I'm running Java 7 on Windows 7, if that makes
any difference.
Oracle Inner/Outer/Full Join
Oracle Inner/Outer/Full Join
I have two tables table1 and table2
In table1 i have two columns table1.userid and table2.full_name and in
table2 i have two columns table2.userid and table2.ssn
I want records where userid present in both table1 and table2.
Records having userid present in table1 should be ignored if they are
present in table2. If not present than want data from table1 also. Also
want rest of the data from table2.
Should i use inner/outer/full join?
Can you please help me for the same.
I have two tables table1 and table2
In table1 i have two columns table1.userid and table2.full_name and in
table2 i have two columns table2.userid and table2.ssn
I want records where userid present in both table1 and table2.
Records having userid present in table1 should be ignored if they are
present in table2. If not present than want data from table1 also. Also
want rest of the data from table2.
Should i use inner/outer/full join?
Can you please help me for the same.
multiple databases and multiple models in django
multiple databases and multiple models in django
I have two databases and two models:one the admin and the is user.
I want to sync my models to the two databases; admin model to database A
and user model to database B;
If I setting the model path to INSTALLED_APPS and syncdb,the two models
will sync to the default database.
if I setting the database in syncdb command such as sync
--database="B",and the two models will sync to database B.
so my problem the how to sync the two models to two databases?
I have two databases and two models:one the admin and the is user.
I want to sync my models to the two databases; admin model to database A
and user model to database B;
If I setting the model path to INSTALLED_APPS and syncdb,the two models
will sync to the default database.
if I setting the database in syncdb command such as sync
--database="B",and the two models will sync to database B.
so my problem the how to sync the two models to two databases?
Upload a photo to a fan page of Facebook
Upload a photo to a fan page of Facebook
I am trying to upload a photo through my application with Facebook Graph
API to timeline of a Facebook's page. The problem is that it works only
when I publish the photo to my personal profile. The code I use is:
<?php
require 'includes/php-sdk/facebook.php';
define('APP_ID', '___________');
define('APP_SECRET', '___________');
define('REDIRECT_URI', '___________');
define('FAN_PAGE_ID', '___________');
define('SCOPE','publish_stream,user_photos,friends_photos, manage_pages');
$facebook = new Facebook(array(
'appId' => APP_ID,
'secret' => APP_SECRET,
'fileUpload' => true
));
//Get User ID
$user = $facebook->getUser();
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
// Login or logout url will be needed depending on current user state.
if ($user)
{
$logoutUrl = $facebook->getLogoutUrl($params = array('next' =>
REDIRECT_URI));
}
else
{
$loginUrl = $facebook->getLoginUrl($params = array('scope' => SCOPE));
if ($_SERVER['SCRIPT_NAME'] != 'index.php')
header('Location:' . $loginUrl);
}
try
{
//$facebook->setFileUploadSupport(true);
$response = $facebook->api(
'/'.FAN_PAGE_ID.'/photos/',
'post',
array(
'message' => 'test',
'source' => '@'.realpath('image.jpg')
));
}
catch (FacebookApiException $e)
{
echo 'Could not post image to Facebook.';
}
I am trying to upload a photo through my application with Facebook Graph
API to timeline of a Facebook's page. The problem is that it works only
when I publish the photo to my personal profile. The code I use is:
<?php
require 'includes/php-sdk/facebook.php';
define('APP_ID', '___________');
define('APP_SECRET', '___________');
define('REDIRECT_URI', '___________');
define('FAN_PAGE_ID', '___________');
define('SCOPE','publish_stream,user_photos,friends_photos, manage_pages');
$facebook = new Facebook(array(
'appId' => APP_ID,
'secret' => APP_SECRET,
'fileUpload' => true
));
//Get User ID
$user = $facebook->getUser();
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
// Login or logout url will be needed depending on current user state.
if ($user)
{
$logoutUrl = $facebook->getLogoutUrl($params = array('next' =>
REDIRECT_URI));
}
else
{
$loginUrl = $facebook->getLoginUrl($params = array('scope' => SCOPE));
if ($_SERVER['SCRIPT_NAME'] != 'index.php')
header('Location:' . $loginUrl);
}
try
{
//$facebook->setFileUploadSupport(true);
$response = $facebook->api(
'/'.FAN_PAGE_ID.'/photos/',
'post',
array(
'message' => 'test',
'source' => '@'.realpath('image.jpg')
));
}
catch (FacebookApiException $e)
{
echo 'Could not post image to Facebook.';
}
Friday, 30 August 2013
Edit a phone list pattern using regex
Edit a phone list pattern using regex
I have just started reading about regex today and I have a question if
what i am trying to do below is possible?
I have a file containing phone numbers some are in (xxx) xxx-xxxx format
but some are in xxx-xxxx format.
so eg telephonelist:
(855) 422-6932
(899) 991-9054
(855) 912-7326
(833) 390-8072
934-2368
731-7056
251-5372
(855) 137-6285
(855) 294-5537
(844) 680-7479
so the objective is to add (000) in all of the lines that is not in (xxx)
xxx-xxxx format.
What i have worked out so far is basically to grep the output and write
them into a new file matching a regex pattern, and do another grep output
but this time not matching the regex and append it to the same file; as
below.
grep "([0-9]\{3\}) [0-9]\{3\}-[0-9]\{4\}" testfile > newtestfile ; grep -v
"([0-9]\{3\}) [0-9]\{3\}-[0-9]\{4\}" testfile | sed 's/^/(000) /' >>
newtestfile
But this will actually change the order of the list, as the new file becomes
(855) 422-6932
(899) 991-9054
(855) 912-7326
(833) 390-8072
(855) 137-6285
(855) 294-5537
(844) 680-7479
(000) 934-2368
(000) 731-7056
(000) 251-5372
Is there any way to do this without changing the order? I have been
researching using sed, awk and nl, but nothing so far. I am a noob..
Thanks for your help.
I have just started reading about regex today and I have a question if
what i am trying to do below is possible?
I have a file containing phone numbers some are in (xxx) xxx-xxxx format
but some are in xxx-xxxx format.
so eg telephonelist:
(855) 422-6932
(899) 991-9054
(855) 912-7326
(833) 390-8072
934-2368
731-7056
251-5372
(855) 137-6285
(855) 294-5537
(844) 680-7479
so the objective is to add (000) in all of the lines that is not in (xxx)
xxx-xxxx format.
What i have worked out so far is basically to grep the output and write
them into a new file matching a regex pattern, and do another grep output
but this time not matching the regex and append it to the same file; as
below.
grep "([0-9]\{3\}) [0-9]\{3\}-[0-9]\{4\}" testfile > newtestfile ; grep -v
"([0-9]\{3\}) [0-9]\{3\}-[0-9]\{4\}" testfile | sed 's/^/(000) /' >>
newtestfile
But this will actually change the order of the list, as the new file becomes
(855) 422-6932
(899) 991-9054
(855) 912-7326
(833) 390-8072
(855) 137-6285
(855) 294-5537
(844) 680-7479
(000) 934-2368
(000) 731-7056
(000) 251-5372
Is there any way to do this without changing the order? I have been
researching using sed, awk and nl, but nothing so far. I am a noob..
Thanks for your help.
Thursday, 29 August 2013
new to gparted, want to know which partition has win7 and which one has linux
new to gparted, want to know which partition has win7 and which one has linux
How do I know Ubuntu and Windows7 are installed in different partitions? I
want to remove windows7 and keep Ubuntu13.04
How do I know Ubuntu and Windows7 are installed in different partitions? I
want to remove windows7 and keep Ubuntu13.04
New venue from within ios app?
New venue from within ios app?
If our user can't find the right venue in our app (location search powered
by foursquare) how can they create it? This is possible within Instagram
but we haven't found how to replicate it. Is it possible? We're developing
for iOS. Thankful for any helpful comments :)
If our user can't find the right venue in our app (location search powered
by foursquare) how can they create it? This is possible within Instagram
but we haven't found how to replicate it. Is it possible? We're developing
for iOS. Thankful for any helpful comments :)
Lifetime of eMMC device
Lifetime of eMMC device
I have better knowledge about the NAND and NOR memory devices as I'm
currently working with them. Now I have heard that eMMC device is going to
be used in one of my upcoming project. What is the assured lifetime(write
or erase cycles) of eMMC device compared to conventional NOR and NAND
flashes?
I have better knowledge about the NAND and NOR memory devices as I'm
currently working with them. Now I have heard that eMMC device is going to
be used in one of my upcoming project. What is the assured lifetime(write
or erase cycles) of eMMC device compared to conventional NOR and NAND
flashes?
Wednesday, 28 August 2013
Importing jQuery mobile app into eclipse
Importing jQuery mobile app into eclipse
hi¡¡¡ wish you can help me with this problem¡¡¡ thanks in advance.
I've made a project in a drag-and-drop builder for creating cross-platform
mobile apps and websites, and now, i want to make an app native, apk
extension, in order to take it into Android Market. After finish the
project, i receive a source code bundle for Eclipse (phonegap project).
The link to the phonegap project is this
http://www.mediafire.com/download/cp4s9dm9e8kx5s4/codiqa-android-404cab59-1377710877.zip
Everything works really fine in the project, but when i make the apk
archive.......... is not so fine.
Let me explain you, step by step what i am doing, maybe you can tell me if
something's wrong and how i can fix it.
Step 1: I export my project as phonegap project (android). I receive a
*zip, and i unzip it in my computer .
Step 2: I open Eclipse program and create a "android project from existing
code" (file>new>project>android project from existing code")
Step 3: I select the root directory where i've unzipped my codiqa project,
and click finish.
Step 4: I export the project as an Android aplication (right
button>export>export android application), follow the steps, and i get my
application. (In the Manifest, i change debuggable to false.)
Step 5: I install it in my phone, and now come the problems.
Problem 1: I can not open anything from my app. For example, when you
normally open a file o website in your phone, you can receive the standard
"what program do you wish to use", but not in my app.
Another example, i have a mediafire link in the app in order to download
an archive,.......... no matter how many times i press the download
button, never work, never download.
Hope you can tell what's wrong and how to fix it, THANKS¡¡¡
hi¡¡¡ wish you can help me with this problem¡¡¡ thanks in advance.
I've made a project in a drag-and-drop builder for creating cross-platform
mobile apps and websites, and now, i want to make an app native, apk
extension, in order to take it into Android Market. After finish the
project, i receive a source code bundle for Eclipse (phonegap project).
The link to the phonegap project is this
http://www.mediafire.com/download/cp4s9dm9e8kx5s4/codiqa-android-404cab59-1377710877.zip
Everything works really fine in the project, but when i make the apk
archive.......... is not so fine.
Let me explain you, step by step what i am doing, maybe you can tell me if
something's wrong and how i can fix it.
Step 1: I export my project as phonegap project (android). I receive a
*zip, and i unzip it in my computer .
Step 2: I open Eclipse program and create a "android project from existing
code" (file>new>project>android project from existing code")
Step 3: I select the root directory where i've unzipped my codiqa project,
and click finish.
Step 4: I export the project as an Android aplication (right
button>export>export android application), follow the steps, and i get my
application. (In the Manifest, i change debuggable to false.)
Step 5: I install it in my phone, and now come the problems.
Problem 1: I can not open anything from my app. For example, when you
normally open a file o website in your phone, you can receive the standard
"what program do you wish to use", but not in my app.
Another example, i have a mediafire link in the app in order to download
an archive,.......... no matter how many times i press the download
button, never work, never download.
Hope you can tell what's wrong and how to fix it, THANKS¡¡¡
Will value objects in a copy of a static ConcurrentHashMap reference the same value objects as the original?
Will value objects in a copy of a static ConcurrentHashMap reference the
same value objects as the original?
I have a two part question.
I have: private static ConcurrentHashMap<Integer, Servers> servers= null;
which I later populate. In method getAllServers, I'm doing this:
public static synchronized ConcurrentHashMap<Integer, Server>
getAllServers() {
ConcurrentHashMap<Integer, Server> toReturn = new ConcurrentHashMap<>();
for(Integer i = 0; i < servers.size(); i ++ ) {
Server s = servers.get(i);
if(s.isAlive()) {
s.incrementConns();
toReturn.put(i, s);
}
}
return toReturn;
}
Q: Will modifications to s be reflected in servers?
Q: Will toReturn reference the same Server objects as in servers? If so,
would any class that creates and modifies getAllServers's returned map be
modifiying the same objects as servers?
same value objects as the original?
I have a two part question.
I have: private static ConcurrentHashMap<Integer, Servers> servers= null;
which I later populate. In method getAllServers, I'm doing this:
public static synchronized ConcurrentHashMap<Integer, Server>
getAllServers() {
ConcurrentHashMap<Integer, Server> toReturn = new ConcurrentHashMap<>();
for(Integer i = 0; i < servers.size(); i ++ ) {
Server s = servers.get(i);
if(s.isAlive()) {
s.incrementConns();
toReturn.put(i, s);
}
}
return toReturn;
}
Q: Will modifications to s be reflected in servers?
Q: Will toReturn reference the same Server objects as in servers? If so,
would any class that creates and modifies getAllServers's returned map be
modifiying the same objects as servers?
Python3 : unescaping non ascii characters
Python3 : unescaping non ascii characters
(Python 3.3.2) I have to unescape some non ASCII escaped characters. I see
here and here methods that doesn't work. I'm working in a 100% UTF-8
environment.
# pure ASCII string : ok
mystring = "a\\n" # expected unescaped string : "a\n"
cod = codecs.getencoder('unicode_escape')
print( cod(mystring) )
# non ASCII string : method #1
mystring = "\\n"
# equivalent to : mystring = codecs.unicode_escape_decode(mystring)
cod = codecs.getdecoder('unicode_escape')
print(cod(mystring))
# RESULT = ('â\x82¬\n', 5) INSTEAD OF ("\n", 2)
# non ASCII string : method #2
mystring = "\\n"
mystring = bytes(mystring, 'utf-8').decode('unicode_escape')
print(mystring)
# RESULT = â\202¬ INSTEAD OF "\n"
Is this a bug ? Have I misunderstood something ?
Any help would be appreciated !
(Python 3.3.2) I have to unescape some non ASCII escaped characters. I see
here and here methods that doesn't work. I'm working in a 100% UTF-8
environment.
# pure ASCII string : ok
mystring = "a\\n" # expected unescaped string : "a\n"
cod = codecs.getencoder('unicode_escape')
print( cod(mystring) )
# non ASCII string : method #1
mystring = "\\n"
# equivalent to : mystring = codecs.unicode_escape_decode(mystring)
cod = codecs.getdecoder('unicode_escape')
print(cod(mystring))
# RESULT = ('â\x82¬\n', 5) INSTEAD OF ("\n", 2)
# non ASCII string : method #2
mystring = "\\n"
mystring = bytes(mystring, 'utf-8').decode('unicode_escape')
print(mystring)
# RESULT = â\202¬ INSTEAD OF "\n"
Is this a bug ? Have I misunderstood something ?
Any help would be appreciated !
Android : Problems with accents and ñ
Android : Problems with accents and ñ
I have the problem that somewhere when i save my textfield the accents
disapear and don't get saved to de bd.
Exemple :
entrance : " la meva ocupació és x " What the bd saves : "la meva ocupaci"
i think i may fail in some of these parts:
when i pick the data from the textfield:
title = (EditText)findViewById(R.id.title);
when i convert it to string :
String post_title = title.getText().toString();
when i put it on the list:
List params = new ArrayList(); params.add(new BasicNameValuePair("title",
post_title));
Full code : http://pastebin.com/trrPEG33
inb4: When i do an insert on the bd it takes accents with no problems
inb4: When i recive data from the bd this data contains the accents and
they are shown perfectly
i think the problem may be on the save .
i'll be really gratefull on any help. Sorry for my english.
I have the problem that somewhere when i save my textfield the accents
disapear and don't get saved to de bd.
Exemple :
entrance : " la meva ocupació és x " What the bd saves : "la meva ocupaci"
i think i may fail in some of these parts:
when i pick the data from the textfield:
title = (EditText)findViewById(R.id.title);
when i convert it to string :
String post_title = title.getText().toString();
when i put it on the list:
List params = new ArrayList(); params.add(new BasicNameValuePair("title",
post_title));
Full code : http://pastebin.com/trrPEG33
inb4: When i do an insert on the bd it takes accents with no problems
inb4: When i recive data from the bd this data contains the accents and
they are shown perfectly
i think the problem may be on the save .
i'll be really gratefull on any help. Sorry for my english.
Stream live ( real ) video from iPhone to server
Stream live ( real ) video from iPhone to server
Kindly ,
I am trying to create an app that start capturing the video from camera
Please give me examples to upload live video to a server
Kindly ,
I am trying to create an app that start capturing the video from camera
Please give me examples to upload live video to a server
Tuesday, 27 August 2013
Where is the FallbackRoute attribute defined in ServiceStack?
Where is the FallbackRoute attribute defined in ServiceStack?
Here is a potentially simple question that I can seem to find the answer to:
In which namespace is the fallback route attribute defined in
ServiceStack? The wiki shows the following example, but the ServiceHost
namespace (where the Route attribute is defined) does not have a
definition for a fallback.
[FallbackRoute("/{Path}")]
Here is a potentially simple question that I can seem to find the answer to:
In which namespace is the fallback route attribute defined in
ServiceStack? The wiki shows the following example, but the ServiceHost
namespace (where the Route attribute is defined) does not have a
definition for a fallback.
[FallbackRoute("/{Path}")]
How to append this SuperScrollorama tween timeline
How to append this SuperScrollorama tween timeline
I am trying to animate a gun with SuperScrollorama. The idea is that the
gun will fire as the user scrolls down. This involves some rather complex
tweening.
Here's what I have so far (*works best in Firefox):
https://googledrive.com/host/0B8V6b1tb9Ds5cDBYTlJpOWhsb1U/index.html
Now that I have the trigger being pulled and the hammer rotating backward,
I need to make the hammer snap to rotation: 0 after it's reached rotation:
-25. I just can't figure out how to append this timeline.
Here is my script:
<script>
$(document).ready(function() {
var controller = $.superscrollorama();
controller.addTween(
'#gun',
(new TimelineLite())
.append([
TweenMax.fromTo($('#hammer'), 1,
{css:{rotation: 0}, immediateRender:true},
{css:{rotation: -25}, ease:Quad.easeInOut}),
TweenMax.fromTo($('#trigger'), 1,
{css:{rotation: 0}, immediateRender:true},
{css:{rotation: 40}, ease:Quad.easeInOut})
]),
500, // scroll duration of tween
200); // offset?
});
</script>
I would appreciate any help that anyone could give me. I've read as much
as I can on the Superscrollorama site and looked at all sorts of code
snippets. Still can't figure it out.
I am trying to animate a gun with SuperScrollorama. The idea is that the
gun will fire as the user scrolls down. This involves some rather complex
tweening.
Here's what I have so far (*works best in Firefox):
https://googledrive.com/host/0B8V6b1tb9Ds5cDBYTlJpOWhsb1U/index.html
Now that I have the trigger being pulled and the hammer rotating backward,
I need to make the hammer snap to rotation: 0 after it's reached rotation:
-25. I just can't figure out how to append this timeline.
Here is my script:
<script>
$(document).ready(function() {
var controller = $.superscrollorama();
controller.addTween(
'#gun',
(new TimelineLite())
.append([
TweenMax.fromTo($('#hammer'), 1,
{css:{rotation: 0}, immediateRender:true},
{css:{rotation: -25}, ease:Quad.easeInOut}),
TweenMax.fromTo($('#trigger'), 1,
{css:{rotation: 0}, immediateRender:true},
{css:{rotation: 40}, ease:Quad.easeInOut})
]),
500, // scroll duration of tween
200); // offset?
});
</script>
I would appreciate any help that anyone could give me. I've read as much
as I can on the Superscrollorama site and looked at all sorts of code
snippets. Still can't figure it out.
Cascade Dropdown Javascript Errors (object doesn't support property)
Cascade Dropdown Javascript Errors (object doesn't support property)
So I'm trying to implement cascading dropdowns in MVC4 using Jquery. I've
been through countless examples and have yet to find a solution that
works. I am trying the solution that is listed on Cascading drop-downs in
MVC 3 Razor view
But I keep getting the Error: Microsoft JScript runtime error: Object
doesn't support property or method 'cascade'
Here's my code.
Javascript Function:
(function ($) {
$.fn.cascade = function (options) {
var defaults = {};
var opts = $.extend(defaults, options);
return this.each(function () {
$(this).change(function () {
var selectedValue = $(this).val();
var params = {};
params[opts.paramName] = selectedValue;
$.getJSON(opts.url, params, function (items) {
opts.childSelect.empty();
$.each(items, function (index, item) {
opts.childSelect.append(
$('<option/>')
.attr('value', item.Id)
.text(item.Name)
);
});
});
});
});
};
})(jQuery);
Then you're supposed to simply link it up on the View like:
<script type="text/javascript">
$(function () {
$('#ClientId').cascade({
url: '@Url.Action("ImportList")',
paramName: 'clientProjectName',
childSelect: $('#ImportId')
});
});
</script>
<div>
Client:
@Html.DropDownListFor(x => x.ClientId, new
SelectList(Model.ClientProjects, "ClientProjectName",
"ClientProjectName"))
</div>
<div>
Imports:
@Html.DropDownListFor(x => x.ImportId,
Enumerable.Empty<SelectListItem>())
</div>
I just want a quick, easy way to get Cascading Dropdowns working, but
everything I have tried seems to not work. I am pretty new to MVC4 and
javascript so any full explanations are greatly appreciated.
So I'm trying to implement cascading dropdowns in MVC4 using Jquery. I've
been through countless examples and have yet to find a solution that
works. I am trying the solution that is listed on Cascading drop-downs in
MVC 3 Razor view
But I keep getting the Error: Microsoft JScript runtime error: Object
doesn't support property or method 'cascade'
Here's my code.
Javascript Function:
(function ($) {
$.fn.cascade = function (options) {
var defaults = {};
var opts = $.extend(defaults, options);
return this.each(function () {
$(this).change(function () {
var selectedValue = $(this).val();
var params = {};
params[opts.paramName] = selectedValue;
$.getJSON(opts.url, params, function (items) {
opts.childSelect.empty();
$.each(items, function (index, item) {
opts.childSelect.append(
$('<option/>')
.attr('value', item.Id)
.text(item.Name)
);
});
});
});
});
};
})(jQuery);
Then you're supposed to simply link it up on the View like:
<script type="text/javascript">
$(function () {
$('#ClientId').cascade({
url: '@Url.Action("ImportList")',
paramName: 'clientProjectName',
childSelect: $('#ImportId')
});
});
</script>
<div>
Client:
@Html.DropDownListFor(x => x.ClientId, new
SelectList(Model.ClientProjects, "ClientProjectName",
"ClientProjectName"))
</div>
<div>
Imports:
@Html.DropDownListFor(x => x.ImportId,
Enumerable.Empty<SelectListItem>())
</div>
I just want a quick, easy way to get Cascading Dropdowns working, but
everything I have tried seems to not work. I am pretty new to MVC4 and
javascript so any full explanations are greatly appreciated.
Can I get the Page of the PDF Document where my Full Text Search Query finds a match?
Can I get the Page of the PDF Document where my Full Text Search Query
finds a match?
Im working with SQL Server 2008 R2. Im using Full Text Search to find some
text in a PDF Document stored as VarBinary(MAX). when I make a query, it
returns the row where the keyword matches somewhere in the PDF Document
stored.. How ever Im working with large pdf documents and I would like to
know if it is possible to get Page number in the document where the
keyword is found.. :)
finds a match?
Im working with SQL Server 2008 R2. Im using Full Text Search to find some
text in a PDF Document stored as VarBinary(MAX). when I make a query, it
returns the row where the keyword matches somewhere in the PDF Document
stored.. How ever Im working with large pdf documents and I would like to
know if it is possible to get Page number in the document where the
keyword is found.. :)
R: How to apply moving averages to subset of columns in a data frame?
R: How to apply moving averages to subset of columns in a data frame?
I have a dataframe (training.set) that is 150 observations of 83
variables. I want to transform 82 of those columns with some moving
averages. The problem is the results end up only being 150 numeric values
(i.e. 1 column).
How would I apply the moving average function across each column
individually in the data and keep the 83rd column unchanged? I feel like
this is super simple, but I can't find a solution.
My current code
# apply moving average on training.set data to 82 of 83 rows
library(TTR) #load TTR library for SMA functions
ts.sma <- SMA(training.set[,1:82], n = 10)
ts.sma
Thanks for your help.
I have a dataframe (training.set) that is 150 observations of 83
variables. I want to transform 82 of those columns with some moving
averages. The problem is the results end up only being 150 numeric values
(i.e. 1 column).
How would I apply the moving average function across each column
individually in the data and keep the 83rd column unchanged? I feel like
this is super simple, but I can't find a solution.
My current code
# apply moving average on training.set data to 82 of 83 rows
library(TTR) #load TTR library for SMA functions
ts.sma <- SMA(training.set[,1:82], n = 10)
ts.sma
Thanks for your help.
how to make gmail notifier app in iPhone?
how to make gmail notifier app in iPhone?
I am new in iphone. i want to create a app that can login with gmail or
yahoo username and notify me when new mail is available.Can anyone help me
with this application.i want full tutorial help.Thanks.
I am new in iphone. i want to create a app that can login with gmail or
yahoo username and notify me when new mail is available.Can anyone help me
with this application.i want full tutorial help.Thanks.
PHP Iterator classes
PHP Iterator classes
I'm trying to figure out what's the actual benefit of using Iterator
classes in Object Oriented PHP over the standard array.
I'm planning to upgrade my framework by converting all arrays to object,
but I just don't understand the actual need apart from having the system
being fully OOP.
I know that by the use of IteratorAggregate I can create:
class MyModel implements IteratorAggregate {
public $records = array();
public function __construct(array $records) {
$this->records = $records;
}
public function getIterator() {
return new ArrayIterator($this->records);
}
}
and then simply loop through it like using the array:
$mdlMy = new MyModel();
foreach($mdlMy as $row) {
echo $row['first_name'];
echo $row['last_name'];
}
Could someone in simple terms explain the actual purpose of these -
perhaps with some use case.
I'm trying to figure out what's the actual benefit of using Iterator
classes in Object Oriented PHP over the standard array.
I'm planning to upgrade my framework by converting all arrays to object,
but I just don't understand the actual need apart from having the system
being fully OOP.
I know that by the use of IteratorAggregate I can create:
class MyModel implements IteratorAggregate {
public $records = array();
public function __construct(array $records) {
$this->records = $records;
}
public function getIterator() {
return new ArrayIterator($this->records);
}
}
and then simply loop through it like using the array:
$mdlMy = new MyModel();
foreach($mdlMy as $row) {
echo $row['first_name'];
echo $row['last_name'];
}
Could someone in simple terms explain the actual purpose of these -
perhaps with some use case.
Receive multiple intents on an activity
Receive multiple intents on an activity
I have to send data from two different activities via intents to the same
activity. From activity1, the intent is passing data to EnquireActivity,
and from activity2 also, the intent is being passed to EnquireActivity.
How to receive these intents in the EnquireActivity. Any help would be
appreciated.
Activity 1:
Intent i1 = new Intent(this, EnquireActivity.class);
i1.putExtra("name",et_name.getText().toString());
i1.putExtra("adults",et_adult.getText().toString());
i1.putExtra("child",et_child.getText().toString());
i1.putExtra("email",et_email.getText().toString());
i1.putExtra("phone",et_phone.getText().toString());
i1.putExtra("datedept",date1);
i1.putExtra("datearr",date2);
i1.putStringArrayListExtra("list1", getChecked);
startActivity(i1);
Activity 2:
Intent intent = new Intent(this, EnquireActivity.class);
intent.putExtra("name", name);
intent.putExtra("night", n);
intent.putExtra("day", d);
intent.putExtra("dest", dest);
startActivity(intent);
I have to send data from two different activities via intents to the same
activity. From activity1, the intent is passing data to EnquireActivity,
and from activity2 also, the intent is being passed to EnquireActivity.
How to receive these intents in the EnquireActivity. Any help would be
appreciated.
Activity 1:
Intent i1 = new Intent(this, EnquireActivity.class);
i1.putExtra("name",et_name.getText().toString());
i1.putExtra("adults",et_adult.getText().toString());
i1.putExtra("child",et_child.getText().toString());
i1.putExtra("email",et_email.getText().toString());
i1.putExtra("phone",et_phone.getText().toString());
i1.putExtra("datedept",date1);
i1.putExtra("datearr",date2);
i1.putStringArrayListExtra("list1", getChecked);
startActivity(i1);
Activity 2:
Intent intent = new Intent(this, EnquireActivity.class);
intent.putExtra("name", name);
intent.putExtra("night", n);
intent.putExtra("day", d);
intent.putExtra("dest", dest);
startActivity(intent);
Monday, 26 August 2013
Emulate SD Card as internal hard disk
Emulate SD Card as internal hard disk
I'm currently using my SD card (32Gb) as a secondary memory storage
because my Windows 8 (not RT) tablet has too little space (50+Gb) by
default. I expect to leave the SD card plugged in all the time.
I'd like to be able to install some applications onto my SD Card, but
often applications only allow installing onto internal hdds, so I'm
wondering if there's a way to let my computer see my SD card as a hard
disk as well?
What would be the pros and cons of this decision, if it is possible?
I'm currently using my SD card (32Gb) as a secondary memory storage
because my Windows 8 (not RT) tablet has too little space (50+Gb) by
default. I expect to leave the SD card plugged in all the time.
I'd like to be able to install some applications onto my SD Card, but
often applications only allow installing onto internal hdds, so I'm
wondering if there's a way to let my computer see my SD card as a hard
disk as well?
What would be the pros and cons of this decision, if it is possible?
JS Cookie Plugin + If Statement Not Working
JS Cookie Plugin + If Statement Not Working
I'm trying to use the JS Cookie Plugin to read the value of a cookie and
include a notification bar (Hello Bar) if the value is not 1.
Here's my code:
<!-- HelloBar code start -->
<script type="text/javascript" src="//www.hellobar.com/hellobar.js"></script>
<script type="text/javascript">
if($.cookie('returning_user') !== '1') {
new HelloBar(12345,12345);
}
</script>
<!-- HelloBar code end -->
Is !== the right operator?
Am I testing the right thing (that it's not equal to 1)?
By putting 1 in quotes, am I testing for a string when I really want an
integer?
I'm trying to use the JS Cookie Plugin to read the value of a cookie and
include a notification bar (Hello Bar) if the value is not 1.
Here's my code:
<!-- HelloBar code start -->
<script type="text/javascript" src="//www.hellobar.com/hellobar.js"></script>
<script type="text/javascript">
if($.cookie('returning_user') !== '1') {
new HelloBar(12345,12345);
}
</script>
<!-- HelloBar code end -->
Is !== the right operator?
Am I testing the right thing (that it's not equal to 1)?
By putting 1 in quotes, am I testing for a string when I really want an
integer?
Including the day of the week in a MySQL table
Including the day of the week in a MySQL table
How would I go about changing the way a 'sign up' date is displayed in a
MySQL table? I wanted the date to be formatted in this way: Monday, August
26 2013 6:04PM instead of the usual, standard format based on a 24 hour
clock.
Currently I have
$value = mysql_real_escape_string($_POST['First']);
$value2 = mysql_real_escape_string($_POST['Last']);
$value3 = mysql_real_escape_string($_POST['City']);
$value4 = mysql_real_escape_string($_POST['State']);
$value5 = mysql_real_escape_string($_POST['Country']);
$value6 = mysql_real_escape_string($_POST['Email']);
$sql = "INSERT INTO members (First, Last, City, State, Country, Email,
Date)
VALUES('$value','$value2','$value3','$value4','$value5','$value6',NOW())";
How would I go about changing the way a 'sign up' date is displayed in a
MySQL table? I wanted the date to be formatted in this way: Monday, August
26 2013 6:04PM instead of the usual, standard format based on a 24 hour
clock.
Currently I have
$value = mysql_real_escape_string($_POST['First']);
$value2 = mysql_real_escape_string($_POST['Last']);
$value3 = mysql_real_escape_string($_POST['City']);
$value4 = mysql_real_escape_string($_POST['State']);
$value5 = mysql_real_escape_string($_POST['Country']);
$value6 = mysql_real_escape_string($_POST['Email']);
$sql = "INSERT INTO members (First, Last, City, State, Country, Email,
Date)
VALUES('$value','$value2','$value3','$value4','$value5','$value6',NOW())";
add a jQuery selector to the URL parameter
add a jQuery selector to the URL parameter
Is it possible to add a jQuery selector to the URL parameter after an
AJAX-request? This is my perfectly working code:
$.ajax({
type : "POST",
url : "load_page.php",
data : 'page=' + url,
success : function(msg) {
if (parseInt(msg) != 0)//if no errors
{
$content.fadeIn(200, function() {
$('#content').html(msg);
});
}
}
});
//load the returned html into pageContent
I know that via .load() (or link) it is possible:
$("# content'").load("demo_test.txt #sub.content");
But is it possible via $('#content').html(msg);?
Additional info: I am trying to only get the <div id="sub-content">
Is it possible to add a jQuery selector to the URL parameter after an
AJAX-request? This is my perfectly working code:
$.ajax({
type : "POST",
url : "load_page.php",
data : 'page=' + url,
success : function(msg) {
if (parseInt(msg) != 0)//if no errors
{
$content.fadeIn(200, function() {
$('#content').html(msg);
});
}
}
});
//load the returned html into pageContent
I know that via .load() (or link) it is possible:
$("# content'").load("demo_test.txt #sub.content");
But is it possible via $('#content').html(msg);?
Additional info: I am trying to only get the <div id="sub-content">
Tomcat does not connect to the database, but when I run it from within netbeans works perfectly
Tomcat does not connect to the database, but when I run it from within
netbeans works perfectly
I'm using Java + BlazeDS + MySQL + Flash Builder + EclipseLink (JPA 2.1) +
Tomcat 7 (Windows)
The problem is this, when I compile my application within Netbeans the
connection to the database works perfectly. But when I do a deploy
directly in tomcat with war file it does not access the database.
I tried with multiple versions of tomcat, including tomcat netbeans and it
did not work. Only works when I run the project from within Netbeans
I'm almost mad trying to solve it, someone has gone through this problem?
I really appreciate any help
netbeans works perfectly
I'm using Java + BlazeDS + MySQL + Flash Builder + EclipseLink (JPA 2.1) +
Tomcat 7 (Windows)
The problem is this, when I compile my application within Netbeans the
connection to the database works perfectly. But when I do a deploy
directly in tomcat with war file it does not access the database.
I tried with multiple versions of tomcat, including tomcat netbeans and it
did not work. Only works when I run the project from within Netbeans
I'm almost mad trying to solve it, someone has gone through this problem?
I really appreciate any help
how to setup AWS/mongodb with replicas so that if an instance crashes there is nothing to do?
how to setup AWS/mongodb with replicas so that if an instance crashes
there is nothing to do?
The question is pretty much all in the title : how to setup AWS/mongodb
with replicas so that if an instance crashes there is nothing to do ?
Namely, if one of the instances of the replica crashes, I guess that
Amazon instantiates a new machine for us and starts up the processes that
were running. With EBS things should be fine.
Only problem : when restarting this, how can we add back the new machine
to the replica set ? Instances have changing ips and Im not sure how how
start up the machine will know what replica set to join, what will be its
ip, and how to tell to join it.
If you have encountered this problem please let me know !
Thanks
Thomas
there is nothing to do?
The question is pretty much all in the title : how to setup AWS/mongodb
with replicas so that if an instance crashes there is nothing to do ?
Namely, if one of the instances of the replica crashes, I guess that
Amazon instantiates a new machine for us and starts up the processes that
were running. With EBS things should be fine.
Only problem : when restarting this, how can we add back the new machine
to the replica set ? Instances have changing ips and Im not sure how how
start up the machine will know what replica set to join, what will be its
ip, and how to tell to join it.
If you have encountered this problem please let me know !
Thanks
Thomas
Access Rest Webservice behind NAT
Access Rest Webservice behind NAT
In my network i have a network device (c++) which provides a simple REST
webservice. I want the webservice be accessible from outside the networ,
e.g. the internet. A PC in the internet which is not behind a NAT should
be able to call the webservice on the device. So communicating with the PC
in the internet is easy because I know the IP and Port of the PC. The
other side is not easy, because the network device is behind NAT.
How can i easily solve this? Since the communication should be
instantiated from the network device, i would first make make a call the
the PC and somehow keep the connection open, so that the PC can make calls
to the Network Device.....?!?!
What would you suggest?
kind regards
In my network i have a network device (c++) which provides a simple REST
webservice. I want the webservice be accessible from outside the networ,
e.g. the internet. A PC in the internet which is not behind a NAT should
be able to call the webservice on the device. So communicating with the PC
in the internet is easy because I know the IP and Port of the PC. The
other side is not easy, because the network device is behind NAT.
How can i easily solve this? Since the communication should be
instantiated from the network device, i would first make make a call the
the PC and somehow keep the connection open, so that the PC can make calls
to the Network Device.....?!?!
What would you suggest?
kind regards
Increase badness based on distance between float and reference
Increase badness based on distance between float and reference
One thing I really often struggle with when writing a latex document (and
I belive a lot of people are in the same case) is float placement.
In particular, I often find myself with a figure or table located several
pages away from the place where ther were referenced.
As I understand it, the way latex choses where to put a float is by trying
to minimize the "badness", which is a numeric value used to characterize
how bad a certain placement would be.
And in this regard, I think we can agree that placing a figure several
pages away from the place where it is needed is pretty bad.
Therefore, is there a way to increase the badness of this when I need to
do so ?
To be more specific, I see two possible kinds of badness :
the vertical distance between the paragraph where it is referenced and the
float
The presence of page breaks between these two.
Alternatively, how could it be implemented, or even, would this be the
right way to approach this problem ?
One thing I really often struggle with when writing a latex document (and
I belive a lot of people are in the same case) is float placement.
In particular, I often find myself with a figure or table located several
pages away from the place where ther were referenced.
As I understand it, the way latex choses where to put a float is by trying
to minimize the "badness", which is a numeric value used to characterize
how bad a certain placement would be.
And in this regard, I think we can agree that placing a figure several
pages away from the place where it is needed is pretty bad.
Therefore, is there a way to increase the badness of this when I need to
do so ?
To be more specific, I see two possible kinds of badness :
the vertical distance between the paragraph where it is referenced and the
float
The presence of page breaks between these two.
Alternatively, how could it be implemented, or even, would this be the
right way to approach this problem ?
Count distinct same names
Count distinct same names
I have table where have over 100k information.
ID FirstName
1 Bob
2 Bob
3 Tom
4 John
5 John
6 John
.. ....
Want procedure which will be count how much names are same, For example it
must be like :
FirstName Count
Bob 2
Tom 1
John 3
Please help me to write it
I have table where have over 100k information.
ID FirstName
1 Bob
2 Bob
3 Tom
4 John
5 John
6 John
.. ....
Want procedure which will be count how much names are same, For example it
must be like :
FirstName Count
Bob 2
Tom 1
John 3
Please help me to write it
Sunday, 25 August 2013
Optimize query selecting based on several date ranges
Optimize query selecting based on several date ranges
It seems like there should be a way to make this more efficient. The
difficulty is the arbitrary date ranges and number of said ranges.
In this query I am attempting to retrieve rows from the tasks table where
the date (regardless of time) is 2013-01-01, 2013-01-03, 2013-01-09 or
2013-02-01
tasks
|id | int |
|begin_date| datetime |
SELECT * FROM tasks
WHERE (tasks.begin_date >= '2013-01-01' AND tasks.begin_date < '2013-01-01')
OR (tasks.begin_date >= '2013-01-03' AND tasks.begin_date < '2013-01-04')
OR (tasks.begin_date >= '2013-01-09' AND tasks.begin_date < '2013-01-10')
OR (tasks.begin_date >= '2013-02-01' AND tasks.begin_date < '2013-02-02')
Is there a "proper" way to do this? or a significantly more efficient way?
I'm using SQL Server 2008.
It seems like there should be a way to make this more efficient. The
difficulty is the arbitrary date ranges and number of said ranges.
In this query I am attempting to retrieve rows from the tasks table where
the date (regardless of time) is 2013-01-01, 2013-01-03, 2013-01-09 or
2013-02-01
tasks
|id | int |
|begin_date| datetime |
SELECT * FROM tasks
WHERE (tasks.begin_date >= '2013-01-01' AND tasks.begin_date < '2013-01-01')
OR (tasks.begin_date >= '2013-01-03' AND tasks.begin_date < '2013-01-04')
OR (tasks.begin_date >= '2013-01-09' AND tasks.begin_date < '2013-01-10')
OR (tasks.begin_date >= '2013-02-01' AND tasks.begin_date < '2013-02-02')
Is there a "proper" way to do this? or a significantly more efficient way?
I'm using SQL Server 2008.
Android Tutorial issue
Android Tutorial issue
I am new to android, Eclipse and Java.
I started these tutorials from here:
http://developer.android.com/training/basics/firstapp/index.html
I did all the steps from the link above...my problem is when I run this
app and press the 'Send' button...nothing happens, there are no errors in
my Console or LogCat.
Here is my code I ended up with:
activity_main.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<EditText android:id="@+id/edit_message"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="@string/edit_message" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_send"
android:onClick="sendMessage" />
</LinearLayout>
strings.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">MyFirstApp</string>
<string name="action_settings">Settings</string>
<string name="edit_message">Enter a message</string>
<string name="button_send">Send</string>
<string name="title_activity_main">MainActivity</string>
<string name="title_activity_display_message">My Message</string>
<string name="hello_world">Hello world!</string>
</resources>
MainActivity.java:
package com.example.myfirstapp;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
public class MainActivity extends Activity {
public final static String EXTRA_MESSAGE =
"com.example.myfirstapp.MESSAGE";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is
present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public void sendMessage(View view) {
Intent intent = new Intent(this, DisplayMessageActivity.class);
EditText editText = (EditText) findViewById(R.id.edit_message);
String message = editText.getText().toString();
intent.putExtra(EXTRA_MESSAGE, message);
}
}
DisplayMessageActivity.java:
package com.example.myfirstapp;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.NavUtils;
import android.view.MenuItem;
import android.widget.TextView;
public class DisplayMessageActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Get the message from the intent
Intent intent = getIntent();
String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
// Create the text view
TextView textView = new TextView(this);
textView.setTextSize(40);
textView.setText(message);
// Set the text view as the activity layout
setContentView(textView);
// Show the Up button in the action bar.
setupActionBar();
}
/**
* Set up the {@link android.app.ActionBar}, if the API is available.
*/
@SuppressLint("NewApi")
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void setupActionBar() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
getActionBar().setDisplayHomeAsUpEnabled(true);
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
// This ID represents the Home or Up button. In the case of this
// activity, the Up button is shown. Use NavUtils to allow users
// to navigate up one level in the application structure. For
// more details, see the Navigation pattern on Android Design:
//
//
http://developer.android.com/design/patterns/navigation.html#up-vs-back
//
NavUtils.navigateUpFromSameTask(this);
return true;
}
return super.onOptionsItemSelected(item);
}
}
and activity_display_message.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".DisplayMessageActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
</RelativeLayout>
Has anyone else ran into the same issue as me? Any help would be appreciated.
Thanks in advanced, J
I am new to android, Eclipse and Java.
I started these tutorials from here:
http://developer.android.com/training/basics/firstapp/index.html
I did all the steps from the link above...my problem is when I run this
app and press the 'Send' button...nothing happens, there are no errors in
my Console or LogCat.
Here is my code I ended up with:
activity_main.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<EditText android:id="@+id/edit_message"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="@string/edit_message" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_send"
android:onClick="sendMessage" />
</LinearLayout>
strings.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">MyFirstApp</string>
<string name="action_settings">Settings</string>
<string name="edit_message">Enter a message</string>
<string name="button_send">Send</string>
<string name="title_activity_main">MainActivity</string>
<string name="title_activity_display_message">My Message</string>
<string name="hello_world">Hello world!</string>
</resources>
MainActivity.java:
package com.example.myfirstapp;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
public class MainActivity extends Activity {
public final static String EXTRA_MESSAGE =
"com.example.myfirstapp.MESSAGE";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is
present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public void sendMessage(View view) {
Intent intent = new Intent(this, DisplayMessageActivity.class);
EditText editText = (EditText) findViewById(R.id.edit_message);
String message = editText.getText().toString();
intent.putExtra(EXTRA_MESSAGE, message);
}
}
DisplayMessageActivity.java:
package com.example.myfirstapp;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.NavUtils;
import android.view.MenuItem;
import android.widget.TextView;
public class DisplayMessageActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Get the message from the intent
Intent intent = getIntent();
String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
// Create the text view
TextView textView = new TextView(this);
textView.setTextSize(40);
textView.setText(message);
// Set the text view as the activity layout
setContentView(textView);
// Show the Up button in the action bar.
setupActionBar();
}
/**
* Set up the {@link android.app.ActionBar}, if the API is available.
*/
@SuppressLint("NewApi")
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void setupActionBar() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
getActionBar().setDisplayHomeAsUpEnabled(true);
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
// This ID represents the Home or Up button. In the case of this
// activity, the Up button is shown. Use NavUtils to allow users
// to navigate up one level in the application structure. For
// more details, see the Navigation pattern on Android Design:
//
//
http://developer.android.com/design/patterns/navigation.html#up-vs-back
//
NavUtils.navigateUpFromSameTask(this);
return true;
}
return super.onOptionsItemSelected(item);
}
}
and activity_display_message.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".DisplayMessageActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
</RelativeLayout>
Has anyone else ran into the same issue as me? Any help would be appreciated.
Thanks in advanced, J
Python permutations including substrings
Python permutations including substrings
I've come across this post: How to generate all permutations of a list in
Python
but i require something more, i require all the permutations of a string
as well as all the permutations of all the substrings of that string. I
know its a big number, but is it possible?
I've come across this post: How to generate all permutations of a list in
Python
but i require something more, i require all the permutations of a string
as well as all the permutations of all the substrings of that string. I
know its a big number, but is it possible?
The unicity of $P$ and $g$ in the factorization of the function $f$
The unicity of $P$ and $g$ in the factorization of the function $f$
The motivation to this question can be found in: Examples of real analytic
functions with finite number of zeros that are not polynomials
My quetion is concerned with the unicity of $P$ and $g$ in the
factorization of the function $f$.
The motivation to this question can be found in: Examples of real analytic
functions with finite number of zeros that are not polynomials
My quetion is concerned with the unicity of $P$ and $g$ in the
factorization of the function $f$.
"Linking Error: Duplicate public_main in module" while building
"Linking Error: Duplicate public_main in module" while building
I Have created a a simple file under one Work area, build it and executed
successfully. And again created another file under same work area. I am
getting linking error like:
"====Linking===== Error: Duplicate public_main in module...." while
building and I am getting the same error when I try to execute first file
also.
Please show me the solution.
I Have created a a simple file under one Work area, build it and executed
successfully. And again created another file under same work area. I am
getting linking error like:
"====Linking===== Error: Duplicate public_main in module...." while
building and I am getting the same error when I try to execute first file
also.
Please show me the solution.
Saturday, 24 August 2013
How Mega downloads a file?
How Mega downloads a file?
when you download a file from MEGA service, a web page to display a
download progress bar will appear. After the bar reaches 100%, your
browser will notify users to save the file into a selected folder. I know
that Mega use HTML5 FileSystem API to do this (Download files like
mega.co.nz ). However, i don't know when the file is completely downloaded
into the sandboxed directory, how the browser's instructed to notify users
about the download? Would you please answer my question? Thanks in
advance.
when you download a file from MEGA service, a web page to display a
download progress bar will appear. After the bar reaches 100%, your
browser will notify users to save the file into a selected folder. I know
that Mega use HTML5 FileSystem API to do this (Download files like
mega.co.nz ). However, i don't know when the file is completely downloaded
into the sandboxed directory, how the browser's instructed to notify users
about the download? Would you please answer my question? Thanks in
advance.
Python showed that there is no attribute for one object
Python showed that there is no attribute for one object
I learned the book "programming python' these days. When I run the
examples, I met the problem. The shell showed me the error:
AttributeError: 'NoneType' object has no attribute 'pack'
However, I copy the exactly code from the book. I'm a freshman of Python.
I try to fix it by myself, but I failed. So I hope anyone could kindly
help me.
Thanks !!!!!!
CODEF
#File test.py
from tkinter import *
from tkinter.messagebox import showinfo
def MyGui(Frame):
def __init__(self, parent = None):
Frame.__init__(self, parent)
button = Button(self, text='press', command=reply)
button.pack()
def reply(self):
showinfo(title = 'popup',message ='Button pressed!')
if __name__ == '__main__':
window = MyGui()
window.pack()
window.mainloop()
#File test2.py
from tkinter import *
from test import MyGui
mainwin = Tk()
Label(mainwin,text = __name__).pack()
popup = Toplevel()
Label(popup,text = 'Attach').pack(side = LEFT)
MyGui(popup).pack(side=RIGHT)
mainwin.mainloop()
I learned the book "programming python' these days. When I run the
examples, I met the problem. The shell showed me the error:
AttributeError: 'NoneType' object has no attribute 'pack'
However, I copy the exactly code from the book. I'm a freshman of Python.
I try to fix it by myself, but I failed. So I hope anyone could kindly
help me.
Thanks !!!!!!
CODEF
#File test.py
from tkinter import *
from tkinter.messagebox import showinfo
def MyGui(Frame):
def __init__(self, parent = None):
Frame.__init__(self, parent)
button = Button(self, text='press', command=reply)
button.pack()
def reply(self):
showinfo(title = 'popup',message ='Button pressed!')
if __name__ == '__main__':
window = MyGui()
window.pack()
window.mainloop()
#File test2.py
from tkinter import *
from test import MyGui
mainwin = Tk()
Label(mainwin,text = __name__).pack()
popup = Toplevel()
Label(popup,text = 'Attach').pack(side = LEFT)
MyGui(popup).pack(side=RIGHT)
mainwin.mainloop()
Is spinlock required for every interrupt handler?
Is spinlock required for every interrupt handler?
In Chapter 5 of ULK the author states as follows:
"...each interrupt handler is serialized with respect to itself-that is,
it cannot execute more than one concurrently. Thus, accessing the data
struct does not require synchronization primitives"
I don't quite understand why interrupt handlers is "serialized" on modern
CPUs with multiple cores. I'm thinking it could be possible that a same
ISR can be run on different cores simultaneously, right? If that's the
case, if you don't use spinlock to protect your data it can come to a race
condition.
So my question is, on a modern system with multi-cpus, for every interrupt
handler you are going to write that will read & write some data, is
spinlock always needed?
In Chapter 5 of ULK the author states as follows:
"...each interrupt handler is serialized with respect to itself-that is,
it cannot execute more than one concurrently. Thus, accessing the data
struct does not require synchronization primitives"
I don't quite understand why interrupt handlers is "serialized" on modern
CPUs with multiple cores. I'm thinking it could be possible that a same
ISR can be run on different cores simultaneously, right? If that's the
case, if you don't use spinlock to protect your data it can come to a race
condition.
So my question is, on a modern system with multi-cpus, for every interrupt
handler you are going to write that will read & write some data, is
spinlock always needed?
Symbolicate crash log with Quincy Kit, give me this error
Symbolicate crash log with Quincy Kit, give me this error
i'm trying to symbolicate a crash log using the Quincy Kit, all works
fine, but i receive this warning/error in the terminal during the
symbolcating:
/Applications/Xcode5-DP5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool:
file: /Users/Piero/Library/Developer/Xcode/iOS DeviceSupport/6.1.3
(10B329)/Symbols/System/Library/Frameworks/Foundation.framework/Foundation
does not contain architecture: armv7
Can't understand the output from otool ( -> xcrun -sdk iphoneos otool
-arch armv7 -l '/Users/Piero/Library/Developer/Xcode/iOS
DeviceSupport/6.1.3
(10B329)/Symbols/System/Library/Frameworks/Foundation.framework/Foundation')
/Applications/Xcode5-DP5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool:
file: /Users/Piero/Library/Developer/Xcode/iOS DeviceSupport/6.1.3
(10B329)/Symbols/System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices
does not contain architecture: armv7
Can't understand the output from otool ( -> xcrun -sdk iphoneos otool
-arch armv7 -l '/Users/Piero/Library/Developer/Xcode/iOS
DeviceSupport/6.1.3
(10B329)/Symbols/System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices')
/Applications/Xcode5-DP5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool:
file: /Users/Piero/Library/Developer/Xcode/iOS DeviceSupport/6.1.3
(10B329)/Symbols/System/Library/Frameworks/UIKit.framework/UIKit does not
contain architecture: armv7
Can't understand the output from otool ( -> xcrun -sdk iphoneos otool
-arch armv7 -l '/Users/Piero/Library/Developer/Xcode/iOS
DeviceSupport/6.1.3
(10B329)/Symbols/System/Library/Frameworks/UIKit.framework/UIKit')
/Applications/Xcode5-DP5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool:
file: /Users/Piero/Library/Developer/Xcode/iOS DeviceSupport/6.1.3
(10B329)/Symbols/System/Library/PrivateFrameworks/JavaScriptCore.framework/JavaScriptCore
does not contain architecture: armv7
Can't understand the output from otool ( -> xcrun -sdk iphoneos otool
-arch armv7 -l '/Users/Piero/Library/Developer/Xcode/iOS
DeviceSupport/6.1.3
(10B329)/Symbols/System/Library/PrivateFrameworks/JavaScriptCore.framework/JavaScriptCore')
/Applications/Xcode5-DP5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool:
file: /Users/Piero/Library/Developer/Xcode/iOS DeviceSupport/6.1.3
(10B329)/Symbols/System/Library/PrivateFrameworks/WebCore.framework/WebCore
does not contain architecture: armv7
Can't understand the output from otool ( -> xcrun -sdk iphoneos otool
-arch armv7 -l '/Users/Piero/Library/Developer/Xcode/iOS
DeviceSupport/6.1.3
(10B329)/Symbols/System/Library/PrivateFrameworks/WebCore.framework/WebCore')
/Applications/Xcode5-DP5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool:
file: /Users/Piero/Library/Developer/Xcode/iOS DeviceSupport/6.1.3
(10B329)/Symbols/usr/lib/libc++abi.dylib does not contain architecture:
armv7
Can't understand the output from otool ( -> xcrun -sdk iphoneos otool
-arch armv7 -l '/Users/Piero/Library/Developer/Xcode/iOS
DeviceSupport/6.1.3 (10B329)/Symbols/usr/lib/libc++abi.dylib')
/Applications/Xcode5-DP5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool:
file: /Users/Piero/Library/Developer/Xcode/iOS DeviceSupport/6.1.3
(10B329)/Symbols/usr/lib/libobjc.A.dylib does not contain architecture:
armv7
Can't understand the output from otool ( -> xcrun -sdk iphoneos otool
-arch armv7 -l '/Users/Piero/Library/Developer/Xcode/iOS
DeviceSupport/6.1.3 (10B329)/Symbols/usr/lib/libobjc.A.dylib')
/Applications/Xcode5-DP5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool:
file: /Users/Piero/Library/Developer/Xcode/iOS DeviceSupport/6.1.3
(10B329)/Symbols/usr/lib/system/libdispatch.dylib does not contain
architecture: armv7
Can't understand the output from otool ( -> xcrun -sdk iphoneos otool
-arch armv7 -l '/Users/Piero/Library/Developer/Xcode/iOS
DeviceSupport/6.1.3 (10B329)/Symbols/usr/lib/system/libdispatch.dylib')
/Applications/Xcode5-DP5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool:
file: /Users/Piero/Library/Developer/Xcode/iOS DeviceSupport/6.1.3
(10B329)/Symbols/usr/lib/system/libsystem_c.dylib does not contain
architecture: armv7
Can't understand the output from otool ( -> xcrun -sdk iphoneos otool
-arch armv7 -l '/Users/Piero/Library/Developer/Xcode/iOS
DeviceSupport/6.1.3 (10B329)/Symbols/usr/lib/system/libsystem_c.dylib')
/Applications/Xcode5-DP5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool:
file: /Users/Piero/Library/Developer/Xcode/iOS DeviceSupport/6.1.3
(10B329)/Symbols/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
does not contain architecture: armv7
Can't understand the output from otool ( -> xcrun -sdk iphoneos otool
-arch armv7 -l '/Users/Piero/Library/Developer/Xcode/iOS
DeviceSupport/6.1.3
(10B329)/Symbols/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation')
/Applications/Xcode5-DP5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool:
file: /Users/Piero/Library/Developer/Xcode/iOS DeviceSupport/6.1.3
(10B329)/Symbols/usr/lib/system/libsystem_kernel.dylib does not contain
architecture: armv7
Can't understand the output from otool ( -> xcrun -sdk iphoneos otool
-arch armv7 -l '/Users/Piero/Library/Developer/Xcode/iOS
DeviceSupport/6.1.3
(10B329)/Symbols/usr/lib/system/libsystem_kernel.dylib')
Sending symbolicated data back to the server ...
Deleting temporary files ...
Done
there is way to fix it?
i'm trying to symbolicate a crash log using the Quincy Kit, all works
fine, but i receive this warning/error in the terminal during the
symbolcating:
/Applications/Xcode5-DP5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool:
file: /Users/Piero/Library/Developer/Xcode/iOS DeviceSupport/6.1.3
(10B329)/Symbols/System/Library/Frameworks/Foundation.framework/Foundation
does not contain architecture: armv7
Can't understand the output from otool ( -> xcrun -sdk iphoneos otool
-arch armv7 -l '/Users/Piero/Library/Developer/Xcode/iOS
DeviceSupport/6.1.3
(10B329)/Symbols/System/Library/Frameworks/Foundation.framework/Foundation')
/Applications/Xcode5-DP5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool:
file: /Users/Piero/Library/Developer/Xcode/iOS DeviceSupport/6.1.3
(10B329)/Symbols/System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices
does not contain architecture: armv7
Can't understand the output from otool ( -> xcrun -sdk iphoneos otool
-arch armv7 -l '/Users/Piero/Library/Developer/Xcode/iOS
DeviceSupport/6.1.3
(10B329)/Symbols/System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices')
/Applications/Xcode5-DP5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool:
file: /Users/Piero/Library/Developer/Xcode/iOS DeviceSupport/6.1.3
(10B329)/Symbols/System/Library/Frameworks/UIKit.framework/UIKit does not
contain architecture: armv7
Can't understand the output from otool ( -> xcrun -sdk iphoneos otool
-arch armv7 -l '/Users/Piero/Library/Developer/Xcode/iOS
DeviceSupport/6.1.3
(10B329)/Symbols/System/Library/Frameworks/UIKit.framework/UIKit')
/Applications/Xcode5-DP5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool:
file: /Users/Piero/Library/Developer/Xcode/iOS DeviceSupport/6.1.3
(10B329)/Symbols/System/Library/PrivateFrameworks/JavaScriptCore.framework/JavaScriptCore
does not contain architecture: armv7
Can't understand the output from otool ( -> xcrun -sdk iphoneos otool
-arch armv7 -l '/Users/Piero/Library/Developer/Xcode/iOS
DeviceSupport/6.1.3
(10B329)/Symbols/System/Library/PrivateFrameworks/JavaScriptCore.framework/JavaScriptCore')
/Applications/Xcode5-DP5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool:
file: /Users/Piero/Library/Developer/Xcode/iOS DeviceSupport/6.1.3
(10B329)/Symbols/System/Library/PrivateFrameworks/WebCore.framework/WebCore
does not contain architecture: armv7
Can't understand the output from otool ( -> xcrun -sdk iphoneos otool
-arch armv7 -l '/Users/Piero/Library/Developer/Xcode/iOS
DeviceSupport/6.1.3
(10B329)/Symbols/System/Library/PrivateFrameworks/WebCore.framework/WebCore')
/Applications/Xcode5-DP5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool:
file: /Users/Piero/Library/Developer/Xcode/iOS DeviceSupport/6.1.3
(10B329)/Symbols/usr/lib/libc++abi.dylib does not contain architecture:
armv7
Can't understand the output from otool ( -> xcrun -sdk iphoneos otool
-arch armv7 -l '/Users/Piero/Library/Developer/Xcode/iOS
DeviceSupport/6.1.3 (10B329)/Symbols/usr/lib/libc++abi.dylib')
/Applications/Xcode5-DP5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool:
file: /Users/Piero/Library/Developer/Xcode/iOS DeviceSupport/6.1.3
(10B329)/Symbols/usr/lib/libobjc.A.dylib does not contain architecture:
armv7
Can't understand the output from otool ( -> xcrun -sdk iphoneos otool
-arch armv7 -l '/Users/Piero/Library/Developer/Xcode/iOS
DeviceSupport/6.1.3 (10B329)/Symbols/usr/lib/libobjc.A.dylib')
/Applications/Xcode5-DP5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool:
file: /Users/Piero/Library/Developer/Xcode/iOS DeviceSupport/6.1.3
(10B329)/Symbols/usr/lib/system/libdispatch.dylib does not contain
architecture: armv7
Can't understand the output from otool ( -> xcrun -sdk iphoneos otool
-arch armv7 -l '/Users/Piero/Library/Developer/Xcode/iOS
DeviceSupport/6.1.3 (10B329)/Symbols/usr/lib/system/libdispatch.dylib')
/Applications/Xcode5-DP5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool:
file: /Users/Piero/Library/Developer/Xcode/iOS DeviceSupport/6.1.3
(10B329)/Symbols/usr/lib/system/libsystem_c.dylib does not contain
architecture: armv7
Can't understand the output from otool ( -> xcrun -sdk iphoneos otool
-arch armv7 -l '/Users/Piero/Library/Developer/Xcode/iOS
DeviceSupport/6.1.3 (10B329)/Symbols/usr/lib/system/libsystem_c.dylib')
/Applications/Xcode5-DP5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool:
file: /Users/Piero/Library/Developer/Xcode/iOS DeviceSupport/6.1.3
(10B329)/Symbols/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
does not contain architecture: armv7
Can't understand the output from otool ( -> xcrun -sdk iphoneos otool
-arch armv7 -l '/Users/Piero/Library/Developer/Xcode/iOS
DeviceSupport/6.1.3
(10B329)/Symbols/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation')
/Applications/Xcode5-DP5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool:
file: /Users/Piero/Library/Developer/Xcode/iOS DeviceSupport/6.1.3
(10B329)/Symbols/usr/lib/system/libsystem_kernel.dylib does not contain
architecture: armv7
Can't understand the output from otool ( -> xcrun -sdk iphoneos otool
-arch armv7 -l '/Users/Piero/Library/Developer/Xcode/iOS
DeviceSupport/6.1.3
(10B329)/Symbols/usr/lib/system/libsystem_kernel.dylib')
Sending symbolicated data back to the server ...
Deleting temporary files ...
Done
there is way to fix it?
Best allocation unit size for external HDD
Best allocation unit size for external HDD
what is the best allocation unit size foe 2tb external hard drive?
need to save space and can sacrifice performance and speed.no softwares
are installed in. only use will be as a file storage.have no growing files
and it is not connected to torrent client either
my main contents will be
1.mostly pdf files--approx file size few Kb - 60mb
2.video files & songs--50 to 180mb
3.movies--300 to 800mb
4.very few iso files-3gb,8gb,13Gb files
also i am not planning to partition the disk.
please reply.i really appriciate it. i am very confused becouse of the
various types and sizes of the files i have.
Thank you!
what is the best allocation unit size foe 2tb external hard drive?
need to save space and can sacrifice performance and speed.no softwares
are installed in. only use will be as a file storage.have no growing files
and it is not connected to torrent client either
my main contents will be
1.mostly pdf files--approx file size few Kb - 60mb
2.video files & songs--50 to 180mb
3.movies--300 to 800mb
4.very few iso files-3gb,8gb,13Gb files
also i am not planning to partition the disk.
please reply.i really appriciate it. i am very confused becouse of the
various types and sizes of the files i have.
Thank you!
Languages that don't have the single classpath issue in Java
Languages that don't have the single classpath issue in Java
I started to write a piece of software with a group of friends and chose
the Java language since we were all familiar with it. In order to solve
the single classpath problem in Java, we chose to use OSGi. We used Spring
DM, Hibernate and CXF DOSGi for the project.
It took a lot of effort to get things working. For example, we wanted to
use Spring annotations to mark transactions and it was quite a difficult
task. We got a lot of "ClassNotFoundException"s and in order to solve
them, added imports to the import-package section without knowing exactly
why they were needed(These were mainly spring packages).
After going through the process we thought that maybe we have chosen the
wrong language?
So my questions are,
what are the languages that do not have the single classpath problem like
in Java?
How does those languages solve the problem?
Are there any cons in using any of those languages rather than using
Java(except for the fact that we will have to learn them)?
I started to write a piece of software with a group of friends and chose
the Java language since we were all familiar with it. In order to solve
the single classpath problem in Java, we chose to use OSGi. We used Spring
DM, Hibernate and CXF DOSGi for the project.
It took a lot of effort to get things working. For example, we wanted to
use Spring annotations to mark transactions and it was quite a difficult
task. We got a lot of "ClassNotFoundException"s and in order to solve
them, added imports to the import-package section without knowing exactly
why they were needed(These were mainly spring packages).
After going through the process we thought that maybe we have chosen the
wrong language?
So my questions are,
what are the languages that do not have the single classpath problem like
in Java?
How does those languages solve the problem?
Are there any cons in using any of those languages rather than using
Java(except for the fact that we will have to learn them)?
set Vim as a basic C++ ide
set Vim as a basic C++ ide
I want to set Vim as a basic IDE for C++, I just want to perform these tasks:
write code (you don't say?)
check and highlight C++ syntaxis
autocompletion (if is possible)
compile & run, and return to the editor
tree-view project files on the side
statusbar
I know that much of this tasks can be done with plugins, so I need your
help to make a list of required plugins and how to set them up together as
a basic C++ IDE.
why basic? well, I'm taking the programming course level 1 in my
university, and we will make simple command-line programs, simple such a
mathematical evaluations (functions, array even or odd numbers, draw
triangles with asterisks and so.)
I want to set Vim as a basic IDE for C++, I just want to perform these tasks:
write code (you don't say?)
check and highlight C++ syntaxis
autocompletion (if is possible)
compile & run, and return to the editor
tree-view project files on the side
statusbar
I know that much of this tasks can be done with plugins, so I need your
help to make a list of required plugins and how to set them up together as
a basic C++ IDE.
why basic? well, I'm taking the programming course level 1 in my
university, and we will make simple command-line programs, simple such a
mathematical evaluations (functions, array even or odd numbers, draw
triangles with asterisks and so.)
Friday, 23 August 2013
How do I get Yeoman to continuously run tests
How do I get Yeoman to continuously run tests
When I run grunt server, my file edits are picked up and the browser
refreshed through livereload. When I run grunt test, it runs once and
shuts down.
This behavior can be simulated by running
yo angular --minsafe mytest
grunt test
When I change karma.unit.singlerun = false in the Gruntfile, grunt test
now says that a watcher is running, but no file changes seem to trigger
running the tests again.
How do I get the reload capability with the tests similar to the way
linemanjs works?
When I run grunt server, my file edits are picked up and the browser
refreshed through livereload. When I run grunt test, it runs once and
shuts down.
This behavior can be simulated by running
yo angular --minsafe mytest
grunt test
When I change karma.unit.singlerun = false in the Gruntfile, grunt test
now says that a watcher is running, but no file changes seem to trigger
running the tests again.
How do I get the reload capability with the tests similar to the way
linemanjs works?
QGLWidget maximum size
QGLWidget maximum size
I have a QT application using OpenGL drawing with QGLWidget, on Mac OS. I
developed it on my MBP, and it worked well, then later I tried it on a 30"
screen and realised that there is a window size limit, if I increase the
window size beyond a certain limit, the QGLWidget's content disappears and
only some grayis memory junk is visible.
I removed all the code, so that all the application does now is to put a
full size QGLWidget in the window, and it also has a simple repaint event
setting the background black in each iteration. The issue is still visible
with this simple setup, I can't increase the size, at a limit the black
surface disappears and gots replaced by the memory junk.
Interesting facts:
When I decrease the window size, the GL surface comes back to live again
I have several other GL applications (not QT) running in maximized window,
so the issue is not with the OpenGL driver/video card
It seems that the area of the window (nr of pixels) matters, if I make the
window very wide, it's height will be limited and vica versa, I if the
windoe is maximized in height, the width must be small
I have a QT application using OpenGL drawing with QGLWidget, on Mac OS. I
developed it on my MBP, and it worked well, then later I tried it on a 30"
screen and realised that there is a window size limit, if I increase the
window size beyond a certain limit, the QGLWidget's content disappears and
only some grayis memory junk is visible.
I removed all the code, so that all the application does now is to put a
full size QGLWidget in the window, and it also has a simple repaint event
setting the background black in each iteration. The issue is still visible
with this simple setup, I can't increase the size, at a limit the black
surface disappears and gots replaced by the memory junk.
Interesting facts:
When I decrease the window size, the GL surface comes back to live again
I have several other GL applications (not QT) running in maximized window,
so the issue is not with the OpenGL driver/video card
It seems that the area of the window (nr of pixels) matters, if I make the
window very wide, it's height will be limited and vica versa, I if the
windoe is maximized in height, the width must be small
How do I ensure that all controllers in an asp.net web-api service are configured correctly _in a single test class_?
How do I ensure that all controllers in an asp.net web-api service are
configured correctly _in a single test class_?
Dipping my toes into asp.net and mvc, more specifically the web-api (2.0)
part of MVC 5, I like the idea of using attributes and creating your own
attribute classes to control how requests are handled and responses
returned for all api end-points.
The "How to test "Only certain roles should have access to a controller in
MVC" article describes how to unit test a single controller to ensure that
it keeps the correct attributes and doesn't get undesired attributes
added.
That is a perfectly valid way of unit testing individual controllers.
However, I prefer to have all tests of the API configuration in a single
place instead of spread around unit tests of individual controllers.
Especially as using attribute routing, a controller can very easily be
replaced by a different controller which may not have the correct
attributes and whose test companion doesn't test for them.
What I envision is a single test class where all aspects of the API
configuration can be secured against undesired effects of (inadvertent)
changes. What I am struggling with is how to set this up. Bryan Avery's
article (mentioned above) shows how to get a list of the custom attributes
of a controller class, but:
how do I get my hands on a list of all controllers present in the test
project?
configured correctly _in a single test class_?
Dipping my toes into asp.net and mvc, more specifically the web-api (2.0)
part of MVC 5, I like the idea of using attributes and creating your own
attribute classes to control how requests are handled and responses
returned for all api end-points.
The "How to test "Only certain roles should have access to a controller in
MVC" article describes how to unit test a single controller to ensure that
it keeps the correct attributes and doesn't get undesired attributes
added.
That is a perfectly valid way of unit testing individual controllers.
However, I prefer to have all tests of the API configuration in a single
place instead of spread around unit tests of individual controllers.
Especially as using attribute routing, a controller can very easily be
replaced by a different controller which may not have the correct
attributes and whose test companion doesn't test for them.
What I envision is a single test class where all aspects of the API
configuration can be secured against undesired effects of (inadvertent)
changes. What I am struggling with is how to set this up. Bryan Avery's
article (mentioned above) shows how to get a list of the custom attributes
of a controller class, but:
how do I get my hands on a list of all controllers present in the test
project?
Backgroundmusicplayer Playlist Windows Phone
Backgroundmusicplayer Playlist Windows Phone
Hi I am trying to build I music app for windows mobile im using the sample
code from the Microsoft sample page everything is functioning time, the
progress bar time remaining, buttons, art ect.. but I cannot get a
playlist work can anyone offer any advice.
Hi I am trying to build I music app for windows mobile im using the sample
code from the Microsoft sample page everything is functioning time, the
progress bar time remaining, buttons, art ect.. but I cannot get a
playlist work can anyone offer any advice.
the @synchronized in Objective-C
the @synchronized in Objective-C
@synchronized(self.runningOperations) { line 1
[self.runningOperations addObject:operation]; line 2
}
when I debug these code .at first it runs the line 1 ,then go to the line
2.it's all right,but after this ,it go to the line 1 again,then go to the
line 2,then jump out the @synchronized. but when I print the
runningOperations,the first time it runs the line 2 code,the Object not
add into self.runningOperations,it is added at the second time. why it run
twice,and why the Object add into self.runningOperations in the second
time?
@synchronized(self.runningOperations) { line 1
[self.runningOperations addObject:operation]; line 2
}
when I debug these code .at first it runs the line 1 ,then go to the line
2.it's all right,but after this ,it go to the line 1 again,then go to the
line 2,then jump out the @synchronized. but when I print the
runningOperations,the first time it runs the line 2 code,the Object not
add into self.runningOperations,it is added at the second time. why it run
twice,and why the Object add into self.runningOperations in the second
time?
alternative firmware (kernel or bootloader) for ebookreader bookeen odyssey
alternative firmware (kernel or bootloader) for ebookreader bookeen odyssey
I'm seeking an alternative distribution or firmware for ebook-readers like
openinkpot. I have a Bookeen Odyssey and my intention is to change the
firmware.
If no alternative firmware exists is there somewhere some work on kernel
or bootloader for this reader done?
I'm seeking an alternative distribution or firmware for ebook-readers like
openinkpot. I have a Bookeen Odyssey and my intention is to change the
firmware.
If no alternative firmware exists is there somewhere some work on kernel
or bootloader for this reader done?
Thursday, 22 August 2013
Why does the google font look so bad in Chrome?
Why does the google font look so bad in Chrome?
http://bbmthemes.com/themes/smart/
All of the font sizes of the common free font "Open Sans" look great in
firefox, but when I view the site in Chrome the edges are horribly
pixelated and the letter spacing isnt even the same. Is there anything
that I can do to fix this? I need to use google fonts, rather than
@font-face.
http://bbmthemes.com/themes/smart/
All of the font sizes of the common free font "Open Sans" look great in
firefox, but when I view the site in Chrome the edges are horribly
pixelated and the letter spacing isnt even the same. Is there anything
that I can do to fix this? I need to use google fonts, rather than
@font-face.
Parse.com API: How to query for objects incrementally?
Parse.com API: How to query for objects incrementally?
I have a table view controller that is fetching objects from a database
hosted by parse.com. At the moment, I have the view controller fetch all
the objects in the database for storage in an array. Right now, there are
100 objects in the database, and what I would like to do, is have the
table view controller fetch 20 of those objects and display them, then
have it fetch and display 20 more when the table scrolls to the bottom.
Here is my init method:
- (id)initWithStyle:(UITableViewStyle)style{
self = [super initWithStyle:style];
if (self) {
//create the array, set the table view size, then populate it.
listings = [[NSMutableArray alloc] init];
[self populateArrayWithListings];
}
return self;
}
[self populateArrayWithListings]; simply fills the array listings with the
100 objects in the database. I have this method to detect when the table
view controller is scrolled to at the bottom:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (scrollView.contentOffset.y + scrollView.bounds.size.height >
scrollView.contentSize.height * 0.9) {
}
}
Question is, what should I put inside those brackets to have it fetch the
next 20 objects in the database?
I have a table view controller that is fetching objects from a database
hosted by parse.com. At the moment, I have the view controller fetch all
the objects in the database for storage in an array. Right now, there are
100 objects in the database, and what I would like to do, is have the
table view controller fetch 20 of those objects and display them, then
have it fetch and display 20 more when the table scrolls to the bottom.
Here is my init method:
- (id)initWithStyle:(UITableViewStyle)style{
self = [super initWithStyle:style];
if (self) {
//create the array, set the table view size, then populate it.
listings = [[NSMutableArray alloc] init];
[self populateArrayWithListings];
}
return self;
}
[self populateArrayWithListings]; simply fills the array listings with the
100 objects in the database. I have this method to detect when the table
view controller is scrolled to at the bottom:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (scrollView.contentOffset.y + scrollView.bounds.size.height >
scrollView.contentSize.height * 0.9) {
}
}
Question is, what should I put inside those brackets to have it fetch the
next 20 objects in the database?
War Overlay... with Ant?
War Overlay... with Ant?
I've been tasked with setting up a Jasig CAS server, which is a Maven
project using the Spring Framework. It uses the Maven War Overlay plugin
to combine the CAS server's original files with my custom files.
Unfortunately, I am not permitted to leverage Maven and must therefore
convert this to an Ant project.
I am not as knowledgeable with Ant as I am with Maven. Does Ant have a
feature comparable to the Maven War Overlay plugin?
I've been tasked with setting up a Jasig CAS server, which is a Maven
project using the Spring Framework. It uses the Maven War Overlay plugin
to combine the CAS server's original files with my custom files.
Unfortunately, I am not permitted to leverage Maven and must therefore
convert this to an Ant project.
I am not as knowledgeable with Ant as I am with Maven. Does Ant have a
feature comparable to the Maven War Overlay plugin?
How Do I Specify Date Range in Rails?
How Do I Specify Date Range in Rails?
In my Rails 3.2 app, I need to create an if condition that checks what
date range today's date is in. Something like this:
current_date = Date.today
# if current_date is between 2013-08-01..2013-08-15
# return 1
# elsif current_date is between 2013-08-16..2013-08-30
# return 2
# end
In my Rails 3.2 app, I need to create an if condition that checks what
date range today's date is in. Something like this:
current_date = Date.today
# if current_date is between 2013-08-01..2013-08-15
# return 1
# elsif current_date is between 2013-08-16..2013-08-30
# return 2
# end
How many servers to be setup for sametime installation
How many servers to be setup for sametime installation
I need to know how many servers are to be setup to install lotus sametime
connect client in a system? What is the architecture? Pls detail the
steps.
I need to know how many servers are to be setup to install lotus sametime
connect client in a system? What is the architecture? Pls detail the
steps.
Wednesday, 21 August 2013
how to know the method loaded from which DLL
how to know the method loaded from which DLL
A common method foo() is defined in two DLLs A.dll and B.dll. Now when a
process proc.exe loads both DLLs and call foo() method simultaneously from
two threads. I want to know foo() was loaded from which DLL A.dll or B.dll
at run time for logging purpose.
GetModuleFileName() would return the process name proc.exe not the Dlls
name name.
A common method foo() is defined in two DLLs A.dll and B.dll. Now when a
process proc.exe loads both DLLs and call foo() method simultaneously from
two threads. I want to know foo() was loaded from which DLL A.dll or B.dll
at run time for logging purpose.
GetModuleFileName() would return the process name proc.exe not the Dlls
name name.
Android annotations REST send image
Android annotations REST send image
I use android annotations to communicate with the server. In one of the
api calls I need to send some text data and an image, say, from gallery.
@Post("/items/addItem.php")
String addItem(Protocol protocol);
How do I attach a MultipartForm with an image along with the post request?
I use android annotations to communicate with the server. In one of the
api calls I need to send some text data and an image, say, from gallery.
@Post("/items/addItem.php")
String addItem(Protocol protocol);
How do I attach a MultipartForm with an image along with the post request?
Escaping this string? (PHP)
Escaping this string? (PHP)
Hello I am making a PHP Script and I need to escape a string for my
preg_replace function and my php server does not display errors for some
reason so I am not able to detect where I did the mistake!
The strig is /*1*\
I am trying: '@\/\*1\*\@' => 'HERE!'
It doesn't work for some reason! Help?
Hello I am making a PHP Script and I need to escape a string for my
preg_replace function and my php server does not display errors for some
reason so I am not able to detect where I did the mistake!
The strig is /*1*\
I am trying: '@\/\*1\*\@' => 'HERE!'
It doesn't work for some reason! Help?
JSP Custom tag html button render
JSP Custom tag html button render
I have a jsp and custom tag to load that is basically a portion of my html
code. The even that triggers the page to call the custom tag is onclick
from a button using ajax to reload it. The problem I'm having is that when
it reaches the custom tag to esentially refresh a portion of my page , the
page has checkboxs on them (one is checked), it doesn't entirely refresh
that part of the page because I have checkboxes that would be get
un-checked within that tag???
I have a jsp and custom tag to load that is basically a portion of my html
code. The even that triggers the page to call the custom tag is onclick
from a button using ajax to reload it. The problem I'm having is that when
it reaches the custom tag to esentially refresh a portion of my page , the
page has checkboxs on them (one is checked), it doesn't entirely refresh
that part of the page because I have checkboxes that would be get
un-checked within that tag???
How to select a text node on jquery without selecting the sibiling
How to select a text node on jquery without selecting the sibiling
I have some HTML that is structured like this:
<div class="ProductPriceRating">
<em>
<strike class="RetailPriceValue">$65.00</strike>
$45.00
</em>
</div>
I need to select the "$45.00". I thought this would work:
$('.ProductPriceRating strike').siblings().css('background','red');
But it didn't
I have some HTML that is structured like this:
<div class="ProductPriceRating">
<em>
<strike class="RetailPriceValue">$65.00</strike>
$45.00
</em>
</div>
I need to select the "$45.00". I thought this would work:
$('.ProductPriceRating strike').siblings().css('background','red');
But it didn't
how to reduce communication time in distributed teams
how to reduce communication time in distributed teams
We have 10 distributed teams in our company and we are developing 3 huge
web applications. A lot of time of our developers is spent with writing
emails.
We are using scrum and for that we had a daily stand-up meeting, but other
questions regarding product features, design issues are always
communicated via email?
Is there a method or techniques available to reduce the time which is used
to communicate!
We have 10 distributed teams in our company and we are developing 3 huge
web applications. A lot of time of our developers is spent with writing
emails.
We are using scrum and for that we had a daily stand-up meeting, but other
questions regarding product features, design issues are always
communicated via email?
Is there a method or techniques available to reduce the time which is used
to communicate!
how to create mvc based application without using framework
how to create mvc based application without using framework
Struts, Spring and few frameworks provide MVC architecture for separates
the representation of information from the user's interaction with it.
Can any one explain or give me an link for that In J2EE, Without using
framework How to create MVC application and what are the design patterns
are need to create for that?
Struts, Spring and few frameworks provide MVC architecture for separates
the representation of information from the user's interaction with it.
Can any one explain or give me an link for that In J2EE, Without using
framework How to create MVC application and what are the design patterns
are need to create for that?
Tuesday, 20 August 2013
how t copy single column values from existing table to another table
how t copy single column values from existing table to another table
How to fetch data from existing table to a new table in SQL (FOR only
single column values copy to another table) .For this purpose give query?
How to fetch data from existing table to a new table in SQL (FOR only
single column values copy to another table) .For this purpose give query?
execute PHP code when selecting a combobox item
execute PHP code when selecting a combobox item
I have a static combobox in a php web page.I want when selecting an item
from this combobox (example 'item 1') the php execute a SELECT statement
to get the value of a field named 'item 1' from a table X in my database.
How that can be done ?
I have a static combobox in a php web page.I want when selecting an item
from this combobox (example 'item 1') the php execute a SELECT statement
to get the value of a field named 'item 1' from a table X in my database.
How that can be done ?
How to find Maximum Value of Multiple Properties
How to find Maximum Value of Multiple Properties
We have the following Product Class.
public string Product{ get; set; }
public int? Monday { get; set; }
public int? Tuesday { get; set; }
public int? Wednesday { get; set; }
public int? Thursday { get; set; }
public int? Friday { get; set; }
public int? Saturday { get; set; }
public int? Sunday { get; set; }
public string Zip { get; set; }
The Properties hold the sales values for that day of the week. We need to
be able to search a list of Products, and select the Total Sales for ALL
products based on the Product's best sales day. For instance: In the
sample below, product 1 has the highest sales on Monday and Product2 has
the highest sales on Sunday, so the total should combine the 2 (5378).
Product Zip City State Sunday Monday Tuesday Wednesday
Thursday Friday
Product 1 63103 Saint Louis MO 0 4728 0 1522 0 0
Product 2 63103 Saint Louis MO 650 419 417 428 599 559
Here is the LINQ code I have so far.
var temp = report.SelectMany(p => p.SnapshotRecords)
.Where(record => record.Zip == "63103")
.GroupBy(g => new
{
g.Zip,
g.ProductID
})
.Select(s => new SnapshotData()
{
Monday = s.Sum(g => g.Monday),
Tuesday = s.Sum(g => g.Tuesday),
Wednesday = s.Sum(g => g.Wednesday),
Thursday = s.Sum(g => g.Thursday),
Friday = s.Sum(g => g.Friday),
Saturday = s.Sum(g => g.Saturday),
Sunday = s.Sum(g => g.Sunday),
});
We have the following Product Class.
public string Product{ get; set; }
public int? Monday { get; set; }
public int? Tuesday { get; set; }
public int? Wednesday { get; set; }
public int? Thursday { get; set; }
public int? Friday { get; set; }
public int? Saturday { get; set; }
public int? Sunday { get; set; }
public string Zip { get; set; }
The Properties hold the sales values for that day of the week. We need to
be able to search a list of Products, and select the Total Sales for ALL
products based on the Product's best sales day. For instance: In the
sample below, product 1 has the highest sales on Monday and Product2 has
the highest sales on Sunday, so the total should combine the 2 (5378).
Product Zip City State Sunday Monday Tuesday Wednesday
Thursday Friday
Product 1 63103 Saint Louis MO 0 4728 0 1522 0 0
Product 2 63103 Saint Louis MO 650 419 417 428 599 559
Here is the LINQ code I have so far.
var temp = report.SelectMany(p => p.SnapshotRecords)
.Where(record => record.Zip == "63103")
.GroupBy(g => new
{
g.Zip,
g.ProductID
})
.Select(s => new SnapshotData()
{
Monday = s.Sum(g => g.Monday),
Tuesday = s.Sum(g => g.Tuesday),
Wednesday = s.Sum(g => g.Wednesday),
Thursday = s.Sum(g => g.Thursday),
Friday = s.Sum(g => g.Friday),
Saturday = s.Sum(g => g.Saturday),
Sunday = s.Sum(g => g.Sunday),
});
JVM-Language for Comfortable Hot-Code Swapping?
JVM-Language for Comfortable Hot-Code Swapping?
I really like the way you can reload code in some languages (or just load
new code, that isn't bound by any type restrictions), like in
Smalltalk/Python/Erlang/JavaScript/etc. The Problem however is that I have
become heavily reliant on the JVM (not a bad thing imho - I do love the
Syntax/Semantics of Java, when contrasting it with those other languages).
But Java/JVM can't really do this code swapping thing on the same level
without restarting. The main reason for wanting to do it without
restarting is to maintain the state of GUIs, sockets, etc. while changing
the code underneath.
I know JRebel does something similar, but they themselves claim their
solution to not be production-grade (.. and it costs money). I guess I
could whip up something similar myself, for the limited use-case that I'm
looking at .. One MetaObjectInterface that calls Runnables/Callables
through a HashMap and then just keep on loading classes that implement
this interface every time I want to reload anything - but obviously
performance would be horrible, since the JVM can't devirtualize these
calls when JITing.
Languages/Implementations like Groovy have solved this partly by using
invokedynamic, but they don't really seem to offer any reasonable way of
loading new code, other than using eval .. which doesn't really swap out
anything, seeing how it is run in a new interpreer context/scope (or am I
wrong here?).
My question now is what you're experiences have been. Specifically, what
do you believe is the most comfortable way/language of doing
Smalltalk/Python-esque code reloading on the JVM that offers
"production-grade" performance (i.e. somewhere within one order of
magnitude of Java code).
(Sidenote: I know how dangerous this might be and how unmaintainable the
code may end up. I also am aware that the JVM has problems with GC'ing
classes. Both of these discussions are off-topic in the context of this
question though.)
I really like the way you can reload code in some languages (or just load
new code, that isn't bound by any type restrictions), like in
Smalltalk/Python/Erlang/JavaScript/etc. The Problem however is that I have
become heavily reliant on the JVM (not a bad thing imho - I do love the
Syntax/Semantics of Java, when contrasting it with those other languages).
But Java/JVM can't really do this code swapping thing on the same level
without restarting. The main reason for wanting to do it without
restarting is to maintain the state of GUIs, sockets, etc. while changing
the code underneath.
I know JRebel does something similar, but they themselves claim their
solution to not be production-grade (.. and it costs money). I guess I
could whip up something similar myself, for the limited use-case that I'm
looking at .. One MetaObjectInterface that calls Runnables/Callables
through a HashMap and then just keep on loading classes that implement
this interface every time I want to reload anything - but obviously
performance would be horrible, since the JVM can't devirtualize these
calls when JITing.
Languages/Implementations like Groovy have solved this partly by using
invokedynamic, but they don't really seem to offer any reasonable way of
loading new code, other than using eval .. which doesn't really swap out
anything, seeing how it is run in a new interpreer context/scope (or am I
wrong here?).
My question now is what you're experiences have been. Specifically, what
do you believe is the most comfortable way/language of doing
Smalltalk/Python-esque code reloading on the JVM that offers
"production-grade" performance (i.e. somewhere within one order of
magnitude of Java code).
(Sidenote: I know how dangerous this might be and how unmaintainable the
code may end up. I also am aware that the JVM has problems with GC'ing
classes. Both of these discussions are off-topic in the context of this
question though.)
Implementing imclose(IM, SE) in opencv
Implementing imclose(IM, SE) in opencv
I want to detect the background of the following image whose foreground is
always lots of black dots:
img.png
Someone performs morphological closing on the image with disk-shaped
structuring element and obtain a good result:
Matlab code:
img = imread('c:\img.png');
bg = imclose(img, strel('disk', 15));
figure('name', 'bg'), imshow(bg);
So how to implement imclose(IM, SE) in opencv to replace the work in
MATLAB or there is another better way to detect such background using
opencv method?
I want to detect the background of the following image whose foreground is
always lots of black dots:
img.png
Someone performs morphological closing on the image with disk-shaped
structuring element and obtain a good result:
Matlab code:
img = imread('c:\img.png');
bg = imclose(img, strel('disk', 15));
figure('name', 'bg'), imshow(bg);
So how to implement imclose(IM, SE) in opencv to replace the work in
MATLAB or there is another better way to detect such background using
opencv method?
Convert the image to a byte array
Convert the image to a byte array
How to convert the picture into a byte array? Found an example, when a
file is open:
using (IRandomAccessStreamWithContentType stream = await
photo.OpenReadAsync())
{
bytes = new byte[stream.Size];
var reader = new DataReader(stream.GetInputStreamAt(0));
await reader.LoadAsync((uint)stream.Size);
reader.ReadBytes(bytes);
}
My image is generated in software, what can I do? Thanks!
How to convert the picture into a byte array? Found an example, when a
file is open:
using (IRandomAccessStreamWithContentType stream = await
photo.OpenReadAsync())
{
bytes = new byte[stream.Size];
var reader = new DataReader(stream.GetInputStreamAt(0));
await reader.LoadAsync((uint)stream.Size);
reader.ReadBytes(bytes);
}
My image is generated in software, what can I do? Thanks!
Pagination in rails 3
Pagination in rails 3
In my rails application I need to display the matching tweets .lets say
for example the matching results has 50 records, I need to display 10
records per page.I am getting the output which has all results but when I
use pagination its showing link to different pages , but when I click the
link to next page it says "string not matched". I tried different
combinations like 5 per page ,but when I click the link to the next page
it says "string not matched", but when I try without pagination it shows
all the results
My code for the controller
class TweetsController<ApplicationController
def index
city = params[:show]
search_term = params[:text]
search_term[" "] = "%"
@tweets = Tweets.where("tweet_text LIKE? ", "%#{search_term}%").paginate(
page: params[:page], per_page: 3)
My code for the view
<%= will_paginate @tweets %>
<% @tweets.each do |tweets| %>
<ul>
<li><%= tweets.id %></li>
<li><%= tweets.tweet_created_at %></li>
<li><%= tweets.tweet_source %></li>
<li><%= tweets.tweet_text %></li>
<li><%= tweets.user_id %></li>
<li><%= tweets.user_name %></li>
<li><%= tweets.user_sc_name %></li>
<li><%= tweets.user_loc %></li>
<li><%= tweets.user_img %></li>
<li><%= tweets.longitude %></li>
<li><%= tweets.latitude %></li>
<li><%= tweets.place %></li>
<li><%= tweets.country %></li>
<% end %>
</ul>
Anyone please help me with this
In my rails application I need to display the matching tweets .lets say
for example the matching results has 50 records, I need to display 10
records per page.I am getting the output which has all results but when I
use pagination its showing link to different pages , but when I click the
link to next page it says "string not matched". I tried different
combinations like 5 per page ,but when I click the link to the next page
it says "string not matched", but when I try without pagination it shows
all the results
My code for the controller
class TweetsController<ApplicationController
def index
city = params[:show]
search_term = params[:text]
search_term[" "] = "%"
@tweets = Tweets.where("tweet_text LIKE? ", "%#{search_term}%").paginate(
page: params[:page], per_page: 3)
My code for the view
<%= will_paginate @tweets %>
<% @tweets.each do |tweets| %>
<ul>
<li><%= tweets.id %></li>
<li><%= tweets.tweet_created_at %></li>
<li><%= tweets.tweet_source %></li>
<li><%= tweets.tweet_text %></li>
<li><%= tweets.user_id %></li>
<li><%= tweets.user_name %></li>
<li><%= tweets.user_sc_name %></li>
<li><%= tweets.user_loc %></li>
<li><%= tweets.user_img %></li>
<li><%= tweets.longitude %></li>
<li><%= tweets.latitude %></li>
<li><%= tweets.place %></li>
<li><%= tweets.country %></li>
<% end %>
</ul>
Anyone please help me with this
Monday, 19 August 2013
How to relace byte of 32bit variable in inline assembly?
How to relace byte of 32bit variable in inline assembly?
I want to replace the highest byte of 32bit value:
__asm__ __volatile__ (
" ldi %D0, %1" "\n\t"
: "=d" ((uint32_t)addr)
: "M" (op_code)
);
and after that inline assembly addr variable gets cluttered - compiler use
registers allocated for addr as temporary registers for other operation
and i lose original addr value. Any idea whats wrong with this code?
I want to replace the highest byte of 32bit value:
__asm__ __volatile__ (
" ldi %D0, %1" "\n\t"
: "=d" ((uint32_t)addr)
: "M" (op_code)
);
and after that inline assembly addr variable gets cluttered - compiler use
registers allocated for addr as temporary registers for other operation
and i lose original addr value. Any idea whats wrong with this code?
How to read and write shared_ptr?
How to read and write shared_ptr?
When my data use shared_ptr which is shared by a number of entries, any
good way to read and write the data to show the sharing?
When my data use shared_ptr which is shared by a number of entries, any
good way to read and write the data to show the sharing?
Google Feed API 'publishedDate' wrong day
Google Feed API 'publishedDate' wrong day
When using Google Feed API JSON result the origin RSS is being converted a
day off in the JSON results.
For example the following origin RSS entry:
<pubDate>Mon, 19 Aug 2013 04:00:00 GMT</pubDate>
...becomes:
"Sun, 18 Aug 2013 21:00:00 -0700"
...in the JSON result. Is there any way to designate a time zone so it
knows not to convert?
Thanks in advance!
When using Google Feed API JSON result the origin RSS is being converted a
day off in the JSON results.
For example the following origin RSS entry:
<pubDate>Mon, 19 Aug 2013 04:00:00 GMT</pubDate>
...becomes:
"Sun, 18 Aug 2013 21:00:00 -0700"
...in the JSON result. Is there any way to designate a time zone so it
knows not to convert?
Thanks in advance!
PyroCMS form handling
PyroCMS form handling
I would like to modify the required fields for the registration and the
edit-profile forms in PyroCMS.
Unfortunately I cannot find the code which does the form handling (the
part where the required fields are passed).
Can anybody point me to it?
Thanks.
I would like to modify the required fields for the registration and the
edit-profile forms in PyroCMS.
Unfortunately I cannot find the code which does the form handling (the
part where the required fields are passed).
Can anybody point me to it?
Thanks.
Redis with Magento on different port (other than 80)
Redis with Magento on different port (other than 80)
I'm quite new to Ubuntu (or at least the terminal and the directories) and
I've already encountered a problem on installing Redis on Magento. I'm
currently running Ubuntu x64 12.04 and I can't seem to get Redis to work
with Magento.
I've tested Magento on localhost using port 80 and Redis cache works fine.
The problem arises when I have to switch the TCP port from 80 to 8000
because my ISP actively blocks these ports to prevent users to setup their
own HTTP, FTP, SMTP servers etc.. I've done port forwarding from 8000 to
80 on my router but the images can't seem to appear to load in the browser
with the URL having a :8000 attached to it. When I remove the code* from
the app/etc/local.xml file, everything becomes fine.
I want to try to enable Redis because I've used it before and it speeds up
my Magento site many times more. What should I do to bridge the 2
solutions together?
FYI, the conflicting code in app/etc/local.xml that is causing the problem is
<!-- This is a child node of config/global -->
<cache>
<backend>Cm_Cache_Backend_Redis</backend>
<backend_options>
<server>127.0.0.1</server> <!-- or absolute path to unix socket -->
<port>6379</port>
<persistent></persistent> <!-- Specify unique string to enable
persistent connections. E.g.: sess-db0; bugs with phpredis and php-fpm
are known: https://github.com/nicolasff/phpredis/issues/70 -->
<database>0</database> <!-- Redis database number; protection against
accidental data loss is improved by not sharing databases -->
<password></password> <!-- Specify if your Redis server requires
authentication -->
<force_standalone>0</force_standalone> <!-- 0 for phpredis, 1 for
standalone PHP -->
<connect_retries>1</connect_retries> <!-- Reduces errors due to
random connection failures; a value of 1 will not retry after the
first failure -->
<read_timeout>10</read_timeout> <!-- Set read timeout
duration; phpredis does not currently support setting read timeouts
-->
<automatic_cleaning_factor>0</automatic_cleaning_factor> <!-- Disabled
by default -->
<compress_data>1</compress_data> <!-- 0-9 for compression level,
recommended: 0 or 1 -->
<compress_tags>1</compress_tags> <!-- 0-9 for compression level,
recommended: 0 or 1 -->
<compress_threshold>20480</compress_threshold> <!-- Strings below
this size will not be compressed -->
<compression_lib>gzip</compression_lib> <!-- Supports gzip, lzf and
snappy -->
</backend_options>
</cache>
<!-- This is a child node of config/global for Magento Enterprise FPC -->
<full_page_cache>
<backend>Cm_Cache_Backend_Redis</backend>
<backend_options>
<server>127.0.0.1</server> <!-- or absolute path to unix socket -->
<port>6379</port>
<persistent></persistent> <!-- Specify unique string to enable
persistent connections. E.g.: sess-db0; bugs with phpredis and php-fpm
are known: https://github.com/nicolasff/phpredis/issues/70 -->
<database>1</database> <!-- Redis database number; protection against
accidental data loss is improved by not sharing databases -->
<password></password> <!-- Specify if your Redis server requires
authentication -->
<force_standalone>0</force_standalone> <!-- 0 for phpredis, 1 for
standalone PHP -->
<connect_retries>1</connect_retries> <!-- Reduces errors due to
random connection failures -->
<lifetimelimit>57600</lifetimelimit> <!-- 16 hours of lifetime for
cache record -->
<compress_data>0</compress_data> <!-- DISABLE compression for
EE FPC since it already uses compression -->
</backend_options>
</full_page_cache>
Even with the removal of the second half of the code (My Magento is
1.7CE), it still doesn't work at all.
I also did not change ports.conf on my server (left it at listen 80
because port forwards to port 80 locally)
I'm quite new to Ubuntu (or at least the terminal and the directories) and
I've already encountered a problem on installing Redis on Magento. I'm
currently running Ubuntu x64 12.04 and I can't seem to get Redis to work
with Magento.
I've tested Magento on localhost using port 80 and Redis cache works fine.
The problem arises when I have to switch the TCP port from 80 to 8000
because my ISP actively blocks these ports to prevent users to setup their
own HTTP, FTP, SMTP servers etc.. I've done port forwarding from 8000 to
80 on my router but the images can't seem to appear to load in the browser
with the URL having a :8000 attached to it. When I remove the code* from
the app/etc/local.xml file, everything becomes fine.
I want to try to enable Redis because I've used it before and it speeds up
my Magento site many times more. What should I do to bridge the 2
solutions together?
FYI, the conflicting code in app/etc/local.xml that is causing the problem is
<!-- This is a child node of config/global -->
<cache>
<backend>Cm_Cache_Backend_Redis</backend>
<backend_options>
<server>127.0.0.1</server> <!-- or absolute path to unix socket -->
<port>6379</port>
<persistent></persistent> <!-- Specify unique string to enable
persistent connections. E.g.: sess-db0; bugs with phpredis and php-fpm
are known: https://github.com/nicolasff/phpredis/issues/70 -->
<database>0</database> <!-- Redis database number; protection against
accidental data loss is improved by not sharing databases -->
<password></password> <!-- Specify if your Redis server requires
authentication -->
<force_standalone>0</force_standalone> <!-- 0 for phpredis, 1 for
standalone PHP -->
<connect_retries>1</connect_retries> <!-- Reduces errors due to
random connection failures; a value of 1 will not retry after the
first failure -->
<read_timeout>10</read_timeout> <!-- Set read timeout
duration; phpredis does not currently support setting read timeouts
-->
<automatic_cleaning_factor>0</automatic_cleaning_factor> <!-- Disabled
by default -->
<compress_data>1</compress_data> <!-- 0-9 for compression level,
recommended: 0 or 1 -->
<compress_tags>1</compress_tags> <!-- 0-9 for compression level,
recommended: 0 or 1 -->
<compress_threshold>20480</compress_threshold> <!-- Strings below
this size will not be compressed -->
<compression_lib>gzip</compression_lib> <!-- Supports gzip, lzf and
snappy -->
</backend_options>
</cache>
<!-- This is a child node of config/global for Magento Enterprise FPC -->
<full_page_cache>
<backend>Cm_Cache_Backend_Redis</backend>
<backend_options>
<server>127.0.0.1</server> <!-- or absolute path to unix socket -->
<port>6379</port>
<persistent></persistent> <!-- Specify unique string to enable
persistent connections. E.g.: sess-db0; bugs with phpredis and php-fpm
are known: https://github.com/nicolasff/phpredis/issues/70 -->
<database>1</database> <!-- Redis database number; protection against
accidental data loss is improved by not sharing databases -->
<password></password> <!-- Specify if your Redis server requires
authentication -->
<force_standalone>0</force_standalone> <!-- 0 for phpredis, 1 for
standalone PHP -->
<connect_retries>1</connect_retries> <!-- Reduces errors due to
random connection failures -->
<lifetimelimit>57600</lifetimelimit> <!-- 16 hours of lifetime for
cache record -->
<compress_data>0</compress_data> <!-- DISABLE compression for
EE FPC since it already uses compression -->
</backend_options>
</full_page_cache>
Even with the removal of the second half of the code (My Magento is
1.7CE), it still doesn't work at all.
I also did not change ports.conf on my server (left it at listen 80
because port forwards to port 80 locally)
XML parsing to fetch the description tab
XML parsing to fetch the description tab
how to fetch xml date in android like
The Fall Preview Event will begin at 7:30pm. We look forward to seeing all
of our friends and clients tomorrow night!]]>
i want to fetch only this line "Your Sole Will be closed tomorrow
Thursday, 8/15, in preparation for our Fall Preview Event. We will re-open
again on Friday 8/16 at noon!"
how can i do
how to fetch xml date in android like
The Fall Preview Event will begin at 7:30pm. We look forward to seeing all
of our friends and clients tomorrow night!]]>
i want to fetch only this line "Your Sole Will be closed tomorrow
Thursday, 8/15, in preparation for our Fall Preview Event. We will re-open
again on Friday 8/16 at noon!"
how can i do
Sunday, 18 August 2013
parent send command line arguments to child
parent send command line arguments to child
I am writing a program that creates a pipe, forks, then the parent sends
the command line arguments to the child one char at a time. The child is
supposed to count them, and then the parent reaps the child and prints out
how many arguments there were. Here is what I have so far:
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <string.h>
int main(int argc, char **argv)
{
pid_t pid;
int status;
int comm[2];
char buffer[BUFSIZ];
// set up pipe
if (pipe(comm)) {
printf("pipe error\n");
return -1;
}
// call fork()
pid = fork();
// fork failed
if (pid < 0) {
printf("fork error %d\n", pid);
return -1;
}
else if (pid == 0) {
// -- running in child process --
int nChars = 0;
close(comm[1]);
// Receive characters from parent process via pipe
// one at a time, and count them.
while(read(comm[0], buffer, sizeof(buffer)) != '\n')
nChars++;
// Return number of characters counted to parent process.
return nChars;
}
else {
// -- running in parent process --
int nChars = 0;
close(comm[0]);
// Send characters from command line arguments starting with
// argv[1] one at a time through pipe to child process.
char endl='\n';
for (int a = 1; a < argc; a++) {
for (int c = 0; c < strlen(argv[a]); c++) {
write(comm[1], &argv[a][c], 1);
}
}
write(comm[1], &endl, 1);
// Wait for child process to return. Reap child process.
// Receive number of characters counted via the value
// returned when the child process is reaped.
waitpid(pid, &status, 0);
printf("child counted %d chars\n", nChars);
return 0;
}
}
It seems to run endlessly. It must be stuck in one of the loops. What is
going wrong?
I am writing a program that creates a pipe, forks, then the parent sends
the command line arguments to the child one char at a time. The child is
supposed to count them, and then the parent reaps the child and prints out
how many arguments there were. Here is what I have so far:
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <string.h>
int main(int argc, char **argv)
{
pid_t pid;
int status;
int comm[2];
char buffer[BUFSIZ];
// set up pipe
if (pipe(comm)) {
printf("pipe error\n");
return -1;
}
// call fork()
pid = fork();
// fork failed
if (pid < 0) {
printf("fork error %d\n", pid);
return -1;
}
else if (pid == 0) {
// -- running in child process --
int nChars = 0;
close(comm[1]);
// Receive characters from parent process via pipe
// one at a time, and count them.
while(read(comm[0], buffer, sizeof(buffer)) != '\n')
nChars++;
// Return number of characters counted to parent process.
return nChars;
}
else {
// -- running in parent process --
int nChars = 0;
close(comm[0]);
// Send characters from command line arguments starting with
// argv[1] one at a time through pipe to child process.
char endl='\n';
for (int a = 1; a < argc; a++) {
for (int c = 0; c < strlen(argv[a]); c++) {
write(comm[1], &argv[a][c], 1);
}
}
write(comm[1], &endl, 1);
// Wait for child process to return. Reap child process.
// Receive number of characters counted via the value
// returned when the child process is reaped.
waitpid(pid, &status, 0);
printf("child counted %d chars\n", nChars);
return 0;
}
}
It seems to run endlessly. It must be stuck in one of the loops. What is
going wrong?
Centering widgets in a dynamic layout?
Centering widgets in a dynamic layout?
I'm using the answer to this SO question here to make a custom image
widget which automatically scales correctly. It works fine but now I am
trying to center the image widget instance at the center of my main
window.
My idea was to create a QHBoxLayout, add the image widget to that, set the
alignment and then add the hBox instance to the ui->verticalLayout.
Doesn't work. The image still displays flush left with the error message:
QLayout: Attempting to add QLayout "" to MainWindow "MainWindow", which
already has a layout
I've tried a few variations on 'setAlignment` but then the image doesn't
appear at all. My simple test code is below.
What am I missing here?
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QPixmap pix;
pix.load("/Users/rise/Desktop/test.jpg");
ImageLabel2* image = new ImageLabel2(this);
image->setPixmap(pix);
QHBoxLayout* hbox = new QHBoxLayout(this);
hbox->addWidget(image);
// hbox->setAlignment(image,Qt::AlignCenter);
hbox->setAlignment(Qt::AlignHCenter);
// ui->verticalLayout->addLayout(hbox);
ui->verticalLayout->addLayout(hbox);
// ui->verticalLayout->addWidget(image);
// ui->verticalLayout->setAlignment(image,Qt::AlignCenter);
// ui->verticalLayout->setAlignment(Qt::AlignHCenter);
}
I'm using the answer to this SO question here to make a custom image
widget which automatically scales correctly. It works fine but now I am
trying to center the image widget instance at the center of my main
window.
My idea was to create a QHBoxLayout, add the image widget to that, set the
alignment and then add the hBox instance to the ui->verticalLayout.
Doesn't work. The image still displays flush left with the error message:
QLayout: Attempting to add QLayout "" to MainWindow "MainWindow", which
already has a layout
I've tried a few variations on 'setAlignment` but then the image doesn't
appear at all. My simple test code is below.
What am I missing here?
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QPixmap pix;
pix.load("/Users/rise/Desktop/test.jpg");
ImageLabel2* image = new ImageLabel2(this);
image->setPixmap(pix);
QHBoxLayout* hbox = new QHBoxLayout(this);
hbox->addWidget(image);
// hbox->setAlignment(image,Qt::AlignCenter);
hbox->setAlignment(Qt::AlignHCenter);
// ui->verticalLayout->addLayout(hbox);
ui->verticalLayout->addLayout(hbox);
// ui->verticalLayout->addWidget(image);
// ui->verticalLayout->setAlignment(image,Qt::AlignCenter);
// ui->verticalLayout->setAlignment(Qt::AlignHCenter);
}
TeXshop can't typeset integral limit
TeXshop can't typeset integral limit
This is very strange: TeXshop can't type a simple integral correctly! The
code
\item $\int_ab f(x) dx$
in a beamer document will produce a caret sign to the right of the
integral sign followed by "b" inside the integral.
I am using TeXshop 3.23 and the latest release of TeX Live. Does this have
to do with character encoding maybe?
This is very strange: TeXshop can't type a simple integral correctly! The
code
\item $\int_ab f(x) dx$
in a beamer document will produce a caret sign to the right of the
integral sign followed by "b" inside the integral.
I am using TeXshop 3.23 and the latest release of TeX Live. Does this have
to do with character encoding maybe?
How to get radio button values in Beans
How to get radio button values in Beans
I'm new to to server side coding and this happens to be my first project.
I have the following code in a jsp page. Now i forward the form to a
struts bean but i can't get the values of each radio button. I named them
but the name is appended with random number. How do i get these values in
the bean and check if the checked radio button is correct answer or not?
Statement st = DBConnection.DBConnection.DBConnect();
String query = "SELECT * FROM "+table_name+" ORDER BY RAND()
LIMIT 5";
ResultSet rs = st.executeQuery(query);
int i = 1;
while(rs.next()){
int q_no = rs.getInt(1);
String ques = rs.getString(2);
String opt1 = rs.getString(3);
String opt2 = rs.getString(4);
String opt3 = rs.getString(5);
String opt4 = rs.getString(6);
%>
<%=i%>. <%=ques%><br/>
<input type="radio" name="ans<%=q_no%>"
value="<%=opt1%>"/><%=opt1%><br/>
<input type="radio" name="ans<%=q_no%>"
value="<%=opt2%>"/><%=opt2%><br/>
<input type="radio" name="ans<%=q_no%>"
value="<%=opt3%>"/><%=opt3%><br/>
<input type="radio" name="ans<%=q_no%>"
value="<%=opt4%>"/><%=opt4%><br/>
<br/><br/>
<%
i++;
}
I'm new to to server side coding and this happens to be my first project.
I have the following code in a jsp page. Now i forward the form to a
struts bean but i can't get the values of each radio button. I named them
but the name is appended with random number. How do i get these values in
the bean and check if the checked radio button is correct answer or not?
Statement st = DBConnection.DBConnection.DBConnect();
String query = "SELECT * FROM "+table_name+" ORDER BY RAND()
LIMIT 5";
ResultSet rs = st.executeQuery(query);
int i = 1;
while(rs.next()){
int q_no = rs.getInt(1);
String ques = rs.getString(2);
String opt1 = rs.getString(3);
String opt2 = rs.getString(4);
String opt3 = rs.getString(5);
String opt4 = rs.getString(6);
%>
<%=i%>. <%=ques%><br/>
<input type="radio" name="ans<%=q_no%>"
value="<%=opt1%>"/><%=opt1%><br/>
<input type="radio" name="ans<%=q_no%>"
value="<%=opt2%>"/><%=opt2%><br/>
<input type="radio" name="ans<%=q_no%>"
value="<%=opt3%>"/><%=opt3%><br/>
<input type="radio" name="ans<%=q_no%>"
value="<%=opt4%>"/><%=opt4%><br/>
<br/><br/>
<%
i++;
}
emulator: ERROR: No initial system image for this configuration
emulator: ERROR: No initial system image for this configuration
During launching the AVD, I am getting error as "emulator: ERROR: No
initial system image for this configuration!". I have downloaded the sdk
ADT bundle for window from http://developer.android.com/sdk/index. Please
help in removing the error.
During launching the AVD, I am getting error as "emulator: ERROR: No
initial system image for this configuration!". I have downloaded the sdk
ADT bundle for window from http://developer.android.com/sdk/index. Please
help in removing the error.
python can't find file it just made
python can't find file it just made
My program cannot find the path that it just made, the program is for
sorting files in the download folder. If it finds a new type of file it
should make a folder for that file type.
import os
FileList = os.listdir("/sdcard/Download/")
for File in FileList:
#print File
extension = ''.join(os.path.splitext(File)[1])
ext = extension.strip('.')
if os.path.exists("/mnt/external_sd/Download/" + ext):
Data = open("/sdcard/Download/" + File, "r").read()
file("/mnt/external_sd/" + ext + "/" + File, "w").write(Data)
elif os.path.exists("/mnt/external_sd/Download/" + ext) != True:
os.makedirs("/mnt/external_sd/Download/" + ext)
Data = open("/sdcard/Download/" + File, "r").read()
file("/mnt/external_sd/" + ext + "/" + File, "w").write(Data)
My program cannot find the path that it just made, the program is for
sorting files in the download folder. If it finds a new type of file it
should make a folder for that file type.
import os
FileList = os.listdir("/sdcard/Download/")
for File in FileList:
#print File
extension = ''.join(os.path.splitext(File)[1])
ext = extension.strip('.')
if os.path.exists("/mnt/external_sd/Download/" + ext):
Data = open("/sdcard/Download/" + File, "r").read()
file("/mnt/external_sd/" + ext + "/" + File, "w").write(Data)
elif os.path.exists("/mnt/external_sd/Download/" + ext) != True:
os.makedirs("/mnt/external_sd/Download/" + ext)
Data = open("/sdcard/Download/" + File, "r").read()
file("/mnt/external_sd/" + ext + "/" + File, "w").write(Data)
Saturday, 17 August 2013
Splash image appears as icon in iPad
Splash image appears as icon in iPad
I have a weird issue, which many of you might not even have thought of!
An application I developed, works fine on both iPhone and iPad, but the
icon appears perfectly fine on iPhone, whereas on the iPad, the splash
image scales down and shows up as icon.
I'm not sure what's going on. I tried checking on and off Prerendered
flag, but no use.
Any help would be appreciated.
Thanks.
I have a weird issue, which many of you might not even have thought of!
An application I developed, works fine on both iPhone and iPad, but the
icon appears perfectly fine on iPhone, whereas on the iPad, the splash
image scales down and shows up as icon.
I'm not sure what's going on. I tried checking on and off Prerendered
flag, but no use.
Any help would be appreciated.
Thanks.
how to convert time to words in php
how to convert time to words in php
I have this HH:mm:ss total time format and i want to convert it to words e.g.
01:00:00 = 1hour
00:30:00 = 30minutes
00:00:30 = 30seconds
01:30:30 = 1hr 30minutes 30seconds
Any Help?
I have this HH:mm:ss total time format and i want to convert it to words e.g.
01:00:00 = 1hour
00:30:00 = 30minutes
00:00:30 = 30seconds
01:30:30 = 1hr 30minutes 30seconds
Any Help?
JSP read local JSON (cache?)
JSP read local JSON (cache?)
I am coding something with JSP v5, Latest GlassFish/Netbeans.
I am using Jackson 1.9.1,
I am reading a local JSON file, but if I modify the JSON file the changes
are not reflected in my web site, of course, I tried to use hard reload in
my browser. I think is a cache problem (server side, could not find
anything online), if I recompile my sources I can see the changes
reflected,
This is the code I am using.
ObjectMapper in_mapper = new ObjectMapper();
JsonNode rootNode = in_mapper.readTree(new BufferedReader(new
FileReader("c:\\file.json")));
I even tried this
ObjectMapper in_mapper = new ObjectMapper();
JsonNode rootNode = in_mapper.readTree(new File("c:\\file.json"));
And the behavior is the same.
I am coding something with JSP v5, Latest GlassFish/Netbeans.
I am using Jackson 1.9.1,
I am reading a local JSON file, but if I modify the JSON file the changes
are not reflected in my web site, of course, I tried to use hard reload in
my browser. I think is a cache problem (server side, could not find
anything online), if I recompile my sources I can see the changes
reflected,
This is the code I am using.
ObjectMapper in_mapper = new ObjectMapper();
JsonNode rootNode = in_mapper.readTree(new BufferedReader(new
FileReader("c:\\file.json")));
I even tried this
ObjectMapper in_mapper = new ObjectMapper();
JsonNode rootNode = in_mapper.readTree(new File("c:\\file.json"));
And the behavior is the same.
CoffeeScript - detect if current scroll position is below div
CoffeeScript - detect if current scroll position is below div
I would like to detect when the user scrolls past a certain point in the
window.
[Meta]
X
scroll below = alert()
I'm quite new to CoffeeScript, so any help would be great!
What I currently have is this:
$("#area_1").bind('scroll', ->
scrollPosition = $(this).scrollTop() + $(this).outerHeight()
divTotalHeight = $(this)[0].scrollHeight()
if (scrollPosition >= divTotalHeight)
alert('end reached')
)
And no alert is showing up. Any tips?
I would like to detect when the user scrolls past a certain point in the
window.
[Meta]
X
scroll below = alert()
I'm quite new to CoffeeScript, so any help would be great!
What I currently have is this:
$("#area_1").bind('scroll', ->
scrollPosition = $(this).scrollTop() + $(this).outerHeight()
divTotalHeight = $(this)[0].scrollHeight()
if (scrollPosition >= divTotalHeight)
alert('end reached')
)
And no alert is showing up. Any tips?
How to implement Custom OpenId Provider for CustomOpenIdClient
How to implement Custom OpenId Provider for CustomOpenIdClient
I am very new to the DotNetOpenAuth and have come across various examples
which lets you login through various existing open id providers like
Google, StackOverFlow, Yahoo etc.
I have written a CustomOpenIdClient to provide some extra data and all,
but I am not able to understand on how do I write a Custom OpenId Provider
on local host ?
I believe anyone can become an Open Id Provider but the question remains
how do I build one in MVC ?
I am very new to the DotNetOpenAuth and have come across various examples
which lets you login through various existing open id providers like
Google, StackOverFlow, Yahoo etc.
I have written a CustomOpenIdClient to provide some extra data and all,
but I am not able to understand on how do I write a Custom OpenId Provider
on local host ?
I believe anyone can become an Open Id Provider but the question remains
how do I build one in MVC ?
Save Relation between User and Entity in ASP.NET MVC4
Save Relation between User and Entity in ASP.NET MVC4
I have an Exercise entity defined in my ASP.NET MVC4 Web Application. I'm
using the Form Authentication with the default AccountModels.cs class.
I have class which looks like
public class Exercise
{
private DateTime _DateCreated = DateTime.Now;
private UserProfile _Teacher;
public int Id{ get; set; }
public string Question { get; set; }
public int Anwser { get; set; }
public string Category { get; set; }
public int maxNbrOfAttempts { get; set; }
public string Hints { get; set; }
public virtual ICollection<Quiz> Quizzes { get; set; }
public DateTime Date
{
get { return _DateCreated; }
set { _DateCreated = value; }
}
public UserProfile Author
{
get { return _Teacher; }
set { _Teacher = value; }
}
}
Am I using the UserProfile correctly to link between an Exercise and a
logged in user? How can I get the current UserProfile in my controller?
I have an Exercise entity defined in my ASP.NET MVC4 Web Application. I'm
using the Form Authentication with the default AccountModels.cs class.
I have class which looks like
public class Exercise
{
private DateTime _DateCreated = DateTime.Now;
private UserProfile _Teacher;
public int Id{ get; set; }
public string Question { get; set; }
public int Anwser { get; set; }
public string Category { get; set; }
public int maxNbrOfAttempts { get; set; }
public string Hints { get; set; }
public virtual ICollection<Quiz> Quizzes { get; set; }
public DateTime Date
{
get { return _DateCreated; }
set { _DateCreated = value; }
}
public UserProfile Author
{
get { return _Teacher; }
set { _Teacher = value; }
}
}
Am I using the UserProfile correctly to link between an Exercise and a
logged in user? How can I get the current UserProfile in my controller?
jQuery fadeIn or animate when scrolled past a certain point
jQuery fadeIn or animate when scrolled past a certain point
So I have a navigation somewhere on my header, when a user scroll pass the
navigation I want to minimize it and fadeIn or animate it back as a fixed
navigation to the top of page, I made it work with the following jquery
code but the issue is that it does the job with css, if I try to replace
it with animate, it keeps repeating itself for each pixel it passes.
here is the code:
function fixDiv() {
var $cache = $('.stickynav');
if ($(window).scrollTop() > 127)
$cache.css({'position': 'fixed','top': '0px','height': '40px'}),
$('#logo img').css({'height': '30px', 'position': 'relative', 'bottom':
'10px'}),
$('#main_menu_container').css({'bottom': '40px'});
else
$cache.css({'position': 'relative','top': '0px', 'height': 'auto'}),
$('#logo img').css({'height': 'auto', 'position': 'auto', 'bottom': 'auto'}),
$('#main_menu_container').css({'bottom': 'auto'});
}
$(window).scroll(fixDiv);
fixDiv();
So I have a navigation somewhere on my header, when a user scroll pass the
navigation I want to minimize it and fadeIn or animate it back as a fixed
navigation to the top of page, I made it work with the following jquery
code but the issue is that it does the job with css, if I try to replace
it with animate, it keeps repeating itself for each pixel it passes.
here is the code:
function fixDiv() {
var $cache = $('.stickynav');
if ($(window).scrollTop() > 127)
$cache.css({'position': 'fixed','top': '0px','height': '40px'}),
$('#logo img').css({'height': '30px', 'position': 'relative', 'bottom':
'10px'}),
$('#main_menu_container').css({'bottom': '40px'});
else
$cache.css({'position': 'relative','top': '0px', 'height': 'auto'}),
$('#logo img').css({'height': 'auto', 'position': 'auto', 'bottom': 'auto'}),
$('#main_menu_container').css({'bottom': 'auto'});
}
$(window).scroll(fixDiv);
fixDiv();
Thursday, 8 August 2013
Code setting item price to 0
Code setting item price to 0
alright, these two functions refuse to work properly for some reason and i
cannot figure out why. They work fine if used outside of an active
database (I'ved tested it and am testing it right now) but for some reason
the second they're getting their information from the database, they zero
out the price that's supposed to be updated; eg where a price should go up
to say, 20 dollars from 4, it goes to zero and then next time it updates
goes to the next number in the line.
private function updatePrice($iid, $price, $purchased)
{
if($price >= 0)
{
$price = abs($price);
}
else
{
$price = $this->getItemStats($iid);
$price = abs($price['base']);
}
$sql = "UPDATE store SET item_price = :price, available =
available-:purchased WHERE iid = :iid";
$que = $this->db->prepare($sql);
$que->bindParam('price', $price);
$que->bindParam('iid', $iid);
$que->bindParam('purchased', $purchased);
try{$que->execute(); if($que) { return true; } else { echo "FUCK";
exit; } }catch(PDOException $e){echo $e->getMessage(); exit;}
}
function getSupplyDemand($purchased, $iid)
{
$sql = "SELECT available, number, item_base_price, iid FROM store
WHERE iid = :iid";
$que = $this->db->prepare($sql);
$que->bindParam('iid', $iid);
try{ $que->execute();
if($que)
{
while($row = $que->fetch())
{
$Quantity =$row[0];
$Supply = $row[1];
$price = $row[2];
$iid = $row[3];
$price = abs(($price * $purchased)*($Quantity -
$Supply)/.25);
if($this->updatePrice($iid, $price, $purchased))
{
return true;
}
else
{
echo "Somethign went wrong";
exit;
}
}
}
}catch(PDOException $e){}
}
alright, these two functions refuse to work properly for some reason and i
cannot figure out why. They work fine if used outside of an active
database (I'ved tested it and am testing it right now) but for some reason
the second they're getting their information from the database, they zero
out the price that's supposed to be updated; eg where a price should go up
to say, 20 dollars from 4, it goes to zero and then next time it updates
goes to the next number in the line.
private function updatePrice($iid, $price, $purchased)
{
if($price >= 0)
{
$price = abs($price);
}
else
{
$price = $this->getItemStats($iid);
$price = abs($price['base']);
}
$sql = "UPDATE store SET item_price = :price, available =
available-:purchased WHERE iid = :iid";
$que = $this->db->prepare($sql);
$que->bindParam('price', $price);
$que->bindParam('iid', $iid);
$que->bindParam('purchased', $purchased);
try{$que->execute(); if($que) { return true; } else { echo "FUCK";
exit; } }catch(PDOException $e){echo $e->getMessage(); exit;}
}
function getSupplyDemand($purchased, $iid)
{
$sql = "SELECT available, number, item_base_price, iid FROM store
WHERE iid = :iid";
$que = $this->db->prepare($sql);
$que->bindParam('iid', $iid);
try{ $que->execute();
if($que)
{
while($row = $que->fetch())
{
$Quantity =$row[0];
$Supply = $row[1];
$price = $row[2];
$iid = $row[3];
$price = abs(($price * $purchased)*($Quantity -
$Supply)/.25);
if($this->updatePrice($iid, $price, $purchased))
{
return true;
}
else
{
echo "Somethign went wrong";
exit;
}
}
}
}catch(PDOException $e){}
}
FTP connection is not allowed by server name
FTP connection is not allowed by server name
Today when I was testing the ftp connection to remove server it was
printing an error saying Host not found.
At client ftp program I have changed the ftp server from ftp.example.com
to server ip adress and as result it works. Any advice on why it works
with ip and not by ftp server name?
Troubleshooting:
pureFtp services is up and running
firewall allows port 21
Centos 4 is the OS of the remote machine
Today when I was testing the ftp connection to remove server it was
printing an error saying Host not found.
At client ftp program I have changed the ftp server from ftp.example.com
to server ip adress and as result it works. Any advice on why it works
with ip and not by ftp server name?
Troubleshooting:
pureFtp services is up and running
firewall allows port 21
Centos 4 is the OS of the remote machine
springseed not working after update
springseed not working after update
After checking other bug reporst I've found this error with the newest
version of springseed. I have followed other questions/answers but this
problems seems to be different.
Here is what I get after running springseed from terminal.
$ /opt/springseed/springseed-bin /opt/springseed/nw: error while loading
shared libraries: libudev.so.0: cannot open shared object file: No such
file or directory
I have the newest udev installed, so the error is strange. I work on
ubuntu 13.04. I have tried to change springseed.desktop as in other posts.
No results other than this libudev error.
After checking other bug reporst I've found this error with the newest
version of springseed. I have followed other questions/answers but this
problems seems to be different.
Here is what I get after running springseed from terminal.
$ /opt/springseed/springseed-bin /opt/springseed/nw: error while loading
shared libraries: libudev.so.0: cannot open shared object file: No such
file or directory
I have the newest udev installed, so the error is strange. I work on
ubuntu 13.04. I have tried to change springseed.desktop as in other posts.
No results other than this libudev error.
Cant find my mistake
Cant find my mistake
The compiler keeps saying this "IndentationError: expected an indented
block", but i cant find my mistake. PLease help a python newbie.
class BackgroundUploadFTP(threading.Thread):
def __init__ (queueFTP):
def run(queueFTP):
while True :
if(len(queueFTP)!= 0):
meinftp = ftplib.FTP("altes-vennhaus.de")
meinftp.login("altes-vennhaus.de","benjamin")
directory = '/bilder' #ftp-Hauptverzeichnis
meinftp.cwd(directory) #Wir nutzen das Hauptverzeichnis des
ftp-Servers.
meinftp.storbinary('Stor '+'altes-vennhaus.jpg',
queueFTP.popleft()) #Es wird die Datei mit
# dem Namen test.txt aus dem Hauptverzeichnis des Servers in
die lokale
# Datei mit dem Namen test2.txt im Verzeichnis E:/ geschrieben.
file.close()
meinftp.quit() #"höfliches" Trennen meinerseits der
ftp-Verbindung
The compiler keeps saying this "IndentationError: expected an indented
block", but i cant find my mistake. PLease help a python newbie.
class BackgroundUploadFTP(threading.Thread):
def __init__ (queueFTP):
def run(queueFTP):
while True :
if(len(queueFTP)!= 0):
meinftp = ftplib.FTP("altes-vennhaus.de")
meinftp.login("altes-vennhaus.de","benjamin")
directory = '/bilder' #ftp-Hauptverzeichnis
meinftp.cwd(directory) #Wir nutzen das Hauptverzeichnis des
ftp-Servers.
meinftp.storbinary('Stor '+'altes-vennhaus.jpg',
queueFTP.popleft()) #Es wird die Datei mit
# dem Namen test.txt aus dem Hauptverzeichnis des Servers in
die lokale
# Datei mit dem Namen test2.txt im Verzeichnis E:/ geschrieben.
file.close()
meinftp.quit() #"höfliches" Trennen meinerseits der
ftp-Verbindung
python - iterating over a subset of a list of tuples
python - iterating over a subset of a list of tuples
Lets say I have a list of tuples as follows
l = [(4,1), (5,1), (3,2), (7,1), (6,0)]
I would like to iterate over the items where the 2nd element in the tuple
is 1?
I can do it using an if condition in the loop, but I was hoping there will
a be amore pythonic way of doing it?
Thanks
Lets say I have a list of tuples as follows
l = [(4,1), (5,1), (3,2), (7,1), (6,0)]
I would like to iterate over the items where the 2nd element in the tuple
is 1?
I can do it using an if condition in the loop, but I was hoping there will
a be amore pythonic way of doing it?
Thanks
Can regular expression match this pattern?
Can regular expression match this pattern?
I want to match [#ABABAB]blah blah blah[/#ABABAB]
but I don't want to match [#ABABAB]blah blah blah[/#000000]
the ABABAB and 000000 are hex color code.
Thank you
I want to match [#ABABAB]blah blah blah[/#ABABAB]
but I don't want to match [#ABABAB]blah blah blah[/#000000]
the ABABAB and 000000 are hex color code.
Thank you
Number of Ranges that lie completely in a particular Range
Number of Ranges that lie completely in a particular Range
Let us say we have n ranges each specified by
[l_i,r_i] where 1<=i<=n
And we have a query of type [L,R] in which we have to find the number of
ranges among those n ranges that lie completely in the given range i.e.
[L,R]
Example:
n ranges are:
here n is 2.
2 4
3 3
for query 3 5, output should be 1.
for query 2 5 output should be 2.
I know method for O(m*n), where n is number of ranges and m is number of
queries, but feels like there must be a more efficient implementation.
Let us say we have n ranges each specified by
[l_i,r_i] where 1<=i<=n
And we have a query of type [L,R] in which we have to find the number of
ranges among those n ranges that lie completely in the given range i.e.
[L,R]
Example:
n ranges are:
here n is 2.
2 4
3 3
for query 3 5, output should be 1.
for query 2 5 output should be 2.
I know method for O(m*n), where n is number of ranges and m is number of
queries, but feels like there must be a more efficient implementation.
How do I combine my game.exe and "media" folder into one .exe file?
How do I combine my game.exe and "media" folder into one .exe file?
I've been searching for this for ages but no solutions. It's simple. I've
created a C++ game. So I have a game.exe and next to it I have a folder
named "media" from where the game takes all the images and sounds it
needs. Now obviously when other people play the game I don't want them to
see the media folder. I want to combine them into one .exe file. Can
someone PLEASE explain to me how to do this like I'm five?
I've been searching for this for ages but no solutions. It's simple. I've
created a C++ game. So I have a game.exe and next to it I have a folder
named "media" from where the game takes all the images and sounds it
needs. Now obviously when other people play the game I don't want them to
see the media folder. I want to combine them into one .exe file. Can
someone PLEASE explain to me how to do this like I'm five?
Wednesday, 7 August 2013
Creating sticky-notes ( post-it )
Creating sticky-notes ( post-it )
I am designing a web page.
And i want to use sticky-notes (post-it) in my page. Where, each
sticky-note is added when we click an add button... Color of sticky notes
must change randomly, and it must be tilted and must have some hover
effect.
How can i do that ? Only CSS and HTML must be used.
I tried the code which i got from a website
http://net.tutsplus.com/tutorials/html-css-techniques/create-a-sticky-note-effect-in-5-easy-steps-with-css3-and-html5/
But, i had some part of my website as list..so when i used this code, it
also make the list items as sticky note.. i want to give property only to
a div
Thanks in advance..
I am designing a web page.
And i want to use sticky-notes (post-it) in my page. Where, each
sticky-note is added when we click an add button... Color of sticky notes
must change randomly, and it must be tilted and must have some hover
effect.
How can i do that ? Only CSS and HTML must be used.
I tried the code which i got from a website
http://net.tutsplus.com/tutorials/html-css-techniques/create-a-sticky-note-effect-in-5-easy-steps-with-css3-and-html5/
But, i had some part of my website as list..so when i used this code, it
also make the list items as sticky note.. i want to give property only to
a div
Thanks in advance..
ssh-agent not getting set up
ssh-agent not getting set up
I set up a new user account for a friend on Kubuntu 12.04. When he uses
ssh he gets this error:
Could not open a connection to your authentication agent
We're running ssh in some bash scripts.
After looking around at the wide variety of things that can lead to that
error, I came across this solution:
$ eval `ssh-agent -s`
$ ssh-add ~/.ssh/some_id_rsa
Then he can run the ssh commands (and bash scripts) as expected.
I want to know how to set up his computer so he doesn't have to run those
two commands. I do not need to run them on my computer. So far I am not
seeing what is different between our machines.
I see this info in the man page, but it does not tell me how Ubuntu is
normally setting up the agent automatically or what is happening on my
friend's machine so that this is not working for him.
There are two main ways to get an agent set up: The first is that the
agent starts a new subcommand into which some environment variables are
exported, eg ssh-agent xterm &. The second is that the agent prints the
needed shell commands (either sh(1) or csh(1) syntax can be generated)
which can be evalled in the calling shell, eg eval �'ssh-agent
-s�' for
Bourne-type shells such as sh(1) or ksh(1) and eval �'ssh-agent
-c�' for
csh(1) and derivatives.
I set up a new user account for a friend on Kubuntu 12.04. When he uses
ssh he gets this error:
Could not open a connection to your authentication agent
We're running ssh in some bash scripts.
After looking around at the wide variety of things that can lead to that
error, I came across this solution:
$ eval `ssh-agent -s`
$ ssh-add ~/.ssh/some_id_rsa
Then he can run the ssh commands (and bash scripts) as expected.
I want to know how to set up his computer so he doesn't have to run those
two commands. I do not need to run them on my computer. So far I am not
seeing what is different between our machines.
I see this info in the man page, but it does not tell me how Ubuntu is
normally setting up the agent automatically or what is happening on my
friend's machine so that this is not working for him.
There are two main ways to get an agent set up: The first is that the
agent starts a new subcommand into which some environment variables are
exported, eg ssh-agent xterm &. The second is that the agent prints the
needed shell commands (either sh(1) or csh(1) syntax can be generated)
which can be evalled in the calling shell, eg eval �'ssh-agent
-s�' for
Bourne-type shells such as sh(1) or ksh(1) and eval �'ssh-agent
-c�' for
csh(1) and derivatives.
Loop through ActiveRecord::Associations::CollectionProxy with each
Loop through ActiveRecord::Associations::CollectionProxy with each
I have the following models set up with active record 4 (mapping a legacy
database)
class Page < ActiveRecord::Base
self.table_name = "page"
self.primary_key = "page_id"
has_many :content, foreign_key: 'content_page_id', class_name:
'PageContent'
end
class PageContent < ActiveRecord::Base
self.table_name = "page_content"
self.primary_key = "content_id"
belongs_to :pages, foreign_key: 'page_id', class_name: 'Page'
end
The following works fine....
page = Page.first
page.content.first.content_id
=> 17
page.content.second.content_id
=> 18
however i want to be able to loop though all the items like so
page.content.each do |item|
item.content_id
end
but it simply returns the whole collection not the individual field
=> [#<PageContent content_id: 17, content_text: 'hello', content_order:
1>, #<PageContent content_id: 18, content_text: 'world', content_order:
2>]
appears it is a ActiveRecord::Associations::CollectionProxy
page.content.class
=>
ActiveRecord::Associations::CollectionProxy::ActiveRecord_Associations_CollectionProxy_PageContent
anyone got any ideas?
cheers
I have the following models set up with active record 4 (mapping a legacy
database)
class Page < ActiveRecord::Base
self.table_name = "page"
self.primary_key = "page_id"
has_many :content, foreign_key: 'content_page_id', class_name:
'PageContent'
end
class PageContent < ActiveRecord::Base
self.table_name = "page_content"
self.primary_key = "content_id"
belongs_to :pages, foreign_key: 'page_id', class_name: 'Page'
end
The following works fine....
page = Page.first
page.content.first.content_id
=> 17
page.content.second.content_id
=> 18
however i want to be able to loop though all the items like so
page.content.each do |item|
item.content_id
end
but it simply returns the whole collection not the individual field
=> [#<PageContent content_id: 17, content_text: 'hello', content_order:
1>, #<PageContent content_id: 18, content_text: 'world', content_order:
2>]
appears it is a ActiveRecord::Associations::CollectionProxy
page.content.class
=>
ActiveRecord::Associations::CollectionProxy::ActiveRecord_Associations_CollectionProxy_PageContent
anyone got any ideas?
cheers
Subscribe to:
Comments (Atom)