How to refer to figure I clicked to change its properties and move it?
I have a figure in canvas in WPF application. This figure is generated by
program (I click a button and then a figure appears). How to order the
Figure_MouseLeftButtonDown function to change some properties of THIS
figure? Also I want to move this figure by dragging. Now I have something
like this: var ell = new Ellipse() { Name = "FirstEllipse", Width = 150,
Height = 100, Margin = new Thickness(200, 150, 0, 0), Fill = Brushes.Red
}; ell.MouseLeftButtonDown += Ellipse_MouseLeftButtonDown;
canvas.Children.Add(ell); private void Figure_MouseLeftButtonDown(object
sender, MouseButtonEventArgs e) { sender.SetValue(Ellipse.FillProperty,
Brushes.Aquamarine);}
Thursday, 3 October 2013
Wednesday, 2 October 2013
needed to remove image extension using htaccess
needed to remove image extension using htaccess
I need to change or redirect the "example.com/photos/logo.jpg" to
"example.com/photos/logo" when user comes from google image search.
Therefore I've used RewriteCond %{REQUEST_URI}
photos/.*.(gif|jpg|jpeg|png)$ [NC] RewriteCond %{HTTP_REFERER}
^http://www.google.[a-z]{2,4}(.[a-z]{2,4})?/url\?.*$ [NC,OR] RewriteCond
%{HTTP_REFERER} ^http://www.bing.com/images/search?q=\?.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} !^http://example.com/.*$ [NC] RewriteCond
%{HTTP_USER_AGENT} !(.bot.|slurp) [NC] RewriteRule ^gallery/(.*) /$1
[L,R=301]
Thank you.
I need to change or redirect the "example.com/photos/logo.jpg" to
"example.com/photos/logo" when user comes from google image search.
Therefore I've used RewriteCond %{REQUEST_URI}
photos/.*.(gif|jpg|jpeg|png)$ [NC] RewriteCond %{HTTP_REFERER}
^http://www.google.[a-z]{2,4}(.[a-z]{2,4})?/url\?.*$ [NC,OR] RewriteCond
%{HTTP_REFERER} ^http://www.bing.com/images/search?q=\?.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} !^http://example.com/.*$ [NC] RewriteCond
%{HTTP_USER_AGENT} !(.bot.|slurp) [NC] RewriteRule ^gallery/(.*) /$1
[L,R=301]
Thank you.
Approach while learning Algorithms
Approach while learning Algorithms
I am learning algorithms and came to this Hanoi Tower. I know how to do
that practically. But I am unable to code it. I haven't read the given
code yet. I am trying it first myself. What should be my approach-keep
trying or read the given code or something else?
Should this approach be followed with all the algorithms?
I am learning algorithms and came to this Hanoi Tower. I know how to do
that practically. But I am unable to code it. I haven't read the given
code yet. I am trying it first myself. What should be my approach-keep
trying or read the given code or something else?
Should this approach be followed with all the algorithms?
FFmpeg on Android - Unable to find a suitable output format
FFmpeg on Android - Unable to find a suitable output format
I want to reduce the resolution of a video before edit it, so I´m using
ffmpeg on android. I´m using the executable/binary file of ffmpeg and I´m
calling my ffmpeg commands like that:
./ffmpeg -i /sdcard/dcim/video.mp4 -s 320x240 -r 10 -y /sdcard/output.mp4
But when I try this command I get this error:
Unable to find a suitable output format for /sdcard/output.mp4
This is the output when I use the adb shell:
The only action I have been able to do is to extract the audio of a video
and save it as a mp3 using this command:
./ffmpeg -i /sdcard/dcim/video.mp4 -y /sdcard/output.mp3
That works well but this is the only action I can do... Any idea of why I
can´t convert a video? (I can´t copy it too) Thanks!!
I want to reduce the resolution of a video before edit it, so I´m using
ffmpeg on android. I´m using the executable/binary file of ffmpeg and I´m
calling my ffmpeg commands like that:
./ffmpeg -i /sdcard/dcim/video.mp4 -s 320x240 -r 10 -y /sdcard/output.mp4
But when I try this command I get this error:
Unable to find a suitable output format for /sdcard/output.mp4
This is the output when I use the adb shell:
The only action I have been able to do is to extract the audio of a video
and save it as a mp3 using this command:
./ffmpeg -i /sdcard/dcim/video.mp4 -y /sdcard/output.mp3
That works well but this is the only action I can do... Any idea of why I
can´t convert a video? (I can´t copy it too) Thanks!!
Collect a specific text string from a very large text string in SQL Server
Collect a specific text string from a very large text string in SQL Server
I have a very large text string in a column (column name: path) of a table
(table name: KYC_Path). The table basically contains very large text
string of image paths from which I need to extract a specific number (file
number). The text strings look like this:
F:\Original\15561 done\sohan1
15561\output_after_name_mapping\01710043429(1).jpg
T:\ALL BACKUP\BACK UP 1TB(SERVER)\ALL SCANNED FILES(sohan)\01832876657
(1).JPG
T:\ALL BACKUP\form 2TB passport HDD\All backup\Afren\24313\24313
Nupur_1box 651\output_after_name_mapping\01918082763(1).jpg
T:\ALL BACKUP\zaman all scan\16830 noboni1
box548\output_after_name_mapping\01823152145(1).jpg
I need to collect just following numbers (file name with out the (1).jpg
part), so that my new column will look like this:
01710043429
01832876657
01918082763
01823152145
I have already devised a method where use following formula:
select (right ([path],18)) as 'wallet_path', [path] into KYCPathNew
from [dbo].[KYCPath]
select (left ([wallet_path],11)) as 'wallet_path_new', [path] into
KYCPathNew2
from [dbo].[KYCPathNew]
However that gives some issues to some rows where file name do not come
correctly due to spaces between numbers (01823152145) and file extension
((1).jpg). And misses one or two characters from the file name.
Is there any other way so that I can collect all the file names more
efficiently? Can I make SQL Server find the last back slash and then take
11 digits from there? How?
I have a very large text string in a column (column name: path) of a table
(table name: KYC_Path). The table basically contains very large text
string of image paths from which I need to extract a specific number (file
number). The text strings look like this:
F:\Original\15561 done\sohan1
15561\output_after_name_mapping\01710043429(1).jpg
T:\ALL BACKUP\BACK UP 1TB(SERVER)\ALL SCANNED FILES(sohan)\01832876657
(1).JPG
T:\ALL BACKUP\form 2TB passport HDD\All backup\Afren\24313\24313
Nupur_1box 651\output_after_name_mapping\01918082763(1).jpg
T:\ALL BACKUP\zaman all scan\16830 noboni1
box548\output_after_name_mapping\01823152145(1).jpg
I need to collect just following numbers (file name with out the (1).jpg
part), so that my new column will look like this:
01710043429
01832876657
01918082763
01823152145
I have already devised a method where use following formula:
select (right ([path],18)) as 'wallet_path', [path] into KYCPathNew
from [dbo].[KYCPath]
select (left ([wallet_path],11)) as 'wallet_path_new', [path] into
KYCPathNew2
from [dbo].[KYCPathNew]
However that gives some issues to some rows where file name do not come
correctly due to spaces between numbers (01823152145) and file extension
((1).jpg). And misses one or two characters from the file name.
Is there any other way so that I can collect all the file names more
efficiently? Can I make SQL Server find the last back slash and then take
11 digits from there? How?
Tuesday, 1 October 2013
About SQL SERVER LEFT JOIN and Group by
About SQL SERVER LEFT JOIN and Group by
I have two tables,Blog table has a FK BlogTagID column point to BlogTag
table:
Blog table:
BlogID BlogTagID BlogTitle
1 2 test1
2 1 test2
3 2 test3
BlogTag table:
BlogTagID BlogTagName
1 JAVA
2 .NET
3 PHP
I would like to get the result:
BlogTagName count
JAVA 1
.NET 2
PHP 0
How to get this?Thank you very much!
I have two tables,Blog table has a FK BlogTagID column point to BlogTag
table:
Blog table:
BlogID BlogTagID BlogTitle
1 2 test1
2 1 test2
3 2 test3
BlogTag table:
BlogTagID BlogTagName
1 JAVA
2 .NET
3 PHP
I would like to get the result:
BlogTagName count
JAVA 1
.NET 2
PHP 0
How to get this?Thank you very much!
Hide/unhide table row given the row index and table ID
Hide/unhide table row given the row index and table ID
Currently I have this code to delete a table row:
var remove = document.getElementById(rid);
if(remove!=null){
var v = remove.parentNode.parentNode.rowIndex;
document.getElementById(tid).deleteRow(v);
}
However, instead of delete it, I'd just like to hide it. What's a good way
to do this?
Also, in the future, I'm going to want to 'unhide' it at user request, so
how can I check if it has been hidden? The if(remove!=null) is what
checked if a row was already removed, so I'd need something similar. If
the row is hidden, I would unhide it.
Thank you for your time.
Currently I have this code to delete a table row:
var remove = document.getElementById(rid);
if(remove!=null){
var v = remove.parentNode.parentNode.rowIndex;
document.getElementById(tid).deleteRow(v);
}
However, instead of delete it, I'd just like to hide it. What's a good way
to do this?
Also, in the future, I'm going to want to 'unhide' it at user request, so
how can I check if it has been hidden? The if(remove!=null) is what
checked if a row was already removed, so I'd need something similar. If
the row is hidden, I would unhide it.
Thank you for your time.
PS6000 showing packet errors but no errors appear on the switch
PS6000 showing packet errors but no errors appear on the switch
We have a loaned PS6000E SAN that we are using to relocate our iSCSI LUNs
off our current PS4000E SAN to upgrade it from Seagate Moose drives under
a proactive replacement plan by Dell. We've connected it up to our stack
of Dell PowerConnect 6248 switches that make up our client stack (because
our Cisco stack is currently full - another is on order so we can extend
it and give our server network room to grow) and while it connects to our
existing stack and we've successfully moved a LUN across, there are
numerous errors on the Ethernet connectors that are giving us cause for
concern.
Our other two SANs are connected to our Cisco stack and show no errors at
all. They connect to the Dell stack via a fibre link which does not have
jumbo frames turned on.
We are not particularly keen on moving across the remainder of the LUNs
until we resolve this issue. Is there something on the switch we need to
configure that I'm missing? Should I not be using the PC6248s for this and
should I wait for our new Cisco switch to arrive? Am I getting myself into
a fuss over nothing?
EDIT: I noticed spanning tree was turned on for the ports and turned off
for the SAN ports on the Cisco switch. Turning it off has done nothing to
stem the errors coming from this thing. I ensured that the MTU was 9000
across the board and it hasn't made a difference. All cables are CAT6.
Turning off LLDP made no difference. Someone requested a diagram, which is
below.
We have a loaned PS6000E SAN that we are using to relocate our iSCSI LUNs
off our current PS4000E SAN to upgrade it from Seagate Moose drives under
a proactive replacement plan by Dell. We've connected it up to our stack
of Dell PowerConnect 6248 switches that make up our client stack (because
our Cisco stack is currently full - another is on order so we can extend
it and give our server network room to grow) and while it connects to our
existing stack and we've successfully moved a LUN across, there are
numerous errors on the Ethernet connectors that are giving us cause for
concern.
Our other two SANs are connected to our Cisco stack and show no errors at
all. They connect to the Dell stack via a fibre link which does not have
jumbo frames turned on.
We are not particularly keen on moving across the remainder of the LUNs
until we resolve this issue. Is there something on the switch we need to
configure that I'm missing? Should I not be using the PC6248s for this and
should I wait for our new Cisco switch to arrive? Am I getting myself into
a fuss over nothing?
EDIT: I noticed spanning tree was turned on for the ports and turned off
for the SAN ports on the Cisco switch. Turning it off has done nothing to
stem the errors coming from this thing. I ensured that the MTU was 9000
across the board and it hasn't made a difference. All cables are CAT6.
Turning off LLDP made no difference. Someone requested a diagram, which is
below.
What does the second index mean in probability distribution in finite events space definition math.stackexchange.com
What does the second index mean in probability distribution in finite
events space definition – math.stackexchange.com
In one of the books I have found such definition: Let $\Omega$ be
countable space $$\Omega=\{ \omega_1, \omega_2,... \}$$ For single element
events function P is defined as follows: $$ P(\{ ...
events space definition – math.stackexchange.com
In one of the books I have found such definition: Let $\Omega$ be
countable space $$\Omega=\{ \omega_1, \omega_2,... \}$$ For single element
events function P is defined as follows: $$ P(\{ ...
Monday, 30 September 2013
Why is there no "remainder" in multiplication math.stackexchange.com
Why is there no "remainder" in multiplication – math.stackexchange.com
With division, you can have a remainder (such as $5/2=2$ remainder $1$).
Now my six year old son has asked me "Why is there no remainder with
multiplication"? The obvious answer is "because it ...
With division, you can have a remainder (such as $5/2=2$ remainder $1$).
Now my six year old son has asked me "Why is there no remainder with
multiplication"? The obvious answer is "because it ...
How much has "True North" shifted in the last few years and would this affect aeronautics=?iso-8859-1?Q?=3F_=96_skeptics.stackexchange.com?=
How much has "True North" shifted in the last few years and would this
affect aeronautics? – skeptics.stackexchange.com
I was talking to a contractor at a major U.S. airport, a Project Manager
who told that they were moving the runways due to the shifting of 'True
North'. I have heard that the poles have shifted even …
affect aeronautics? – skeptics.stackexchange.com
I was talking to a contractor at a major U.S. airport, a Project Manager
who told that they were moving the runways due to the shifting of 'True
North'. I have heard that the poles have shifted even …
Training/skills to become a good QA engineer
Training/skills to become a good QA engineer
I've done a search for similar questions before but it seems they only
mention a few books or talk about soft skills, they seem to like training
resources for becoming a tester and there is little to no mention of
training resources for test automation.
So for background I'm a CS grad who doesn't seem to have a great ability
to develop, at least not yet. I went into finance and worked for two years
in support/development and got on very well, unfortunately my application
got quite popular and therefore the team was heavily regulated, this meant
I went to strictly support and low level so I wasn't happy with the lack
of complexity.
As a result I decided to try a different industry and have went back to
technology and got a job as a QA engineer. I am fully aware I cannot rely
solely on my employer to provide the skills necessary to become a good QA
Engineer.
Therefore I wish to firstly cement soft skills as a good QA tester which I
believe I already have. i.e. an eye for detail, enjoy a good puzzle. What
technical skills do people feel are required to be a good 'manual' tester?
Lastly the main reason I took this jump was to get into automated testing
as I believe it will allow a jump in complexity and perhaps a side move to
development when I'm good enough. Where do I start in becoming good at
automated testing?
The standard advice for a dev is to start developing personal projects?
What about a tester? Is it the same so then you can test your project
thoroughly? I've often seen it said you should be testing OTHER peoples
code mainly. So how can I get this exposure?
Just for additional info, I've been researching a bit myself and have come
across a few products like selenium to play with and reading the google
testing blog. On top of this I've started two udacity classes, one for
software testing and one for debugging. Any further suggestions? Any
decent books to help me feel a little less lost in my current situation?
Thanks for any advice you can provide
I've done a search for similar questions before but it seems they only
mention a few books or talk about soft skills, they seem to like training
resources for becoming a tester and there is little to no mention of
training resources for test automation.
So for background I'm a CS grad who doesn't seem to have a great ability
to develop, at least not yet. I went into finance and worked for two years
in support/development and got on very well, unfortunately my application
got quite popular and therefore the team was heavily regulated, this meant
I went to strictly support and low level so I wasn't happy with the lack
of complexity.
As a result I decided to try a different industry and have went back to
technology and got a job as a QA engineer. I am fully aware I cannot rely
solely on my employer to provide the skills necessary to become a good QA
Engineer.
Therefore I wish to firstly cement soft skills as a good QA tester which I
believe I already have. i.e. an eye for detail, enjoy a good puzzle. What
technical skills do people feel are required to be a good 'manual' tester?
Lastly the main reason I took this jump was to get into automated testing
as I believe it will allow a jump in complexity and perhaps a side move to
development when I'm good enough. Where do I start in becoming good at
automated testing?
The standard advice for a dev is to start developing personal projects?
What about a tester? Is it the same so then you can test your project
thoroughly? I've often seen it said you should be testing OTHER peoples
code mainly. So how can I get this exposure?
Just for additional info, I've been researching a bit myself and have come
across a few products like selenium to play with and reading the google
testing blog. On top of this I've started two udacity classes, one for
software testing and one for debugging. Any further suggestions? Any
decent books to help me feel a little less lost in my current situation?
Thanks for any advice you can provide
Clean IOS xcode target in command line
Clean IOS xcode target in command line
I am building/running an IOS app from command line with following commands:
xcodebuild -sdk "${TARGET_SDK}" -xcconfig "${CONFIG_FILE_PATH}"
-configuration Release
/usr/bin/xcrun -sdk "${TARGET_SDK}" PackageApplication -v
"${PROJECT_BUILD_DIR}/${APPLICATION_NAME}.app" -o
"${OUTPUT_DIR}/${APPLICATION_NAME}.ipa"
Is there any command to clean the targets. or these commands take care of
cleaning themselves.
I am building/running an IOS app from command line with following commands:
xcodebuild -sdk "${TARGET_SDK}" -xcconfig "${CONFIG_FILE_PATH}"
-configuration Release
/usr/bin/xcrun -sdk "${TARGET_SDK}" PackageApplication -v
"${PROJECT_BUILD_DIR}/${APPLICATION_NAME}.app" -o
"${OUTPUT_DIR}/${APPLICATION_NAME}.ipa"
Is there any command to clean the targets. or these commands take care of
cleaning themselves.
Sunday, 29 September 2013
Using Lisp's CFFI defcstruct with OpenCV's cvSize and CvSize struct?
Using Lisp's CFFI defcstruct with OpenCV's cvSize and CvSize struct?
I have half successfully wrapped the OpenCV cvSize function
CV_INLINE CvSize cvSize( int width, int height )
and I would like to acces the slots of the defctruct cv-size but could use
help here are my steps:
i created a cl-opencv-glue.c file and adding this
CvSize cvSize_glue(int width, int height)
{
return cvSize(width, height);
}
then created cl-opencv-glue.h file and adding this:
/* CvSize cvSize(int width, int height) */
CvSize cvSize_glue(int width, int height);
then builded a
/usr/local/lib/libcl-opencv-glue.so
which builds successfully
then created a wrapper for the glue function like this:
;; CvSize cvSize(int width, int height)
(cffi:defcfun ("cvSize_glue" size) (:pointer (:struct cv-size))
"Constructs CvSize structure."
(width :int)
(height :int))
then i can run this program successfully:
(defun init-image-header-example (&optional (width 640)
(height 480))
"Initializes an image header that was previously allocated."
(let* ((img-size (size width height))
(image (create-image img-size +ipl-depth-8u+ 3))
(image-re-init (init-image-header image img-size
+ipl-depth-8u+ 3
+ipl-origin-tl+ 4))
(window-name "INIT-IMAGE-HEADER Example"))
(named-window window-name +window-normal+)
(move-window window-name 702 285)
(create-data image-re-init)
(show-image window-name image-re-init)
(loop while (not (= (wait-key 0) 27)))
(release-image image-re-init)
(destroy-window window-name)))
the
(img-size (size width height))
line successfully creates a size structure for the:
(create-image img-size +ipl-depth-8u+ 3)
which is wrapped like this
;; IplImage* cvCreateImage(CvSize size, int depth, int channels)
(cffi:defcfun ("cvCreateImage" create-image) (:pointer (:struct ipl-image))
(size (:pointer (:struct cv-size)))
(depth :int)
(channels :int))
now for testing i create a size struct at the repl(w/ output):
CL-OPENCV> (defparameter size (size 1280 1024))
SIZE
CL-OPENCV> size
#.(SB-SYS:INT-SAP #X40000000500)
CL-OPENCV>
now id like to access slots of the size pointer so i can get size.width
and size.height so i can create a size-width and size-height function in
lisp
so i attempt to get at the slots by running at the repl(w/ output)
CL-OPENCV> (cffi:with-foreign-object (size '(:struct cv-size))
;; Initialize the slots
;; Return a list with the coordinates
(cffi:with-foreign-slots ((width height) size (:struct cv-size))
(list width height)))
Output > (754484 0)
and get this
(754484 0)
my defcstruct created by swig is
(cffi:defcstruct cv-size
(width :int)
(height :int))
and the defined Opencv struct is this(along with the CV_INLINE for
reference):
here is how they are defined in
/home/w/Downloads/opencv-2.4.6.1/modules/core/include/opencv2/core/types_c.h:
typedef struct CvSize
{
int width;
int height;
}
CvSize;
CV_INLINE CvSize cvSize( int width, int height )
{
CvSize s;
s.width = width;
s.height = height;
return s;
}
so i change my glue.c to(and rebuild .so)
CvSize cvSize_glue(int width, int height)
{
cvSize(width, height);
}
i re-open emacs and run the (init-image-header-example) function above and
it runs so i rerun the above repl test(shown below w/ output)
(cffi:with-foreign-object (size '(:struct cv-size))
;; Initialize the slots
;; Return a list with the coordinates
(cffi:with-foreign-slots ((width height) size (:struct cv-size))
(list width height)))
Output > (338509 0)
compared to above test of
(754484 0)
it is similar but different the 754484 changes evertime regardless of
whether return is there or not I tried every variation of the defcstruct
cv-size parameter i/e replacing the cv-size in
(cffi:defcstruct cv-size
(width :int)
(height :int))
with all the below:
:struct cv-size, (:struct cv-size), (:pointer (:struct cv-size)), :struct
cv-size
and get errors for all....(didnt include errors for sake of length of
post(but will if neccesary)) i then try the below to access the slots
(shown /w output)
CL-OPENCV> (defparameter size (size 1280 1024))
SIZE
CL-OPENCV> size
#.(SB-SYS:INT-SAP #X40000000500)
CL-OPENCV> (cffi:with-foreign-slots ((width height)
size (:struct cv-size))
(format t "width = ~a~%height = ~a~%"
width height ))
but get a
[Condition of type SB-SYS:MEMORY-FAULT-ERROR]
after last entry
Any help on this would be much appreciated...
I have half successfully wrapped the OpenCV cvSize function
CV_INLINE CvSize cvSize( int width, int height )
and I would like to acces the slots of the defctruct cv-size but could use
help here are my steps:
i created a cl-opencv-glue.c file and adding this
CvSize cvSize_glue(int width, int height)
{
return cvSize(width, height);
}
then created cl-opencv-glue.h file and adding this:
/* CvSize cvSize(int width, int height) */
CvSize cvSize_glue(int width, int height);
then builded a
/usr/local/lib/libcl-opencv-glue.so
which builds successfully
then created a wrapper for the glue function like this:
;; CvSize cvSize(int width, int height)
(cffi:defcfun ("cvSize_glue" size) (:pointer (:struct cv-size))
"Constructs CvSize structure."
(width :int)
(height :int))
then i can run this program successfully:
(defun init-image-header-example (&optional (width 640)
(height 480))
"Initializes an image header that was previously allocated."
(let* ((img-size (size width height))
(image (create-image img-size +ipl-depth-8u+ 3))
(image-re-init (init-image-header image img-size
+ipl-depth-8u+ 3
+ipl-origin-tl+ 4))
(window-name "INIT-IMAGE-HEADER Example"))
(named-window window-name +window-normal+)
(move-window window-name 702 285)
(create-data image-re-init)
(show-image window-name image-re-init)
(loop while (not (= (wait-key 0) 27)))
(release-image image-re-init)
(destroy-window window-name)))
the
(img-size (size width height))
line successfully creates a size structure for the:
(create-image img-size +ipl-depth-8u+ 3)
which is wrapped like this
;; IplImage* cvCreateImage(CvSize size, int depth, int channels)
(cffi:defcfun ("cvCreateImage" create-image) (:pointer (:struct ipl-image))
(size (:pointer (:struct cv-size)))
(depth :int)
(channels :int))
now for testing i create a size struct at the repl(w/ output):
CL-OPENCV> (defparameter size (size 1280 1024))
SIZE
CL-OPENCV> size
#.(SB-SYS:INT-SAP #X40000000500)
CL-OPENCV>
now id like to access slots of the size pointer so i can get size.width
and size.height so i can create a size-width and size-height function in
lisp
so i attempt to get at the slots by running at the repl(w/ output)
CL-OPENCV> (cffi:with-foreign-object (size '(:struct cv-size))
;; Initialize the slots
;; Return a list with the coordinates
(cffi:with-foreign-slots ((width height) size (:struct cv-size))
(list width height)))
Output > (754484 0)
and get this
(754484 0)
my defcstruct created by swig is
(cffi:defcstruct cv-size
(width :int)
(height :int))
and the defined Opencv struct is this(along with the CV_INLINE for
reference):
here is how they are defined in
/home/w/Downloads/opencv-2.4.6.1/modules/core/include/opencv2/core/types_c.h:
typedef struct CvSize
{
int width;
int height;
}
CvSize;
CV_INLINE CvSize cvSize( int width, int height )
{
CvSize s;
s.width = width;
s.height = height;
return s;
}
so i change my glue.c to(and rebuild .so)
CvSize cvSize_glue(int width, int height)
{
cvSize(width, height);
}
i re-open emacs and run the (init-image-header-example) function above and
it runs so i rerun the above repl test(shown below w/ output)
(cffi:with-foreign-object (size '(:struct cv-size))
;; Initialize the slots
;; Return a list with the coordinates
(cffi:with-foreign-slots ((width height) size (:struct cv-size))
(list width height)))
Output > (338509 0)
compared to above test of
(754484 0)
it is similar but different the 754484 changes evertime regardless of
whether return is there or not I tried every variation of the defcstruct
cv-size parameter i/e replacing the cv-size in
(cffi:defcstruct cv-size
(width :int)
(height :int))
with all the below:
:struct cv-size, (:struct cv-size), (:pointer (:struct cv-size)), :struct
cv-size
and get errors for all....(didnt include errors for sake of length of
post(but will if neccesary)) i then try the below to access the slots
(shown /w output)
CL-OPENCV> (defparameter size (size 1280 1024))
SIZE
CL-OPENCV> size
#.(SB-SYS:INT-SAP #X40000000500)
CL-OPENCV> (cffi:with-foreign-slots ((width height)
size (:struct cv-size))
(format t "width = ~a~%height = ~a~%"
width height ))
but get a
[Condition of type SB-SYS:MEMORY-FAULT-ERROR]
after last entry
Any help on this would be much appreciated...
PHP File request from url directory
PHP File request from url directory
This is probably a very easy question. Anyway how do you use variables
from a url without requests. For example:
www.mysite.com/get.php/id/123
Then the page retrieves id 123 from a database.
How is this done? Thanks in advance!
This is probably a very easy question. Anyway how do you use variables
from a url without requests. For example:
www.mysite.com/get.php/id/123
Then the page retrieves id 123 from a database.
How is this done? Thanks in advance!
Generate multipart/mixed HTTP request
Generate multipart/mixed HTTP request
I would like to POST a multipart/mixed request, where one part is of type
application/json and the other of type video/mp4 (Content-Type: video/mp4;
charset=binary). How can I easily build such POST request in python?
I would like to POST a multipart/mixed request, where one part is of type
application/json and the other of type video/mp4 (Content-Type: video/mp4;
charset=binary). How can I easily build such POST request in python?
Ensuring a transaction within a method with ActiveRecord
Ensuring a transaction within a method with ActiveRecord
I have a situation in which I would like a method to work within a
transaction, but only if a transaction has not already been started.
Here's a contrived example to distill what I'm talking about:
class ConductBusinessLogic
def initialize(params)
@params = params
end
def process!
ActiveRecord::Base.transaction do
ModelA.create_multiple(params[:model_a])
ModelB.create_multiple(params[:model_a])
end
end
end
class ModelA < ActiveRecord::Base
def self.create_multiple(params)
# I'd like the below to be more like "ensure_transaction"
ActiveRecord::Base.transaction do
params.each { |p| create(p) }
end
end
end
class ModelB < ActiveRecord::Base
def self.create_multiple(params)
# Again, a transaction here is only necessary if one has not already
been started
ActiveRecord::Base.transaction do
params.each { |p| create(p) }
end
end
end
Basically, I don't want these to act as nested transactions. I want the
.create_multiple methods to only start transactions if they are not
already called within a transaction, such as through
ConductBusinessLogic#process!. If the model methods are called by
themselves, they should start their own transaction, but if they are
already being called inside a transaction, as through
ConductBusinessLogic#process!, they should not nest a sub-transaction.
I don't know of a way in which Rails provides this out of the box. If I
run the above code as-is and a rollback is triggered by one of the model
methods, the whole transaction will still go through because the
sub-transaction swallows the ActiveRecord::Rollback exception. If I use
the requires_new option on the sub-transactions, savepoints will be used
to simulate nested transactions, and only that sub-transaction will
actually be rolled back. The behavior I would like would be something to
the effect of ActiveRecord::Base.ensure_transaction, such that a new
transaction is started only if there isn't already an outer transaction,
so that any sub-transaction can trigger a rollback on the entire outer
transaction. This would allow these methods to be transactional on their
own, but defer to a parent transaction if there is one.
Is there a built-in way to achieve this behavior, and if not, is there a
gem or patch that will work?
I have a situation in which I would like a method to work within a
transaction, but only if a transaction has not already been started.
Here's a contrived example to distill what I'm talking about:
class ConductBusinessLogic
def initialize(params)
@params = params
end
def process!
ActiveRecord::Base.transaction do
ModelA.create_multiple(params[:model_a])
ModelB.create_multiple(params[:model_a])
end
end
end
class ModelA < ActiveRecord::Base
def self.create_multiple(params)
# I'd like the below to be more like "ensure_transaction"
ActiveRecord::Base.transaction do
params.each { |p| create(p) }
end
end
end
class ModelB < ActiveRecord::Base
def self.create_multiple(params)
# Again, a transaction here is only necessary if one has not already
been started
ActiveRecord::Base.transaction do
params.each { |p| create(p) }
end
end
end
Basically, I don't want these to act as nested transactions. I want the
.create_multiple methods to only start transactions if they are not
already called within a transaction, such as through
ConductBusinessLogic#process!. If the model methods are called by
themselves, they should start their own transaction, but if they are
already being called inside a transaction, as through
ConductBusinessLogic#process!, they should not nest a sub-transaction.
I don't know of a way in which Rails provides this out of the box. If I
run the above code as-is and a rollback is triggered by one of the model
methods, the whole transaction will still go through because the
sub-transaction swallows the ActiveRecord::Rollback exception. If I use
the requires_new option on the sub-transactions, savepoints will be used
to simulate nested transactions, and only that sub-transaction will
actually be rolled back. The behavior I would like would be something to
the effect of ActiveRecord::Base.ensure_transaction, such that a new
transaction is started only if there isn't already an outer transaction,
so that any sub-transaction can trigger a rollback on the entire outer
transaction. This would allow these methods to be transactional on their
own, but defer to a parent transaction if there is one.
Is there a built-in way to achieve this behavior, and if not, is there a
gem or patch that will work?
Saturday, 28 September 2013
Issue with PDO select query: unknown error
Issue with PDO select query: unknown error
I'm trying to get comfortable with PDO but can't get this to work.
Below is a script for a basic search box:
<?php
$sth= new connection();
if (isset($_GET['search'])) {
$search_query = $_GET['search'];
$search_query = htmlentities($search_query)
$result=$sth->con->prepare("SELECT firstname, lastname FROM users WHERE
firstname LIKE '%" . $search_query . "%' OR
lastname LIKE '%" . $search_query . "%' OR
LIMIT 25");
$result->bindParam(1, $search_query, PDO::PARAM_STR, 12);
foreach ($result as $row) {
$firstname = $row["firstname"];
$lastname = $row["lastname"];
if (!($result) == 0) {
?>
<div="foo">Here are your results:</div>
<?php
} else {
?>
<div="bar">No results!</div>
<?php
}
}
?>
Here's the error that I get:
fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[]:
<<Unknown error>>
What am I doing wrong ?
ps: $sth works fine with other queries.
I'm trying to get comfortable with PDO but can't get this to work.
Below is a script for a basic search box:
<?php
$sth= new connection();
if (isset($_GET['search'])) {
$search_query = $_GET['search'];
$search_query = htmlentities($search_query)
$result=$sth->con->prepare("SELECT firstname, lastname FROM users WHERE
firstname LIKE '%" . $search_query . "%' OR
lastname LIKE '%" . $search_query . "%' OR
LIMIT 25");
$result->bindParam(1, $search_query, PDO::PARAM_STR, 12);
foreach ($result as $row) {
$firstname = $row["firstname"];
$lastname = $row["lastname"];
if (!($result) == 0) {
?>
<div="foo">Here are your results:</div>
<?php
} else {
?>
<div="bar">No results!</div>
<?php
}
}
?>
Here's the error that I get:
fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[]:
<<Unknown error>>
What am I doing wrong ?
ps: $sth works fine with other queries.
declaring a variable within conditional expressions (ternary operator)
declaring a variable within conditional expressions (ternary operator)
Is it possible to declare the variable within a conditional expression?
for example: The code below return a syntax error (because I've declared
the variable x within the conditional expression?).
var a = document.getElementById("userData");
var d = a.value;
function() {
(d.length>15)?(
alert("your input was too long")):(
var x = parseInt(d).toString(2),
a.value=x
);
}
obviously this can be fixed by simply adding var x; outside the statement,
but is it possible for variables to be declared here?
Is it possible to declare the variable within a conditional expression?
for example: The code below return a syntax error (because I've declared
the variable x within the conditional expression?).
var a = document.getElementById("userData");
var d = a.value;
function() {
(d.length>15)?(
alert("your input was too long")):(
var x = parseInt(d).toString(2),
a.value=x
);
}
obviously this can be fixed by simply adding var x; outside the statement,
but is it possible for variables to be declared here?
Why files creatied with Java FileOutputStream on Android are visible on my pc throught USB after few ubs reconnectonions (+up to few...
Why files creatied with Java FileOutputStream on Android are visible on my
pc throught USB after few ubs reconnectonions (+up to few...
I have code like this: File file = new
File(Environment.getExternalStorageDirectory(), fileName);
FileOutputStream os = null; try { os = new FileOutputStream(file); } catch
(FileNotFoundException e) { System.err.println("Error while creating
FileOutputStream"); e.printStackTrace(); }
os.write("something".getBytes());
and when i create file on my HTC desire x i have to disconnect usb, wait
few minutes, connect it again to see it in windows explorer. Why it's like
that? And how can i prevent it?
pc throught USB after few ubs reconnectonions (+up to few...
I have code like this: File file = new
File(Environment.getExternalStorageDirectory(), fileName);
FileOutputStream os = null; try { os = new FileOutputStream(file); } catch
(FileNotFoundException e) { System.err.println("Error while creating
FileOutputStream"); e.printStackTrace(); }
os.write("something".getBytes());
and when i create file on my HTC desire x i have to disconnect usb, wait
few minutes, connect it again to see it in windows explorer. Why it's like
that? And how can i prevent it?
Buses scheduling - relational database or nosql
Buses scheduling - relational database or nosql
I'm trying to store buses schedules into database and I'm wondering which
database model is suitable for my case.
I have bus operators, each operator has several routes, each route has
several turns, each turn has stops, etc. Turns are generated from
something called "turn master" where the scheduling is defined (frequency,
stops, etc.) within next N days.
I expect to deliver a very fast searching for bus when user tries to
search a bus from city to city on given date.
I'm using MySQL, the number of stops reach around 100.000 records and the
searching speed is fast but I'm not sure if it's still fast when data gets
really big (thousand operators, each operator has hundreses turns, each
turn has around 10 stops, turns are generated for around next 30 days).
Basically, performing a search is to look for stop (city/town/place, time)
and check if it matches user search criteria.
So, my question is: Is relational database is best in this case? Or using
some kind of NoSQL will be better when the data get really bigs?
Thanks in advance,
I'm trying to store buses schedules into database and I'm wondering which
database model is suitable for my case.
I have bus operators, each operator has several routes, each route has
several turns, each turn has stops, etc. Turns are generated from
something called "turn master" where the scheduling is defined (frequency,
stops, etc.) within next N days.
I expect to deliver a very fast searching for bus when user tries to
search a bus from city to city on given date.
I'm using MySQL, the number of stops reach around 100.000 records and the
searching speed is fast but I'm not sure if it's still fast when data gets
really big (thousand operators, each operator has hundreses turns, each
turn has around 10 stops, turns are generated for around next 30 days).
Basically, performing a search is to look for stop (city/town/place, time)
and check if it matches user search criteria.
So, my question is: Is relational database is best in this case? Or using
some kind of NoSQL will be better when the data get really bigs?
Thanks in advance,
Friday, 27 September 2013
Xcode5 build failed
Xcode5 build failed
I am a newbie and sorry about my english!- -!
I update my Xcdoe4.* to Xcode5,After that I cretate a helloworld project.
I launche Xcode and click "create a new Xcode project" and then select
"Single View Application" and click "next".After type product name,I click
"next" again and then "create". and I get this
I click the rectangle button left-top in the window to run the app,the
Xcode tell me "Build failed",and now i get this
very sorry about my english,Is anyone can help
I am a newbie and sorry about my english!- -!
I update my Xcdoe4.* to Xcode5,After that I cretate a helloworld project.
I launche Xcode and click "create a new Xcode project" and then select
"Single View Application" and click "next".After type product name,I click
"next" again and then "create". and I get this
I click the rectangle button left-top in the window to run the app,the
Xcode tell me "Build failed",and now i get this
very sorry about my english,Is anyone can help
Hartl Chapter Error Before 9.1.3
Hartl Chapter Error Before 9.1.3
I'm going through Mr. Hartl's Tutorial and trying to copy it exactly, even
kinda using his completed github code as a guide, but I'm stuck with the
following after running the "bundle exec rspec spec/":
Failures:
1) Authentication signin with valid information
Failure/Error: before { sign_in user }
ActionView::MissingTemplate:
Missing template sessions/create, application/create with
{:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder,
:raw, :ruby, :jbuilder, :coffee]}. Searched in:
* "/home/nemo/rails_projects/sample_app/app/views"
# ./spec/support/utilities.rb:19:in `sign_in'
# ./spec/requests/authentication_pages_spec.rb:32:in `block (4
levels) in <top (required)>'
2) Authentication signin with valid information
Failure/Error: before { sign_in user }
ActionView::MissingTemplate:
Missing template sessions/create, application/create with
{:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder,
:raw, :ruby, :jbuilder, :coffee]}. Searched in:
* "/home/nemo/rails_projects/sample_app/app/views"
# ./spec/support/utilities.rb:19:in `sign_in'
# ./spec/requests/authentication_pages_spec.rb:32:in `block (4
levels) in <top (required)>'
3) Authentication signin with valid information
Failure/Error: before { sign_in user }
ActionView::MissingTemplate:
Missing template sessions/create, application/create with
{:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder,
:raw, :ruby, :jbuilder, :coffee]}. Searched in:
* "/home/nemo/rails_projects/sample_app/app/views"
# ./spec/support/utilities.rb:19:in `sign_in'
# ./spec/requests/authentication_pages_spec.rb:32:in `block (4
levels) in <top (required)>'
4) Authentication signin with valid information
Failure/Error: before { sign_in user }
ActionView::MissingTemplate:
Missing template sessions/create, application/create with
{:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder,
:raw, :ruby, :jbuilder, :coffee]}. Searched in:
* "/home/nemo/rails_projects/sample_app/app/views"
# ./spec/support/utilities.rb:19:in `sign_in'
# ./spec/requests/authentication_pages_spec.rb:32:in `block (4
levels) in <top (required)>'
5) Authentication signin with valid information
Failure/Error: before { sign_in user }
ActionView::MissingTemplate:
Missing template sessions/create, application/create with
{:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder,
:raw, :ruby, :jbuilder, :coffee]}. Searched in:
* "/home/nemo/rails_projects/sample_app/app/views"
# ./spec/support/utilities.rb:19:in `sign_in'
# ./spec/requests/authentication_pages_spec.rb:32:in `block (4
levels) in <top (required)>'
6) Authentication signin with valid information followed by signout
Failure/Error: before { sign_in user }
ActionView::MissingTemplate:
Missing template sessions/create, application/create with
{:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder,
:raw, :ruby, :jbuilder, :coffee]}. Searched in:
* "/home/nemo/rails_projects/sample_app/app/views"
# ./spec/support/utilities.rb:19:in `sign_in'
# ./spec/requests/authentication_pages_spec.rb:32:in `block (4
levels) in <top (required)>'
7) User pages profile page signup with valid information after saving
the user
Failure/Error: before { visit user_path(user) }
AbstractController::ActionNotFound:
The action 'index' could not be found for UsersController
# ./spec/requests/user_pages_spec.rb:16:in `block (3 levels) in <top
(required)>'
8) User pages profile page signup with valid information after saving
the user
Failure/Error: before { visit user_path(user) }
AbstractController::ActionNotFound:
The action 'index' could not be found for UsersController
# ./spec/requests/user_pages_spec.rb:16:in `block (3 levels) in <top
(required)>'
9) User pages profile page signup with valid information after saving
the user
Failure/Error: before { visit user_path(user) }
AbstractController::ActionNotFound:
The action 'index' could not be found for UsersController
# ./spec/requests/user_pages_spec.rb:16:in `block (3 levels) in <top
(required)>'
10) User pages profile page with invalid information
Failure/Error: before { click_button "Save changes" }
Capybara::ElementNotFound:
Unable to find button "Save changes"
# ./spec/requests/user_pages_spec.rb:76:in `block (4 levels) in <top
(required)>'
11) User pages profile page page
Failure/Error: it { should have_content("Update your profile") }
expected #has_content?("Update your profile") to return true, got
false
# ./spec/requests/user_pages_spec.rb:70:in `block (4 levels) in <top
(required)>'
12) User pages profile page page
Failure/Error: it { should have_title("Edit user") }
expected #has_title?("Edit user") to return true, got false
# ./spec/requests/user_pages_spec.rb:71:in `block (4 levels) in <top
(required)>'
13) User pages profile page page
Failure/Error: it { should have_link('change', href:
'http://gravatar.com/emails') }
expected #has_link?("change",
{:href=>"http://gravatar.com/emails"}) to return true, got false
# ./spec/requests/user_pages_spec.rb:72:in `block (4 levels) in <top
(required)>'
Finished in 1.83 seconds
53 examples, 13 failures
spec/requests/authentication_pages_spec.rb:
require 'spec_helper'
describe "Authentication" do
subject { page }
describe "signin page" do
before { visit signin_path }
it { should have_content('Sign in') }
it { should have_title('Sign in') }
end
describe "signin" do
before { visit signin_path }
describe "with invalid information" do
before { click_button "Sign in" }
it { should have_title('Sign in') }
it { should have_selector('div.alert.alert-error', text: 'Invalid') }
describe "after visiting another page" do
before { click_link "Home" }
it { should_not have_selector('div.alert.alert-error') }
end
end
describe "with valid information" do
let(:user) { FactoryGirl.create(:user) }
before { sign_in user }
it { should have_title(user.name) }
it { should have_link('Profile', href: user_path(user)) }
it { should have_link('Settings', href: edit_user_path(user)) }
it { should have_link('Sign out', href: signout_path) }
it { should_not have_link('Sign in', href: signin_path) }
describe "followed by signout" do
before { click_link "Sign out" }
it { should have_link('Sign in') }
end
end
end
end
spec/requests/user_pages_spec.rb
require 'spec_helper'
describe "User pages" do
subject { page }
describe "signup page" do
before { visit signup_path }
it { should have_content('Sign up') }
it { should have_title(full_title('Sign up')) }
end
describe "profile page" do
let(:user) { FactoryGirl.create(:user) }
before { visit user_path(user) }
it { should have_content(user.name) }
it { should have_title(user.name) }
describe "signup" do
before { visit signup_path }
let(:submit) { "Create my account" }
describe "with invalid information" do
it "should not create a user" do
expect { click_button submit }.not_to change(User, :count)
end
describe "after submission" do
before { click_button submit }
it { should have_title('Sign up') }
it { should have_content('error') }
end
end
describe "with valid information" do
before do
fill_in "Name", with: "Example User"
fill_in "Email", with: "user@example.com"
fill_in "Password", with: "foobar"
fill_in "Confirmation", with: "foobar"
end
it "should create a user" do
expect { click_button submit }.to change(User, :count).by(1)
end
describe "after saving the user" do
before { click_button submit }
let(:user) { User.find_by(email: 'user@example.com') }
it { should have_link('Sign out') }
it { should have_title(user.name) }
it { should have_selector('div.alert.alert-success', text:
'Welcome') }
end
end
end
describe "edit" do
let(:user) { FactoryGirl.create(:user) }
before { visit edit_user_path(user) }
end
describe "page" do
it { should have_content("Update your profile") }
it { should have_title("Edit user") }
it { should have_link('change', href: 'http://gravatar.com/emails') }
end
describe "with invalid information" do
before { click_button "Save changes" }
it { should have_content('error') }
end
end
end
I'm going through Mr. Hartl's Tutorial and trying to copy it exactly, even
kinda using his completed github code as a guide, but I'm stuck with the
following after running the "bundle exec rspec spec/":
Failures:
1) Authentication signin with valid information
Failure/Error: before { sign_in user }
ActionView::MissingTemplate:
Missing template sessions/create, application/create with
{:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder,
:raw, :ruby, :jbuilder, :coffee]}. Searched in:
* "/home/nemo/rails_projects/sample_app/app/views"
# ./spec/support/utilities.rb:19:in `sign_in'
# ./spec/requests/authentication_pages_spec.rb:32:in `block (4
levels) in <top (required)>'
2) Authentication signin with valid information
Failure/Error: before { sign_in user }
ActionView::MissingTemplate:
Missing template sessions/create, application/create with
{:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder,
:raw, :ruby, :jbuilder, :coffee]}. Searched in:
* "/home/nemo/rails_projects/sample_app/app/views"
# ./spec/support/utilities.rb:19:in `sign_in'
# ./spec/requests/authentication_pages_spec.rb:32:in `block (4
levels) in <top (required)>'
3) Authentication signin with valid information
Failure/Error: before { sign_in user }
ActionView::MissingTemplate:
Missing template sessions/create, application/create with
{:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder,
:raw, :ruby, :jbuilder, :coffee]}. Searched in:
* "/home/nemo/rails_projects/sample_app/app/views"
# ./spec/support/utilities.rb:19:in `sign_in'
# ./spec/requests/authentication_pages_spec.rb:32:in `block (4
levels) in <top (required)>'
4) Authentication signin with valid information
Failure/Error: before { sign_in user }
ActionView::MissingTemplate:
Missing template sessions/create, application/create with
{:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder,
:raw, :ruby, :jbuilder, :coffee]}. Searched in:
* "/home/nemo/rails_projects/sample_app/app/views"
# ./spec/support/utilities.rb:19:in `sign_in'
# ./spec/requests/authentication_pages_spec.rb:32:in `block (4
levels) in <top (required)>'
5) Authentication signin with valid information
Failure/Error: before { sign_in user }
ActionView::MissingTemplate:
Missing template sessions/create, application/create with
{:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder,
:raw, :ruby, :jbuilder, :coffee]}. Searched in:
* "/home/nemo/rails_projects/sample_app/app/views"
# ./spec/support/utilities.rb:19:in `sign_in'
# ./spec/requests/authentication_pages_spec.rb:32:in `block (4
levels) in <top (required)>'
6) Authentication signin with valid information followed by signout
Failure/Error: before { sign_in user }
ActionView::MissingTemplate:
Missing template sessions/create, application/create with
{:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder,
:raw, :ruby, :jbuilder, :coffee]}. Searched in:
* "/home/nemo/rails_projects/sample_app/app/views"
# ./spec/support/utilities.rb:19:in `sign_in'
# ./spec/requests/authentication_pages_spec.rb:32:in `block (4
levels) in <top (required)>'
7) User pages profile page signup with valid information after saving
the user
Failure/Error: before { visit user_path(user) }
AbstractController::ActionNotFound:
The action 'index' could not be found for UsersController
# ./spec/requests/user_pages_spec.rb:16:in `block (3 levels) in <top
(required)>'
8) User pages profile page signup with valid information after saving
the user
Failure/Error: before { visit user_path(user) }
AbstractController::ActionNotFound:
The action 'index' could not be found for UsersController
# ./spec/requests/user_pages_spec.rb:16:in `block (3 levels) in <top
(required)>'
9) User pages profile page signup with valid information after saving
the user
Failure/Error: before { visit user_path(user) }
AbstractController::ActionNotFound:
The action 'index' could not be found for UsersController
# ./spec/requests/user_pages_spec.rb:16:in `block (3 levels) in <top
(required)>'
10) User pages profile page with invalid information
Failure/Error: before { click_button "Save changes" }
Capybara::ElementNotFound:
Unable to find button "Save changes"
# ./spec/requests/user_pages_spec.rb:76:in `block (4 levels) in <top
(required)>'
11) User pages profile page page
Failure/Error: it { should have_content("Update your profile") }
expected #has_content?("Update your profile") to return true, got
false
# ./spec/requests/user_pages_spec.rb:70:in `block (4 levels) in <top
(required)>'
12) User pages profile page page
Failure/Error: it { should have_title("Edit user") }
expected #has_title?("Edit user") to return true, got false
# ./spec/requests/user_pages_spec.rb:71:in `block (4 levels) in <top
(required)>'
13) User pages profile page page
Failure/Error: it { should have_link('change', href:
'http://gravatar.com/emails') }
expected #has_link?("change",
{:href=>"http://gravatar.com/emails"}) to return true, got false
# ./spec/requests/user_pages_spec.rb:72:in `block (4 levels) in <top
(required)>'
Finished in 1.83 seconds
53 examples, 13 failures
spec/requests/authentication_pages_spec.rb:
require 'spec_helper'
describe "Authentication" do
subject { page }
describe "signin page" do
before { visit signin_path }
it { should have_content('Sign in') }
it { should have_title('Sign in') }
end
describe "signin" do
before { visit signin_path }
describe "with invalid information" do
before { click_button "Sign in" }
it { should have_title('Sign in') }
it { should have_selector('div.alert.alert-error', text: 'Invalid') }
describe "after visiting another page" do
before { click_link "Home" }
it { should_not have_selector('div.alert.alert-error') }
end
end
describe "with valid information" do
let(:user) { FactoryGirl.create(:user) }
before { sign_in user }
it { should have_title(user.name) }
it { should have_link('Profile', href: user_path(user)) }
it { should have_link('Settings', href: edit_user_path(user)) }
it { should have_link('Sign out', href: signout_path) }
it { should_not have_link('Sign in', href: signin_path) }
describe "followed by signout" do
before { click_link "Sign out" }
it { should have_link('Sign in') }
end
end
end
end
spec/requests/user_pages_spec.rb
require 'spec_helper'
describe "User pages" do
subject { page }
describe "signup page" do
before { visit signup_path }
it { should have_content('Sign up') }
it { should have_title(full_title('Sign up')) }
end
describe "profile page" do
let(:user) { FactoryGirl.create(:user) }
before { visit user_path(user) }
it { should have_content(user.name) }
it { should have_title(user.name) }
describe "signup" do
before { visit signup_path }
let(:submit) { "Create my account" }
describe "with invalid information" do
it "should not create a user" do
expect { click_button submit }.not_to change(User, :count)
end
describe "after submission" do
before { click_button submit }
it { should have_title('Sign up') }
it { should have_content('error') }
end
end
describe "with valid information" do
before do
fill_in "Name", with: "Example User"
fill_in "Email", with: "user@example.com"
fill_in "Password", with: "foobar"
fill_in "Confirmation", with: "foobar"
end
it "should create a user" do
expect { click_button submit }.to change(User, :count).by(1)
end
describe "after saving the user" do
before { click_button submit }
let(:user) { User.find_by(email: 'user@example.com') }
it { should have_link('Sign out') }
it { should have_title(user.name) }
it { should have_selector('div.alert.alert-success', text:
'Welcome') }
end
end
end
describe "edit" do
let(:user) { FactoryGirl.create(:user) }
before { visit edit_user_path(user) }
end
describe "page" do
it { should have_content("Update your profile") }
it { should have_title("Edit user") }
it { should have_link('change', href: 'http://gravatar.com/emails') }
end
describe "with invalid information" do
before { click_button "Save changes" }
it { should have_content('error') }
end
end
end
write a code in a separate threads
write a code in a separate threads
Hello how can i write this code in a separate threads because i have an
intensive operations in my main thread.so i have to use an Async Activity
and delegate the network intensive operation to 'doInBackground'
method.but i don't know how to edit it
public void setImage(ImageView aView, URL aURL) {
try {
URLConnection conn = aURL.openConnection();
conn.connect();
InputStream is = conn.getInputStream();
// Bufferisation pour le t�l�chargement
BufferedInputStream bis = new BufferedInputStream(is, 8192);
// Cr�ation de l'image depuis le flux des
donn�es entrant
Bitmap bm = BitmapFactory.decodeStream(bis);
bis.close();
is.close();
// Fixe l'image sur le composant ImageView
aView.setImageBitmap(bm);
} catch (IOException e) {
aView.setImageDrawable(mNoImage);
Log.e("DVP Gallery", "Erreur t�l�chargement
image URL : " + aURL.toString());
e.printStackTrace();
}
}
please help me thanks
Hello how can i write this code in a separate threads because i have an
intensive operations in my main thread.so i have to use an Async Activity
and delegate the network intensive operation to 'doInBackground'
method.but i don't know how to edit it
public void setImage(ImageView aView, URL aURL) {
try {
URLConnection conn = aURL.openConnection();
conn.connect();
InputStream is = conn.getInputStream();
// Bufferisation pour le t�l�chargement
BufferedInputStream bis = new BufferedInputStream(is, 8192);
// Cr�ation de l'image depuis le flux des
donn�es entrant
Bitmap bm = BitmapFactory.decodeStream(bis);
bis.close();
is.close();
// Fixe l'image sur le composant ImageView
aView.setImageBitmap(bm);
} catch (IOException e) {
aView.setImageDrawable(mNoImage);
Log.e("DVP Gallery", "Erreur t�l�chargement
image URL : " + aURL.toString());
e.printStackTrace();
}
}
please help me thanks
Which is the best approach to send large UDP packets in sequence
Which is the best approach to send large UDP packets in sequence
I have an android application that needs to send data through the protocol
UDP every 100 milliseconds. Each UDP packet has 15000 bytes average.
packets are sent in broadcast
Every 100 milliseconds lines below are run through a loop.
DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length,
broadcast, 9876);
clientSocket.send(sendPacket);
Application starts working fine, but after about 1 minute frequency of
received packets decreases until the packets do not arrive over the
destination.
The theoretical limit (on Windows) for the maximum size of a UDP packet is
65507 bytes
I know the media MTU of a network is 1500 bytes and when I send a packet
bigger it is broken into several fragments and if a fragment does not
reach the destination the whole package is lost.
I do not understand why at first 1 minute the packets are sent correctly
and after a while the packets do not arrive more. So I wonder what would
be the best approach to solve this problem?
I have an android application that needs to send data through the protocol
UDP every 100 milliseconds. Each UDP packet has 15000 bytes average.
packets are sent in broadcast
Every 100 milliseconds lines below are run through a loop.
DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length,
broadcast, 9876);
clientSocket.send(sendPacket);
Application starts working fine, but after about 1 minute frequency of
received packets decreases until the packets do not arrive over the
destination.
The theoretical limit (on Windows) for the maximum size of a UDP packet is
65507 bytes
I know the media MTU of a network is 1500 bytes and when I send a packet
bigger it is broken into several fragments and if a fragment does not
reach the destination the whole package is lost.
I do not understand why at first 1 minute the packets are sent correctly
and after a while the packets do not arrive more. So I wonder what would
be the best approach to solve this problem?
Prevent prompting for PEM passphrase
Prevent prompting for PEM passphrase
I am building a Qt-based application that will communicate through https
with a webserver. The setup should allow client-authentication with a
local certificate and private key. The application must run without any
user interaction.
Now I have a problem when the private key file is protected by a passphrase:
OpenSSL will prompt for a password, blocking the whole application!
The openSSL API allows to pass a callback for getting the passphrase, but
this is not accessible though the Qt Wrapper. Is there another way to
prevent openSSL from prompting for a password? Or can this somehow be
interrupted?
I am building a Qt-based application that will communicate through https
with a webserver. The setup should allow client-authentication with a
local certificate and private key. The application must run without any
user interaction.
Now I have a problem when the private key file is protected by a passphrase:
OpenSSL will prompt for a password, blocking the whole application!
The openSSL API allows to pass a callback for getting the passphrase, but
this is not accessible though the Qt Wrapper. Is there another way to
prevent openSSL from prompting for a password? Or can this somehow be
interrupted?
VS displaying blue text despite being configured for black
VS displaying blue text despite being configured for black
I'm running Visual Studio 2010 on my tablet, which is configured for 125%
display scaling (Iconia W3; kind of necessary on an 8" screen). When
configured with default color settings, Visual Studio displays any text
that's supposed to be black normally with a blue tint. If I configure it
as black, it appears blue. If I configure it as red, it appears purple.
Anybody seen this before, and know a workaround, or should I report it on
MS Connect?
I'm running Visual Studio 2010 on my tablet, which is configured for 125%
display scaling (Iconia W3; kind of necessary on an 8" screen). When
configured with default color settings, Visual Studio displays any text
that's supposed to be black normally with a blue tint. If I configure it
as black, it appears blue. If I configure it as red, it appears purple.
Anybody seen this before, and know a workaround, or should I report it on
MS Connect?
Getting virtual memory page size by java code
Getting virtual memory page size by java code
Is it possible to get virtual memory page size of the OS on which a java
application is running? If yes, how?
Is it possible to get virtual memory page size of the OS on which a java
application is running? If yes, how?
Thursday, 26 September 2013
Java Game - how to add enemies using Arraylist?
Java Game - how to add enemies using Arraylist?
I'm doing my first Java game using GdxLib, and i want to create enemies
using an ArrayList (but im not sure of how to do it), and that all of them
spawn in a random position, but i got few problems,
Im creating them wrong cause they are spawning like a 'line' because i
dont know how to spawn them randomly.
When any of my created enemies on Screen 'dies' (count == 20) if i shoot
any other enemy i can't kill it.
Here is the class code:
public class World {
gameMain game;
Ship ship;
ArrayList<Bullet> bullets = new ArrayList<Bullet>();
ArrayList<Follower> enemies = new ArrayList<Follower>(5);
WorldRenderer wr;
Iterator<Bullet> bIter;
Iterator<Follower> eIter;
Bullet b;
Enemy e;
int count = 0;
int shipCount = 0;
float x = 0;
float y = 0;
public World (gameMain game){
this.game = game;
ship = new Ship(new Vector2(20, 15), 1, 1, 0, 5f);//Ship Atributes
for (int i= 0;i<5; i++){ Creates 5 enemies
enemies.add(new Follower(5f, 0, 1, 1, new Vector2(x,y)));
x = x+2;
y = y+2;
}
Gdx.input.setInputProcessor(new InputHandler(this));
}
public Ship getShip(){
return ship;
}
public ArrayList<Follower> getEnemies(){
return enemies;
}
public void update(){
ship.update();
bIter = bullets.iterator();
while(bIter.hasNext()){
b = bIter.next();
b.update(ship);
}
eIter = enemies.iterator();
while(eIter.hasNext()){
e = eIter.next();
if(ship.getBounds().overlaps(e.getBounds()))
Gdx.app.log(gameMain.LOG, "ColisioN!");
shipCount = shipCount +1;
}
bIter = bullets.iterator();
while(bIter.hasNext()){
b = bIter.next();
eIter = enemies.iterator();
while(eIter.hasNext()){
e = eIter.next();
if(e.getBounds().overlaps(b.getBounds())){
Gdx.app.log(gameMain.LOG, "!");
bIter.remove();
count = count +1;
if (count == 20) {
eIter.remove();
}
}
}
}
public void addBullet(Bullet b){
bullets.add(b);
}
public ArrayList<Bullet> getBullets(){
return bullets;
}
public void setRenderer(WorldRenderer wr){
this.wr = wr;
}
public WorldRenderer getRenderer(){
return wr;
}
public void dispose(){
}
}
Also, i tried to put a Thread.sleep(2000) after an enemy creation to the
next creation, but when i run the game the Screen frezzes, but the thread
is working because i used a System.out.println to print in console after
each creation. There is another option to delay the bucle without using
Thread.sleep?`
I'm doing my first Java game using GdxLib, and i want to create enemies
using an ArrayList (but im not sure of how to do it), and that all of them
spawn in a random position, but i got few problems,
Im creating them wrong cause they are spawning like a 'line' because i
dont know how to spawn them randomly.
When any of my created enemies on Screen 'dies' (count == 20) if i shoot
any other enemy i can't kill it.
Here is the class code:
public class World {
gameMain game;
Ship ship;
ArrayList<Bullet> bullets = new ArrayList<Bullet>();
ArrayList<Follower> enemies = new ArrayList<Follower>(5);
WorldRenderer wr;
Iterator<Bullet> bIter;
Iterator<Follower> eIter;
Bullet b;
Enemy e;
int count = 0;
int shipCount = 0;
float x = 0;
float y = 0;
public World (gameMain game){
this.game = game;
ship = new Ship(new Vector2(20, 15), 1, 1, 0, 5f);//Ship Atributes
for (int i= 0;i<5; i++){ Creates 5 enemies
enemies.add(new Follower(5f, 0, 1, 1, new Vector2(x,y)));
x = x+2;
y = y+2;
}
Gdx.input.setInputProcessor(new InputHandler(this));
}
public Ship getShip(){
return ship;
}
public ArrayList<Follower> getEnemies(){
return enemies;
}
public void update(){
ship.update();
bIter = bullets.iterator();
while(bIter.hasNext()){
b = bIter.next();
b.update(ship);
}
eIter = enemies.iterator();
while(eIter.hasNext()){
e = eIter.next();
if(ship.getBounds().overlaps(e.getBounds()))
Gdx.app.log(gameMain.LOG, "ColisioN!");
shipCount = shipCount +1;
}
bIter = bullets.iterator();
while(bIter.hasNext()){
b = bIter.next();
eIter = enemies.iterator();
while(eIter.hasNext()){
e = eIter.next();
if(e.getBounds().overlaps(b.getBounds())){
Gdx.app.log(gameMain.LOG, "!");
bIter.remove();
count = count +1;
if (count == 20) {
eIter.remove();
}
}
}
}
public void addBullet(Bullet b){
bullets.add(b);
}
public ArrayList<Bullet> getBullets(){
return bullets;
}
public void setRenderer(WorldRenderer wr){
this.wr = wr;
}
public WorldRenderer getRenderer(){
return wr;
}
public void dispose(){
}
}
Also, i tried to put a Thread.sleep(2000) after an enemy creation to the
next creation, but when i run the game the Screen frezzes, but the thread
is working because i used a System.out.println to print in console after
each creation. There is another option to delay the bucle without using
Thread.sleep?`
Wednesday, 25 September 2013
C Infinite Pointer Loop (Caused By Duplicate Value?)
C Infinite Pointer Loop (Caused By Duplicate Value?)
Compiling with MinGW with -O3 -Wall -c -fmessage-length=0 -std=c99
Well, this is what I think the problem is... Here's the breakdown:
I have a linked list that I built using
typedef struct Coordinate{
int x;
int y;
struct Coordinate *next;
} Coordinate;
I am adding "valid moves" (in the game Reversi/Othello) on a 6x6 board
(matrix). My logic for checking whether or not a move is valid or not
works just fine - it's adding things to the list that gets me into
trouble.
For obvious reasons I want to avoid adding duplicate values to the list.
However, every function I attempt to code (that seems like it should work)
just crashes the application, segfaulting all the live long day.
So here's a function that I attempted to code:
int inList(Coordinate *list, int x, int y) {
if (list == NULL) return 0;
while (list != NULL) {
if (list->x == x && list->y == y) return 1;
else list = list->next;
}
return 0;
}
and called it like:
Coordinate *validMoves = createNewCoordinate(-1, -1); // Just so that
there is *something*
if (!inList(validMoves, 1, 1)) {
validMoves->next = createNewCoordinate(1, 1);
validMoves = validMoves->next;
}
So as far as I know, this should work perfectly. I've looked up examples
online and all my really convoluted uses of pointers in this particular
program have worked without a hitch thus far.
Anyway, the real problem is that if I don't prevent duplicates from being
entered into the same list (connected through pointers), then I get an
infinite loop (I imagine this is caused by two elements being considered
equal because their non-pointer types are equal).
I've posted all three parts of the code on pastebin for full reference (no
worries, open source, man!): othello.c othello_engine.c othello_engine.h
I've tried debugging but I'm not very good at that, I didn't really see
anything worth mentioning. Can anyone explain what might be happening
and/or give an example of how to avoid duplicates in a linked list? (I've
tried so many ways my brain hurts)
Compiling with MinGW with -O3 -Wall -c -fmessage-length=0 -std=c99
Well, this is what I think the problem is... Here's the breakdown:
I have a linked list that I built using
typedef struct Coordinate{
int x;
int y;
struct Coordinate *next;
} Coordinate;
I am adding "valid moves" (in the game Reversi/Othello) on a 6x6 board
(matrix). My logic for checking whether or not a move is valid or not
works just fine - it's adding things to the list that gets me into
trouble.
For obvious reasons I want to avoid adding duplicate values to the list.
However, every function I attempt to code (that seems like it should work)
just crashes the application, segfaulting all the live long day.
So here's a function that I attempted to code:
int inList(Coordinate *list, int x, int y) {
if (list == NULL) return 0;
while (list != NULL) {
if (list->x == x && list->y == y) return 1;
else list = list->next;
}
return 0;
}
and called it like:
Coordinate *validMoves = createNewCoordinate(-1, -1); // Just so that
there is *something*
if (!inList(validMoves, 1, 1)) {
validMoves->next = createNewCoordinate(1, 1);
validMoves = validMoves->next;
}
So as far as I know, this should work perfectly. I've looked up examples
online and all my really convoluted uses of pointers in this particular
program have worked without a hitch thus far.
Anyway, the real problem is that if I don't prevent duplicates from being
entered into the same list (connected through pointers), then I get an
infinite loop (I imagine this is caused by two elements being considered
equal because their non-pointer types are equal).
I've posted all three parts of the code on pastebin for full reference (no
worries, open source, man!): othello.c othello_engine.c othello_engine.h
I've tried debugging but I'm not very good at that, I didn't really see
anything worth mentioning. Can anyone explain what might be happening
and/or give an example of how to avoid duplicates in a linked list? (I've
tried so many ways my brain hurts)
Thursday, 19 September 2013
Codeigniter - How to get values as array to use in next select with where_not_in
Codeigniter - How to get values as array to use in next select with
where_not_in
I have three tables; user, car and user_x_car. user_x_car holds users who
own car; user_id and car_id are stored. I want to get users who don't own
a car as follows:
$car_owner = $this->db->select()->from('user_x_car')->get()->result();
for ($i = 0; $i < count($car_owners); $i++)
$$car_owner_id[$i] = $car_owner[$i]->user_id;
$non_car_owner = $this->db->select()->from('user')->where_not_in('id',
$car_owner_id)->get()->result();
I get what I want, however, is there any way to bypass the for loop in the
middle which creates and array of id's selected in the first select. Is
there any way to get array of selected user_ids directly?
where_not_in
I have three tables; user, car and user_x_car. user_x_car holds users who
own car; user_id and car_id are stored. I want to get users who don't own
a car as follows:
$car_owner = $this->db->select()->from('user_x_car')->get()->result();
for ($i = 0; $i < count($car_owners); $i++)
$$car_owner_id[$i] = $car_owner[$i]->user_id;
$non_car_owner = $this->db->select()->from('user')->where_not_in('id',
$car_owner_id)->get()->result();
I get what I want, however, is there any way to bypass the for loop in the
middle which creates and array of id's selected in the first select. Is
there any way to get array of selected user_ids directly?
User defined Copy constructor
User defined Copy constructor
I'm getting compile errors for the below code but the same gets compiled
if I remove copy constructor statement.
Could anyone let me know about this behaviour?
class MyClass
{
private:
int i;
MyClass(MyClass &);
public:
MyClass():i(0){}
};
int main(){
MyClass obj = MyClass();
return 0;
}
I'm getting compile errors for the below code but the same gets compiled
if I remove copy constructor statement.
Could anyone let me know about this behaviour?
class MyClass
{
private:
int i;
MyClass(MyClass &);
public:
MyClass():i(0){}
};
int main(){
MyClass obj = MyClass();
return 0;
}
enclose table name containing spaces - d2rq language
enclose table name containing spaces - d2rq language
How do I enclose table name (sql server) containing space while mapping
files using d2rq language? table name is Compression Stats
So in my mapping file I have among other things:
d2rq:condition "Compression Stats.VelocityID = '2145C'" ;
I tried [], ```, () around table, and table.column, but nothing is
working. Does anyone know?
How do I enclose table name (sql server) containing space while mapping
files using d2rq language? table name is Compression Stats
So in my mapping file I have among other things:
d2rq:condition "Compression Stats.VelocityID = '2145C'" ;
I tried [], ```, () around table, and table.column, but nothing is
working. Does anyone know?
WIndows store create app packages not working with third party dll
WIndows store create app packages not working with third party dll
During the development of my Monogame game, I needed a calculation
library, and included a library called Jace. This works fine; however,
when I try to generate an Appx package for deployment to the Windows
Store, I get an error that the namespace for Jace can't be found.
My guess is that this means that I can't use a third party library. Is
this the case and, if so, is there a way around it, or do I need to
rewrite the entire library inside my Store App?
During the development of my Monogame game, I needed a calculation
library, and included a library called Jace. This works fine; however,
when I try to generate an Appx package for deployment to the Windows
Store, I get an error that the namespace for Jace can't be found.
My guess is that this means that I can't use a third party library. Is
this the case and, if so, is there a way around it, or do I need to
rewrite the entire library inside my Store App?
Extjs 3.4 ComboBox: how to preselect a record when the combobox is first loaded?
Extjs 3.4 ComboBox: how to preselect a record when the combobox is first
loaded?
I'm using Extjs 3.4. I need to set up a type ahead combobox like this: The
combobox is using a JsonStore, when the combobox is first loaded onto the
page, I need to preselect a value. Later on, the user can change the value
to other record.
combobox.store.on("load",function(){
combobox.setValue(value);
});
But the value will be set every time the combobox is loaded. I only need
to set up the value when it is first loaded.
Thanks in advance!
loaded?
I'm using Extjs 3.4. I need to set up a type ahead combobox like this: The
combobox is using a JsonStore, when the combobox is first loaded onto the
page, I need to preselect a value. Later on, the user can change the value
to other record.
combobox.store.on("load",function(){
combobox.setValue(value);
});
But the value will be set every time the combobox is loaded. I only need
to set up the value when it is first loaded.
Thanks in advance!
MySQL - One SQL request instead two (both request include diffrent COUNT(*)
MySQL - One SQL request instead two (both request include diffrent COUNT(*)
Once again i need yours help ;). I have a lot data and mysql request are
slower and slower so the need request that i need i want group in one
comand.
My example DB structure:
|product|opinion (pos/neg)|reason|
__________________________________
|milk | pos | good |
|milk | pos |fresh |
|chocolate| neg | old |
|milk | neg | from cow|
So i need information about all diffrent product (GROUP BY) count of it,
and count of pos opinion for each product. I want output like that:
|product|count|pos count|
_________________________
|milk | 3 | 2 |
|chocolate| 1 | 0 |
I hope that my explain was good enought ;) Or go to work: I write two
commands
SELECT COUNT(*) as pos count FROM table WHERE product = "milk" AND opinion
= "pos" GROUP BY `opinion`
And Second one
SELECT product, COUNT(*) FROM table GROUP BY `product`
I don't know how to join this two request, maybe that is impossible? In my
real use code i have additional category collumn and i use WHERE in second
command too
Once again i need yours help ;). I have a lot data and mysql request are
slower and slower so the need request that i need i want group in one
comand.
My example DB structure:
|product|opinion (pos/neg)|reason|
__________________________________
|milk | pos | good |
|milk | pos |fresh |
|chocolate| neg | old |
|milk | neg | from cow|
So i need information about all diffrent product (GROUP BY) count of it,
and count of pos opinion for each product. I want output like that:
|product|count|pos count|
_________________________
|milk | 3 | 2 |
|chocolate| 1 | 0 |
I hope that my explain was good enought ;) Or go to work: I write two
commands
SELECT COUNT(*) as pos count FROM table WHERE product = "milk" AND opinion
= "pos" GROUP BY `opinion`
And Second one
SELECT product, COUNT(*) FROM table GROUP BY `product`
I don't know how to join this two request, maybe that is impossible? In my
real use code i have additional category collumn and i use WHERE in second
command too
bb::cascades::Button: click handler - determining the sender
bb::cascades::Button: click handler - determining the sender
I'm creating multiple (undefined at design time) number of buttons
programatically. How can I determine which button was clicked in my
handler?
for (int i = 0; i < XXX; i++) {
Button *btn = Button::create();
QObject::connect(btn, SIGNAL(clicked()), this, SLOT(onButtonClicked()));
...
}
void MyClass::onButtonClicked() {
???? Which button ???
}
On all platforms I'v previously used (Borland.VCL, Cocoa, Cocoa Touch,
WinRT/PRT, Android...) event handler always(!!!) has a sender parameter
indicating the object instance invoked the event.
So, how to do it in BlackBerry Cascades?
PS. Pleas don't tell me I have to create my own Subclass of Button, add a
SIGNAL onClicked(MyButton *sender) and propagate it... This will end my
BlackBerry development in it's early beginning. :)
I'm creating multiple (undefined at design time) number of buttons
programatically. How can I determine which button was clicked in my
handler?
for (int i = 0; i < XXX; i++) {
Button *btn = Button::create();
QObject::connect(btn, SIGNAL(clicked()), this, SLOT(onButtonClicked()));
...
}
void MyClass::onButtonClicked() {
???? Which button ???
}
On all platforms I'v previously used (Borland.VCL, Cocoa, Cocoa Touch,
WinRT/PRT, Android...) event handler always(!!!) has a sender parameter
indicating the object instance invoked the event.
So, how to do it in BlackBerry Cascades?
PS. Pleas don't tell me I have to create my own Subclass of Button, add a
SIGNAL onClicked(MyButton *sender) and propagate it... This will end my
BlackBerry development in it's early beginning. :)
Wednesday, 18 September 2013
How to block eclipse P2 update Pop up in RCP application comes at right corner
How to block eclipse P2 update Pop up in RCP application comes at right
corner
I am having an RCP based application which has P2 update plugin installed.
I want to block the popup comes into the right end corner of RCP
application , whenever it get installed. I know it will come because of
version change or upgrade but I just dont want that popup to come. Either
that else there is a checkbox in install plug-in ![enter image description
here][1]
[1]: http://i.stack.imgur.com/9375i.png in Automatic Updates of Preference
page. I want to uncheck the checkbox by default.Even this issue will then
automatically solved.
corner
I am having an RCP based application which has P2 update plugin installed.
I want to block the popup comes into the right end corner of RCP
application , whenever it get installed. I know it will come because of
version change or upgrade but I just dont want that popup to come. Either
that else there is a checkbox in install plug-in ![enter image description
here][1]
[1]: http://i.stack.imgur.com/9375i.png in Automatic Updates of Preference
page. I want to uncheck the checkbox by default.Even this issue will then
automatically solved.
Is it possible to build iphoneos6.1 projects in Xcode 5, preserving the behaviour of views laid out in an Xcode 4.6.3 storyboard?
Is it possible to build iphoneos6.1 projects in Xcode 5, preserving the
behaviour of views laid out in an Xcode 4.6.3 storyboard?
Our build server was recently updated to use Xcode 5's xcodebuild. We've
installed the iphoneos6.1 so that we can still use iPhone SDK 6.1 for some
legacy projects that do not yet support iOS7. However, when we use
xcodebuild to build these projects using -sdk iphoneos6.1, we still see
problems with UIViewController's contents being laid out underneath
navigation bars and tab bars.
Is there some way to build these projects that were developed with Xcode
4.6.3/base sdk iOS 6.1 using Xcode 5's xcodebuild, but preserving the
views as they were laid out in the storyboard developed using Xcode 4.6.3?
I took a look at the man page for ibtool, but I'm not seeing any option
related to choosing a target SDK, or anything else that seems relevant to
the "extends edges" problem I noted above.
Note that we haven't updated the storyboard using Xcode 5 - the project is
continuing to be developed in Xcode 4.6.3, and only touches the Xcode 5
toolchain when our build server clones the project's git repo and builds
using xcodebuild.
behaviour of views laid out in an Xcode 4.6.3 storyboard?
Our build server was recently updated to use Xcode 5's xcodebuild. We've
installed the iphoneos6.1 so that we can still use iPhone SDK 6.1 for some
legacy projects that do not yet support iOS7. However, when we use
xcodebuild to build these projects using -sdk iphoneos6.1, we still see
problems with UIViewController's contents being laid out underneath
navigation bars and tab bars.
Is there some way to build these projects that were developed with Xcode
4.6.3/base sdk iOS 6.1 using Xcode 5's xcodebuild, but preserving the
views as they were laid out in the storyboard developed using Xcode 4.6.3?
I took a look at the man page for ibtool, but I'm not seeing any option
related to choosing a target SDK, or anything else that seems relevant to
the "extends edges" problem I noted above.
Note that we haven't updated the storyboard using Xcode 5 - the project is
continuing to be developed in Xcode 4.6.3, and only touches the Xcode 5
toolchain when our build server clones the project's git repo and builds
using xcodebuild.
How to Add Student_ID to Devise Confirmation Email To Be Emailed to User
How to Add Student_ID to Devise Confirmation Email To Be Emailed to User
I have a rails application where a user needs its student_id to access
some features.
The default devise confirmation email is this
<p>Welcome <%= @email %>!</p>
<p>You can confirm your account email through the link below:</p>
<p><%= link_to 'Confirm my account', confirmation_url(@resource,
:confirmation_token => @resource.confirmation_token) %></p>
I want to know where the
<%= @email %>
is from ?
I tried adding
<p>Your student id is <%= @student_id %> ! Please don't forget ! </p>
but it did not work.
I have this in my routes
devise_for :students
then a link_to to the new_student_registration path in
application.html.erb and then a simple_form in that registration view
under devise, after a user signs up the user will get a confirmation email
sent by sendgrid.
My question is won't that particular student's record be exposed during
the sequence from above? and hence that is where the
<%= @email %> comes from?
why can't I pass in the student id to be emailed as well?
I have a rails application where a user needs its student_id to access
some features.
The default devise confirmation email is this
<p>Welcome <%= @email %>!</p>
<p>You can confirm your account email through the link below:</p>
<p><%= link_to 'Confirm my account', confirmation_url(@resource,
:confirmation_token => @resource.confirmation_token) %></p>
I want to know where the
<%= @email %>
is from ?
I tried adding
<p>Your student id is <%= @student_id %> ! Please don't forget ! </p>
but it did not work.
I have this in my routes
devise_for :students
then a link_to to the new_student_registration path in
application.html.erb and then a simple_form in that registration view
under devise, after a user signs up the user will get a confirmation email
sent by sendgrid.
My question is won't that particular student's record be exposed during
the sequence from above? and hence that is where the
<%= @email %> comes from?
why can't I pass in the student id to be emailed as well?
Simplest way to restrict access to Cloudfront(S3) files from some users but not others
Simplest way to restrict access to Cloudfront(S3) files from some users
but not others
I'm just getting started with permissions on AWS S3 and Cloudfront so
please take it easy on me.
Two main questions:
I'd like to allow access to some users (e.g., those that are logged in)
but not others. I assume I need to be using ACLs instead of a bucket
policy since the former is more customizable in that you can identify the
user in the URL with query parameters. First of all is this correct? Can
someone point me to the plainest english description of how to do this on
a file/user-by-file/user basis? The documentation on ACL confuses the heck
out of me.
I'd also like to restrict access such that people can only view content on
my-site.com and not your-site.com. Unfortunately the S3 documentation
example bucket policy for this has no effect on access for my demo bucket
(see code below, slightly adapted from AWS docs). Moreover, if I need to
foremost be focusing on allowing user-by-user access, do I even want to be
defining a bucket policy?
I realize i'm not even touching on how to make this work in the context of
Cloudfront (the ultimate goal) but any thoughts on questions 1 and 2 would
be greatly appreciated and mentioning Cloudfront would be a bonus at this
point.
`
{
"Version": "2008-10-17",
"Id":"http referer policy example",
"Statement": [
{
"Sid": "AllowPublicRead",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::my-bucket/*",
"Condition": {
"StringLike": {
"aws:Referer": [
"https://mysite.com/*",
"https://www.mysite.com/*"
]
}
}
}
]
}
but not others
I'm just getting started with permissions on AWS S3 and Cloudfront so
please take it easy on me.
Two main questions:
I'd like to allow access to some users (e.g., those that are logged in)
but not others. I assume I need to be using ACLs instead of a bucket
policy since the former is more customizable in that you can identify the
user in the URL with query parameters. First of all is this correct? Can
someone point me to the plainest english description of how to do this on
a file/user-by-file/user basis? The documentation on ACL confuses the heck
out of me.
I'd also like to restrict access such that people can only view content on
my-site.com and not your-site.com. Unfortunately the S3 documentation
example bucket policy for this has no effect on access for my demo bucket
(see code below, slightly adapted from AWS docs). Moreover, if I need to
foremost be focusing on allowing user-by-user access, do I even want to be
defining a bucket policy?
I realize i'm not even touching on how to make this work in the context of
Cloudfront (the ultimate goal) but any thoughts on questions 1 and 2 would
be greatly appreciated and mentioning Cloudfront would be a bonus at this
point.
`
{
"Version": "2008-10-17",
"Id":"http referer policy example",
"Statement": [
{
"Sid": "AllowPublicRead",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::my-bucket/*",
"Condition": {
"StringLike": {
"aws:Referer": [
"https://mysite.com/*",
"https://www.mysite.com/*"
]
}
}
}
]
}
Benefit of defining success/failure function instead of using success/!success
Benefit of defining success/failure function instead of using
success/!success
I was reading man page of gearman code
(http://manpages.ubuntu.com/manpages/precise/man3/gearman_success.3.html).
They are having two functions
bool gearman_success(gearman_return_t rc)
bool gearman_failed(gearman_return_t rc)
And code of those functions look like (libgearman-1.0/return.h):
static inline bool gearman_failed(enum gearman_return_t rc)
{
return rc != GEARMAN_SUCCESS;
}
static inline bool gearman_success(enum gearman_return_t rc)
{
return rc == GEARMAN_SUCCESS;
}
Both function does nearly same thing. One return true and another false.
What is the benefit of this code ?
Why not just have !gearman_success
Is there benefit of coding pattern or something , which I am missing here.
success/!success
I was reading man page of gearman code
(http://manpages.ubuntu.com/manpages/precise/man3/gearman_success.3.html).
They are having two functions
bool gearman_success(gearman_return_t rc)
bool gearman_failed(gearman_return_t rc)
And code of those functions look like (libgearman-1.0/return.h):
static inline bool gearman_failed(enum gearman_return_t rc)
{
return rc != GEARMAN_SUCCESS;
}
static inline bool gearman_success(enum gearman_return_t rc)
{
return rc == GEARMAN_SUCCESS;
}
Both function does nearly same thing. One return true and another false.
What is the benefit of this code ?
Why not just have !gearman_success
Is there benefit of coding pattern or something , which I am missing here.
How to put data from various .cshtm files into of _Layout.cshtml?
How to put data from various .cshtm files into of _Layout.cshtml?
My _Layout.cshtml file has three "div" situated in one "div"(div
id="content"). The full code is:
<body id="bckgrimg">
<div id="content">
<div id="leftcolumn">
<ul >
<li><a href="home/contactus">Contact us</a></li>
<li><a href="home/aboutus">About us</a></li>
</ul>
</div>
<div id="centercolumn">
We'll put something useful here later
</div>
<div id="rightcolumn">
<div id="gallery">
<a href="../Slide1.JPG"><img src="..."/></a>
<a href="../horse_B.jpg"><img src="..."/></a>
<a href="../shore_B.jpg"><img src="..."/></a>
</div>
</div>
</div>
I have tried to put data by writing "some text" in xxx.cshtml but I just
add new element on a web page as I have yet created in _Layout.cshtml. I
just would like to put exactly data from various .cshtml files into of
_Layout.cshtml.
Is it possible to put data from xxx.cshtml file into (Where it is wtiiten
"We'll put something useful here later") of_Layout.cshtml?
My _Layout.cshtml file has three "div" situated in one "div"(div
id="content"). The full code is:
<body id="bckgrimg">
<div id="content">
<div id="leftcolumn">
<ul >
<li><a href="home/contactus">Contact us</a></li>
<li><a href="home/aboutus">About us</a></li>
</ul>
</div>
<div id="centercolumn">
We'll put something useful here later
</div>
<div id="rightcolumn">
<div id="gallery">
<a href="../Slide1.JPG"><img src="..."/></a>
<a href="../horse_B.jpg"><img src="..."/></a>
<a href="../shore_B.jpg"><img src="..."/></a>
</div>
</div>
</div>
I have tried to put data by writing "some text" in xxx.cshtml but I just
add new element on a web page as I have yet created in _Layout.cshtml. I
just would like to put exactly data from various .cshtml files into of
_Layout.cshtml.
Is it possible to put data from xxx.cshtml file into (Where it is wtiiten
"We'll put something useful here later") of_Layout.cshtml?
Printed text in while loop doesn't act as expected
Printed text in while loop doesn't act as expected
This code:
while ($row = mysql_fetch_assoc($result)) {
$username=$row["username"];
$currentroles[$username]=$row["role"];
print "abc";
echo "<tr><td>$username</td>";
echo "def";
echo "<td><select name=\"role[$username]\">";
if($row["role"]=='admin')
{
echo "<option value=\"admin\">admin</option>";
echo "<option value=\"user\">user</option>";
}
else if($row["role"]=='user')
{
echo "<option value=\"user\">user</option>";
echo "<option value=\"admin\">admin</option>";
}
echo "</select></td></tr><br/>";
}
Produces this page:
(this is just a part of the page, there are as many users with a dropdown
list as "abcdef"s)
I have no idea why are the "abc", "def" strings at the top of the page. If
I take them out, there are empty lines in the page (instead of "abcdef)",
even though I never printed <br>. What's going on?
This code:
while ($row = mysql_fetch_assoc($result)) {
$username=$row["username"];
$currentroles[$username]=$row["role"];
print "abc";
echo "<tr><td>$username</td>";
echo "def";
echo "<td><select name=\"role[$username]\">";
if($row["role"]=='admin')
{
echo "<option value=\"admin\">admin</option>";
echo "<option value=\"user\">user</option>";
}
else if($row["role"]=='user')
{
echo "<option value=\"user\">user</option>";
echo "<option value=\"admin\">admin</option>";
}
echo "</select></td></tr><br/>";
}
Produces this page:
(this is just a part of the page, there are as many users with a dropdown
list as "abcdef"s)
I have no idea why are the "abc", "def" strings at the top of the page. If
I take them out, there are empty lines in the page (instead of "abcdef)",
even though I never printed <br>. What's going on?
User defined Objects equality always returns false
User defined Objects equality always returns false
Class Product def initialize(name, qty) @name = name @qty = qty end def
to_s "#{@name}, #{@qty}" end end
irb> Product.new("Amazon", 3) == Product.new ("Amazon", 3) irb> false
Ruby always returns false for these type of user defined objects which is
wrong, how to make them true if they are equal and false if they are wrong
Class Product def initialize(name, qty) @name = name @qty = qty end def
to_s "#{@name}, #{@qty}" end end
irb> Product.new("Amazon", 3) == Product.new ("Amazon", 3) irb> false
Ruby always returns false for these type of user defined objects which is
wrong, how to make them true if they are equal and false if they are wrong
Tuesday, 17 September 2013
How do I initialize an instance variable?
How do I initialize an instance variable?
I have a class called Countdown with a constructor:
Countdown(int[][][] countdown): How do I initialize an instance variable
to reference the countdown thats passed into the constructor as a
parameter
Many thanks!
I have a class called Countdown with a constructor:
Countdown(int[][][] countdown): How do I initialize an instance variable
to reference the countdown thats passed into the constructor as a
parameter
Many thanks!
jQuery animated header and footer not working in IE 9 & 10
jQuery animated header and footer not working in IE 9 & 10
can anybody help me with this?
The header and footer slide in to the page just after loading and it all
works perfectly in all browsers except for IE 9 and 10 (IE 8 is fine),
here's the test version
http://surefireresearchtestsite.businesscatalyst.com
I am using bigvideo.js on the page; when I disable bigvideo.js it all
works fine, so I guess the problem lies there somewhere but what the
conflict is I just don't know, and turning it off is not an option. I've
tried changing the order of the scripts, thought that might have some
affect, but no. I'm quite new to jQuery so am at a loss of how to fix
this.
<script>
//$(function(){
$(document).ready(function() {
//removes the flash of unstyled content
$('.no-fouc').removeClass('no-fouc');
//fade in body content
$('#bgFade').hide();
$('#bgFade').delay(800).fadeIn(1800);
//hide all content that can be toggled - the button in the footer
$('.but2').hide();
//on clicking the first button
$(document).on("click", "img.but1", function(e){
e.preventDefault(); //this is preventing the page jitter to top and back
$('html,body').scrollTo( {top:'+=500px', left:'0px'}, 400 );
$('.but1').hide();
$('.but2').show();
});
//on clicking the second button
$(document).on("click", "img.but2", function(e){
e.preventDefault(); //preventing the page jittering to top
$('.but1').show();
$('.but2').hide();
$('html,body').scrollTo( {top:'+=-500px', left:'0px'}, 400 );
});
//animated header - drop down from off screen after loading page
$('#dropDown').bounceThis({
bounceHeight : '3px',
dropDownSpeed : 400,
delay : 1200
});
//animated footer - rise up from off screen after loading page
$('#footerSlideContent').delay( 1600 ).animate({ height: '145px' });
$(this).css('backgroundPosition', 'bottom left');
open = true;
//background video
var BV = new $.BigVideo();
BV.init();
BV.show('video/surefireRedBg.mp4',{ambient:true});
});
</script>
If anybody could take a look and see what the problem is I'd be most
grateful. Thanks in advance.
can anybody help me with this?
The header and footer slide in to the page just after loading and it all
works perfectly in all browsers except for IE 9 and 10 (IE 8 is fine),
here's the test version
http://surefireresearchtestsite.businesscatalyst.com
I am using bigvideo.js on the page; when I disable bigvideo.js it all
works fine, so I guess the problem lies there somewhere but what the
conflict is I just don't know, and turning it off is not an option. I've
tried changing the order of the scripts, thought that might have some
affect, but no. I'm quite new to jQuery so am at a loss of how to fix
this.
<script>
//$(function(){
$(document).ready(function() {
//removes the flash of unstyled content
$('.no-fouc').removeClass('no-fouc');
//fade in body content
$('#bgFade').hide();
$('#bgFade').delay(800).fadeIn(1800);
//hide all content that can be toggled - the button in the footer
$('.but2').hide();
//on clicking the first button
$(document).on("click", "img.but1", function(e){
e.preventDefault(); //this is preventing the page jitter to top and back
$('html,body').scrollTo( {top:'+=500px', left:'0px'}, 400 );
$('.but1').hide();
$('.but2').show();
});
//on clicking the second button
$(document).on("click", "img.but2", function(e){
e.preventDefault(); //preventing the page jittering to top
$('.but1').show();
$('.but2').hide();
$('html,body').scrollTo( {top:'+=-500px', left:'0px'}, 400 );
});
//animated header - drop down from off screen after loading page
$('#dropDown').bounceThis({
bounceHeight : '3px',
dropDownSpeed : 400,
delay : 1200
});
//animated footer - rise up from off screen after loading page
$('#footerSlideContent').delay( 1600 ).animate({ height: '145px' });
$(this).css('backgroundPosition', 'bottom left');
open = true;
//background video
var BV = new $.BigVideo();
BV.init();
BV.show('video/surefireRedBg.mp4',{ambient:true});
});
</script>
If anybody could take a look and see what the problem is I'd be most
grateful. Thanks in advance.
Storing an Object into a temporary Object and not changing the original Objects value
Storing an Object into a temporary Object and not changing the original
Objects value
I have an object stored in a global variable let's say:
static ArrayList<Object> list = new ArrayList<Object>();
I want to store it later to look into it without actually changing the
values in the structure itself. So I am doing something similar to this:
public void someMethod()
{
ArrayList<Object> tempList = new ArrayList<Object>();
tempList = list;
list.remove(0);
}
I'm thinking this may have something to do with me initializing the
variable as "static". I don't usually do that but Eclipse told me I had to
so I just let the change happen.
My understanding would be that I am storing the original list into a
temporary list and anything I do to the temporary list would be
independent of the original list. But it appears that if I were to remove
something from this above list, that the original list is removing it as
well.
I remember learning that this could happen sometimes but I think I've done
this before without having that issue.
I apologize if this is a repeated question but the way I worded it didn't
show me an question that was similar.
Thanks!
Objects value
I have an object stored in a global variable let's say:
static ArrayList<Object> list = new ArrayList<Object>();
I want to store it later to look into it without actually changing the
values in the structure itself. So I am doing something similar to this:
public void someMethod()
{
ArrayList<Object> tempList = new ArrayList<Object>();
tempList = list;
list.remove(0);
}
I'm thinking this may have something to do with me initializing the
variable as "static". I don't usually do that but Eclipse told me I had to
so I just let the change happen.
My understanding would be that I am storing the original list into a
temporary list and anything I do to the temporary list would be
independent of the original list. But it appears that if I were to remove
something from this above list, that the original list is removing it as
well.
I remember learning that this could happen sometimes but I think I've done
this before without having that issue.
I apologize if this is a repeated question but the way I worded it didn't
show me an question that was similar.
Thanks!
Is There An Easy Way To Comment Out XAML Code in Microsoft Blend?
Is There An Easy Way To Comment Out XAML Code in Microsoft Blend?
I've been using Blend 4 for a while, especially when customizing
templates, and one thing irks me. There's no 'comment' button, so I can't
easily wrap a highlighted section of XAML with HTML comments (<!-- -->).
Is there any workaround for this, or am I forever stuck having to type those.
NOTE: I did see a macro extension that allows you to open/close comment
with a shortcut key, but sadly it doesn't install with my version of
Blend.
I've been using Blend 4 for a while, especially when customizing
templates, and one thing irks me. There's no 'comment' button, so I can't
easily wrap a highlighted section of XAML with HTML comments (<!-- -->).
Is there any workaround for this, or am I forever stuck having to type those.
NOTE: I did see a macro extension that allows you to open/close comment
with a shortcut key, but sadly it doesn't install with my version of
Blend.
Check and Uncheck Checkbox Dynamically with jQuery : bug? II
Check and Uncheck Checkbox Dynamically with jQuery : bug? II
I want to use the same functionality as described at Check and Uncheck
Checkbox Dynamically with jQuery : bug? - i.e. one master checkbox and two
slaves checkboxes.
The difference compared to the previous question is that I need to declare
all the checkboxes as button() (as contained here:
http://jqueryui.com/button/#checkbox ):
$(document).ready(function() {
$( "#myCheck" ).button();
$( "#myCheck2" ).button();
$( "#myCheck3" ).button();
$('#myCheck').click(function() {
$('.myCheck').prop('checked', false);
});
$('.myCheck').click(function() {
if ($('.myCheck').is(':checked')) {
$('#myCheck').prop('checked', false);
} else {
$('#myCheck').prop('checked', true);
//alert("Checkbox Master must be checked, but it's not!");
}
});
});
See http://jsfiddle.net/uQfMs/90/
The outcome of this difference is that the functionality is away. I cannot
find why.
I want to use the same functionality as described at Check and Uncheck
Checkbox Dynamically with jQuery : bug? - i.e. one master checkbox and two
slaves checkboxes.
The difference compared to the previous question is that I need to declare
all the checkboxes as button() (as contained here:
http://jqueryui.com/button/#checkbox ):
$(document).ready(function() {
$( "#myCheck" ).button();
$( "#myCheck2" ).button();
$( "#myCheck3" ).button();
$('#myCheck').click(function() {
$('.myCheck').prop('checked', false);
});
$('.myCheck').click(function() {
if ($('.myCheck').is(':checked')) {
$('#myCheck').prop('checked', false);
} else {
$('#myCheck').prop('checked', true);
//alert("Checkbox Master must be checked, but it's not!");
}
});
});
See http://jsfiddle.net/uQfMs/90/
The outcome of this difference is that the functionality is away. I cannot
find why.
what is Turbo sim unlocked iPhone ? how is differ with factory unlock and unlocked iphone?
what is Turbo sim unlocked iPhone ? how is differ with factory unlock and
unlocked iphone?
what is Turbo sim unlocked iPhone ? how is differ with factory unlock and
unlock iphone ? what are the disadvantages of turbo sim unlocked ?
Thanks in advance !!!
unlocked iphone?
what is Turbo sim unlocked iPhone ? how is differ with factory unlock and
unlock iphone ? what are the disadvantages of turbo sim unlocked ?
Thanks in advance !!!
Sunday, 15 September 2013
why wont my containers extend to encompass my content?
why wont my containers extend to encompass my content?
I'm having issues getting my content box to extend to encompass everything
within it. shouldnt max-height:100% do this?
http://codepen.io/anon/pen/xujAC
There's the codepen of my code. The red and blue background are for visual
reference only. Shouldnt the blue background (.container) only extend 20px
below the blocks?
Pretty new at this and learning as I go. I'm probably missing something easy.
Thanks a lot.
I'm having issues getting my content box to extend to encompass everything
within it. shouldnt max-height:100% do this?
http://codepen.io/anon/pen/xujAC
There's the codepen of my code. The red and blue background are for visual
reference only. Shouldnt the blue background (.container) only extend 20px
below the blocks?
Pretty new at this and learning as I go. I'm probably missing something easy.
Thanks a lot.
Edittext field next defers to itself
Edittext field next defers to itself
I'm trying to make it so if a user selects an edittext box, it clears it.
Now through trying to do this, it appears that hitting next still keeps
the focus in the same text box and clears it. I tried
rows = (EditText) findViewById(R.id.editText1);
cols = (EditText) findViewById(R.id.editText2);
ticks = (EditText) findViewById(R.id.editText3);
rows.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
rows.setText("");
//cols.requestFocus();
}
});
cols.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
cols.setText("");
//ticks.requestFocus();
}
});
ticks.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
ticks.setText("");
}
});
now i tried doing request focus in the onclick, which successfully moves
the focus to the the next edittext, but it clears what was in the previous
edittext as it does that. How can I make the edittexts clear the text when
a user selects it, yet still retain it's normal "next" properties.
I'm trying to make it so if a user selects an edittext box, it clears it.
Now through trying to do this, it appears that hitting next still keeps
the focus in the same text box and clears it. I tried
rows = (EditText) findViewById(R.id.editText1);
cols = (EditText) findViewById(R.id.editText2);
ticks = (EditText) findViewById(R.id.editText3);
rows.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
rows.setText("");
//cols.requestFocus();
}
});
cols.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
cols.setText("");
//ticks.requestFocus();
}
});
ticks.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
ticks.setText("");
}
});
now i tried doing request focus in the onclick, which successfully moves
the focus to the the next edittext, but it clears what was in the previous
edittext as it does that. How can I make the edittexts clear the text when
a user selects it, yet still retain it's normal "next" properties.
How to download youtube api jar for android
How to download youtube api jar for android
im trying to use youtube api codes but i cant find from where i download
the correct jars.
I got to this page:
https://code.google.com/p/google-api-java-client/wiki/APIs#YouTube_Data_API
I downloaded the file but i got there many jars and on the developers site
its not wrinten which jars i should import.
I trired to import the file called:
google-api-services-youtube-v3-rev77-1.17.0-rc from the root folder but
when i try to use sample code eclipse cant find the imports.
The sample code is here:
https://developers.google.com/youtube/v3/code_samples/java#search_by_keyword
When im trying to use
private static final JsonFactory JSON_FACTORY = new JacksonFactory();
Eclipse cant find from to import the files.
I dont understand why using youtube api should be so complicated. why not
putting all the code on one simple jar.
im trying to use youtube api codes but i cant find from where i download
the correct jars.
I got to this page:
https://code.google.com/p/google-api-java-client/wiki/APIs#YouTube_Data_API
I downloaded the file but i got there many jars and on the developers site
its not wrinten which jars i should import.
I trired to import the file called:
google-api-services-youtube-v3-rev77-1.17.0-rc from the root folder but
when i try to use sample code eclipse cant find the imports.
The sample code is here:
https://developers.google.com/youtube/v3/code_samples/java#search_by_keyword
When im trying to use
private static final JsonFactory JSON_FACTORY = new JacksonFactory();
Eclipse cant find from to import the files.
I dont understand why using youtube api should be so complicated. why not
putting all the code on one simple jar.
Trying to obtain memberof detail from linux ldapsearch command
Trying to obtain memberof detail from linux ldapsearch command
I am trying run an LDAP query from a Linux machine (CentOS 5.8) to a
Windows LDAP server and want to get 'memberof' detail for a user. In this
example, the Domain is cm.loc and the user is admin1@cm.loc. Here is the
ldapsearch syntax I am using. It returns an error. Can someone point me in
the right direction with what the correct syntax should be using
ldapsearch to query for memberof detail for a particular account?
Here is what I am using that returns error; "ldap search ext bad search
filter 7" Where is my syntax wrong?
ldapsearch –x –h 192.168.1.20 –b 'DC=cm,DC=loc' -s base –D 'admin1@cm.loc'
-W '(&(objectCategory=Group)(|(memberOf=group1)(memberOf=group2)…))'
Thank You
I am trying run an LDAP query from a Linux machine (CentOS 5.8) to a
Windows LDAP server and want to get 'memberof' detail for a user. In this
example, the Domain is cm.loc and the user is admin1@cm.loc. Here is the
ldapsearch syntax I am using. It returns an error. Can someone point me in
the right direction with what the correct syntax should be using
ldapsearch to query for memberof detail for a particular account?
Here is what I am using that returns error; "ldap search ext bad search
filter 7" Where is my syntax wrong?
ldapsearch –x –h 192.168.1.20 –b 'DC=cm,DC=loc' -s base –D 'admin1@cm.loc'
-W '(&(objectCategory=Group)(|(memberOf=group1)(memberOf=group2)…))'
Thank You
Stuck with mootools script. Image autochange
Stuck with mootools script. Image autochange
<div id="contentimage">
<img src="1.jpg" class="activeimage" />
<img src="2.jpg" style="opacity: 0;" />
<img src="3.jpg" class="last" style="opacity: 0;" />
</div>
<script>
window.addEvent('domready', function() {
var fx = function() {
var activeimage = $$('img.activeimage');
if(!activeimage.hasClass('last')) {
var next = activeimage.getNext('img');
activeimage.toggleClass('activeimage');
next.toggleClass('activeimage');
activeimage.morph({'opacity':'0'});
next.morph({'opacity':'1'});
} else {
var next = $('contentimage').getFirst('img');
activeimage.toggleClass('activeimage');
next.toggleClass('activeimage');
activeimage.morph({'opacity':'0'});
next.morph({'opacity':'1'});
}
}
fx.periodical(3000);
});
</script>
I just can't understand why this :
if(!activeimage.hasClass('last'))
always returns false ? I tried to check it with "alert", and it was all
good, but when it comes to this line - it goes not like I expected.
<div id="contentimage">
<img src="1.jpg" class="activeimage" />
<img src="2.jpg" style="opacity: 0;" />
<img src="3.jpg" class="last" style="opacity: 0;" />
</div>
<script>
window.addEvent('domready', function() {
var fx = function() {
var activeimage = $$('img.activeimage');
if(!activeimage.hasClass('last')) {
var next = activeimage.getNext('img');
activeimage.toggleClass('activeimage');
next.toggleClass('activeimage');
activeimage.morph({'opacity':'0'});
next.morph({'opacity':'1'});
} else {
var next = $('contentimage').getFirst('img');
activeimage.toggleClass('activeimage');
next.toggleClass('activeimage');
activeimage.morph({'opacity':'0'});
next.morph({'opacity':'1'});
}
}
fx.periodical(3000);
});
</script>
I just can't understand why this :
if(!activeimage.hasClass('last'))
always returns false ? I tried to check it with "alert", and it was all
good, but when it comes to this line - it goes not like I expected.
SQL: Join value from another table
SQL: Join value from another table
I have 1 table called accounts and another one called level_points
Basically the idea is to determine what is the minimum amount of points
you need to be X level.
Account Structure
id, name.. etc. points
Level_Points Structure
level, points
Values in here such as
(1, 5) (2, 10) (3, 15)
I'm able to calculate the level using this query
"SELECT level FROM level_points WHERE points <= (SELECT points FROM
accounts WHERE id = 'x') ORDER BY level DESC LIMIT 1"
My problem is that now i'm trying to join the tables to get something like
this (For every user in the accounts table)
Result:
For user 1: id, name etc... points, level For user 2: id, name etc...
points, level For user 3: id, name etc... points, level
I'm not exactly sure how to do this using joins and I can't seem to find
an answer here that helps me here. Thanks.
I have 1 table called accounts and another one called level_points
Basically the idea is to determine what is the minimum amount of points
you need to be X level.
Account Structure
id, name.. etc. points
Level_Points Structure
level, points
Values in here such as
(1, 5) (2, 10) (3, 15)
I'm able to calculate the level using this query
"SELECT level FROM level_points WHERE points <= (SELECT points FROM
accounts WHERE id = 'x') ORDER BY level DESC LIMIT 1"
My problem is that now i'm trying to join the tables to get something like
this (For every user in the accounts table)
Result:
For user 1: id, name etc... points, level For user 2: id, name etc...
points, level For user 3: id, name etc... points, level
I'm not exactly sure how to do this using joins and I can't seem to find
an answer here that helps me here. Thanks.
How to sort a given string "ORACLE" in ascending order in oracle?
How to sort a given string "ORACLE" in ascending order in oracle?
String="ORACLE"
Out Put Like "ACELOR"
How to write Query? or Pl/Sql Program?
String="ORACLE"
Out Put Like "ACELOR"
How to write Query? or Pl/Sql Program?
Saturday, 14 September 2013
Connect to Office 365 from objective-c
Connect to Office 365 from objective-c
Is it possible to connect to the Office 365 service and manage users via
objective-c ? Has anyone had any success with this before?
Is it possible to connect to the Office 365 service and manage users via
objective-c ? Has anyone had any success with this before?
MouseEnter ContextMenu.StaysOpen doesn't respond
MouseEnter ContextMenu.StaysOpen doesn't respond
I've build a WPF application that contains a button, which activates a
drop-down sub-menu. My intent for the button behavior was to make it so
when it is moused-over, the sub-menu appears and you can access it.
Likewise, when the mouse goes off it, the sub-menu disappears. Pretty
basic function.
I'm tried using the MouseEnter xaml and this is where my problem occurs. I
tell the contextmenu to stay open using ContextMenu.IsOpen = true , then
call ContextMenu.StaysOpen = false in the MouseLeave to close it.
private void AdminButton_MouseEnter(object sender, MouseEventArgs e)
{
(sender as Button).ContextMenu.IsEnabled = true;
(sender as Button).ContextMenu.PlacementTarget = (sender as Button);
(sender as Button).ContextMenu.Placement =
System.Windows.Controls.Primitives.PlacementMode.Bottom;
(sender as Button).ContextMenu.IsOpen = true;
(sender as Button).ContextMenu.StaysOpen = false;
}
private void AdminButton_MouseLeave(object sender, MouseEventArgs e)
{
(sender as Button).ContextMenu.StaysOpen = false;
}
The result is that once I mouse over the button, it stays active and the
submenu exists until I click elsewhere on the screen. I'm pretty confused
by this behavior, shouldn't the ContextMenu.StaysOpen = false close the
submenu?
I've already tried to use both MouseEnter/MouseLeave and the most common
behavior is that the second the cursor comes off the button to access the
submenu, the submenu disappears.
I figure if I can't make these commands work, there must be some way to
suspend the MouseLeave duration so the user can get to the submenu before
it closes???
not many examples on the web concerning this action for a button or
textblock, so any help would be great.
I've build a WPF application that contains a button, which activates a
drop-down sub-menu. My intent for the button behavior was to make it so
when it is moused-over, the sub-menu appears and you can access it.
Likewise, when the mouse goes off it, the sub-menu disappears. Pretty
basic function.
I'm tried using the MouseEnter xaml and this is where my problem occurs. I
tell the contextmenu to stay open using ContextMenu.IsOpen = true , then
call ContextMenu.StaysOpen = false in the MouseLeave to close it.
private void AdminButton_MouseEnter(object sender, MouseEventArgs e)
{
(sender as Button).ContextMenu.IsEnabled = true;
(sender as Button).ContextMenu.PlacementTarget = (sender as Button);
(sender as Button).ContextMenu.Placement =
System.Windows.Controls.Primitives.PlacementMode.Bottom;
(sender as Button).ContextMenu.IsOpen = true;
(sender as Button).ContextMenu.StaysOpen = false;
}
private void AdminButton_MouseLeave(object sender, MouseEventArgs e)
{
(sender as Button).ContextMenu.StaysOpen = false;
}
The result is that once I mouse over the button, it stays active and the
submenu exists until I click elsewhere on the screen. I'm pretty confused
by this behavior, shouldn't the ContextMenu.StaysOpen = false close the
submenu?
I've already tried to use both MouseEnter/MouseLeave and the most common
behavior is that the second the cursor comes off the button to access the
submenu, the submenu disappears.
I figure if I can't make these commands work, there must be some way to
suspend the MouseLeave duration so the user can get to the submenu before
it closes???
not many examples on the web concerning this action for a button or
textblock, so any help would be great.
SSRS passing parameters to a web service call
SSRS passing parameters to a web service call
I'm calling a function on an XML web service, and that service requires a
boolean value. But I am at a loss as to how to send a value. It looks like
I'll need a parameter, but it's not having any effect. I've got a
parameter that needs to be put into the report, calling it Boolean at the
moment for simplicity.
<Parameters>
<Parameter Name="Boolean"/>
</Parameters>
This isn't having any effect on the result, it's always being treated as a
function with the default value of false.
I'm calling a function on an XML web service, and that service requires a
boolean value. But I am at a loss as to how to send a value. It looks like
I'll need a parameter, but it's not having any effect. I've got a
parameter that needs to be put into the report, calling it Boolean at the
moment for simplicity.
<Parameters>
<Parameter Name="Boolean"/>
</Parameters>
This isn't having any effect on the result, it's always being treated as a
function with the default value of false.
Exception from writeln function if the input size is big
Exception from writeln function if the input size is big
I am reading the amplitudes of a audio file in D. From string I am
converting the into float[] Than I am writing it like :
auto amplitudeByTime = file2string("data8.txt");//file2string returns
a float[] with size I determine.
writeln(amplitudeByTime);
Everything is ok if the size of float[] is 1660(or less) but when it to
1661(or more) writeln throws an exception like:
std.stdio.StdioException@std\stdio.d(2431): Bad file descriptor
----------------
0x0040EA7B
0x00411F62
0x0040FD80
0x0040FDBB
0x0040F9B9
0x0040B774
0x75EDD2E9 in BaseThreadInitThunk
0x77BF1603 in RtlInitializeExceptionChain
0x77BF15D6 in RtlInitializeExceptionChain
----------------
Do you have any idea about what might be problem?
I am reading the amplitudes of a audio file in D. From string I am
converting the into float[] Than I am writing it like :
auto amplitudeByTime = file2string("data8.txt");//file2string returns
a float[] with size I determine.
writeln(amplitudeByTime);
Everything is ok if the size of float[] is 1660(or less) but when it to
1661(or more) writeln throws an exception like:
std.stdio.StdioException@std\stdio.d(2431): Bad file descriptor
----------------
0x0040EA7B
0x00411F62
0x0040FD80
0x0040FDBB
0x0040F9B9
0x0040B774
0x75EDD2E9 in BaseThreadInitThunk
0x77BF1603 in RtlInitializeExceptionChain
0x77BF15D6 in RtlInitializeExceptionChain
----------------
Do you have any idea about what might be problem?
Magento - set currency when creating order programatically?
Magento - set currency when creating order programatically?
I have a dev magento with multi-currency enabled (GBP, EUR , USD). I am
trying to create a sales order against my dev magento in Euro - however
the order keeps creating in GBP (my base currency).
Any idea what I am doing wrong? Here's my code so far:
<?php
// Init Magento In Admin Store Context
require_once '/home/www-data/public_html/app/Mage.php';
$app = Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
// Function To Generate Magento Sales Order
function CreateOrder($orderData = array())
{
// Validate Order Data
if (!sizeof($orderData)) {
exit('Invalid Order Data');
}
$orderData = (object)$orderData;
if (!sizeof($orderData->BasketData)) {
exit('Sales Order Basket Cannot Be Empty');
}
// Anticipate Error
try
{
// Start New Sales Order Quote
$quote = Mage::getModel('sales/quote')
->setStoreId($orderData->StoreId);
// Set Sales Order Quote Currency
$quote->setCurrency($orderData->Currency);
// Load Sales Order Customer
$customer = Mage::getModel('customer/customer')
->setWebsiteId($orderData->CustomerWebsiteId)
->load($orderData->CustomerId);
// Assign Customer To Sales Order Quote
$quote->assignCustomer($customer);
// Configure Notification
$quote->setSendCconfirmation($orderData->SendConfirmation ? '1' :
'0');
// Add Products To Sales Order Quote
foreach ($orderData->BasketData as $orderLine)
{
// Add Product To Sales Order Quote
$quote->addProduct(
Mage::getModel('catalog/product')->load($orderLine['ProductId']),
new Varien_Object(array(
'price' => floatval($orderLine['Price']),
'qty' => intval($orderLine['Qty'])
))
);
}
// Set Sales Order Billing Address
$billingAddress = $quote->getBillingAddress()->addData(array(
'firstname' => $orderData->BillingAddress['Firstname'],
'lastname' => $orderData->BillingAddress['Lastname'],
'company' => $orderData->BillingAddress['Company'],
'street' =>
array($orderData->BillingAddress['AddressLine1'],
$orderData->BillingAddress['AddressLine2']),
'region_id' => 0,
'region' => $orderData->BillingAddress['Region'],
'city' => $orderData->BillingAddress['City'],
'postcode' => $orderData->BillingAddress['Postcode'],
'country_id' =>
getCountryId($orderData->BillingAddress['Country']),
'telephone' => $orderData->BillingAddress['Telephone']
));
// Set Sales Order Shipping Address
$shippingAddress = $quote->getShippingAddress()->addData(array(
'firstname' => $orderData->ShippingAddress['Firstname'],
'lastname' => $orderData->ShippingAddress['Lastname'],
'company' => $orderData->ShippingAddress['Company'],
'street' =>
array($orderData->ShippingAddress['AddressLine1'],
$orderData->ShippingAddress['AddressLine2']),
'region_id' => 0,
'region' => $orderData->ShippingAddress['Region'],
'city' => $orderData->ShippingAddress['City'],
'postcode' => $orderData->ShippingAddress['Postcode'],
'country_id' =>
getCountryId($orderData->ShippingAddress['Country']),
'telephone' => $orderData->ShippingAddress['Telephone']
));
// Collect Rates and Set Shipping & Payment Method
$shippingAddress->setCollectShippingRates(true)
->collectShippingRates()
->setShippingMethod($orderData->ShippingMethod)
->setPaymentMethod($orderData->PaymentMethod);
// Set Sales Order Payment
$quote->getPayment()->importData(array('method' =>
$orderData->PaymentMethod));
// Collect Totals & Save Quote
$quote->collectTotals()->save();
// Create Order From Quote
$service = Mage::getModel('sales/service_quote', $quote);
$service->submitAll();
$increment_id = $service->getOrder()->getIncrementId();
// Resource Clean-Up
$quote = $customer = $service = null;
// Finished
return $increment_id;
}
catch (Exception $e)
{
// Error
exit($e->getMessage());
}
}
// HELPER FUNCTION
function getCountryId($countryName) {
$countryId = '';
$countryCollection =
Mage::getModel('directory/country')->getCollection();
foreach ($countryCollection as $country) {
if ($countryName == $country->getName()) {
$countryId = $country->getCountryId();
break;
}
}
$countryCollection = null;
return $countryId;
}
// TEST Order Create Function
echo CreateOrder(array(
'Currency' => 'EUR', // Euro
'StoreId' => 3, // Trade Store View
'CustomerWebsiteId' => 2, // Trade Website
'CustomerId' => 5, // Latheesan K.
'SendConfirmation' => false,
'BasketData' => array
(
array('ProductId' => 3, 'Price' => 13.00, 'Qty' => 1), // VCF001
array('ProductId' => 6, 'Price' => 1.00, 'Qty' => 1), // VCF002
array('ProductId' => 8, 'Price' => 14.99, 'Qty' => 1), // VCF003
),
'BillingAddress' => array
(
'Firstname' => 'Latheesan',
'Lastname' => 'Kanes',
'Company' => 'Intelli B.I. Ltd',
'AddressLine1' => 'Unit 1, Eastman Road',
'AddressLine2' => 'Acton',
'Region' => '',
'City' => 'London',
'Postcode' => 'W3 7QS',
'Country' => 'United Kingdom',
'Telephone' => '0208 428 2832',
),
'ShippingAddress' => array
(
'Firstname' => 'Latheesan',
'Lastname' => 'Kanes',
'Company' => 'Intelli B.I. Ltd',
'AddressLine1' => 'Unit 1, Eastman Road',
'AddressLine2' => 'Acton',
'Region' => '',
'City' => 'London',
'Postcode' => 'W3 7QS',
'Country' => 'United Kingdom',
'Telephone' => '0208 428 2832',
),
'ShippingMethod' => 'flatrate_flatrate',
'PaymentMethod' => 'checkmo'
));
?>
Also, this line isn't turning on email notification on order create:
// Configure Notification
$quote->setSendCconfirmation($orderData->SendConfirmation ? '1' : '0');
How do you enable email notification?
Regards, Latheesan
I have a dev magento with multi-currency enabled (GBP, EUR , USD). I am
trying to create a sales order against my dev magento in Euro - however
the order keeps creating in GBP (my base currency).
Any idea what I am doing wrong? Here's my code so far:
<?php
// Init Magento In Admin Store Context
require_once '/home/www-data/public_html/app/Mage.php';
$app = Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
// Function To Generate Magento Sales Order
function CreateOrder($orderData = array())
{
// Validate Order Data
if (!sizeof($orderData)) {
exit('Invalid Order Data');
}
$orderData = (object)$orderData;
if (!sizeof($orderData->BasketData)) {
exit('Sales Order Basket Cannot Be Empty');
}
// Anticipate Error
try
{
// Start New Sales Order Quote
$quote = Mage::getModel('sales/quote')
->setStoreId($orderData->StoreId);
// Set Sales Order Quote Currency
$quote->setCurrency($orderData->Currency);
// Load Sales Order Customer
$customer = Mage::getModel('customer/customer')
->setWebsiteId($orderData->CustomerWebsiteId)
->load($orderData->CustomerId);
// Assign Customer To Sales Order Quote
$quote->assignCustomer($customer);
// Configure Notification
$quote->setSendCconfirmation($orderData->SendConfirmation ? '1' :
'0');
// Add Products To Sales Order Quote
foreach ($orderData->BasketData as $orderLine)
{
// Add Product To Sales Order Quote
$quote->addProduct(
Mage::getModel('catalog/product')->load($orderLine['ProductId']),
new Varien_Object(array(
'price' => floatval($orderLine['Price']),
'qty' => intval($orderLine['Qty'])
))
);
}
// Set Sales Order Billing Address
$billingAddress = $quote->getBillingAddress()->addData(array(
'firstname' => $orderData->BillingAddress['Firstname'],
'lastname' => $orderData->BillingAddress['Lastname'],
'company' => $orderData->BillingAddress['Company'],
'street' =>
array($orderData->BillingAddress['AddressLine1'],
$orderData->BillingAddress['AddressLine2']),
'region_id' => 0,
'region' => $orderData->BillingAddress['Region'],
'city' => $orderData->BillingAddress['City'],
'postcode' => $orderData->BillingAddress['Postcode'],
'country_id' =>
getCountryId($orderData->BillingAddress['Country']),
'telephone' => $orderData->BillingAddress['Telephone']
));
// Set Sales Order Shipping Address
$shippingAddress = $quote->getShippingAddress()->addData(array(
'firstname' => $orderData->ShippingAddress['Firstname'],
'lastname' => $orderData->ShippingAddress['Lastname'],
'company' => $orderData->ShippingAddress['Company'],
'street' =>
array($orderData->ShippingAddress['AddressLine1'],
$orderData->ShippingAddress['AddressLine2']),
'region_id' => 0,
'region' => $orderData->ShippingAddress['Region'],
'city' => $orderData->ShippingAddress['City'],
'postcode' => $orderData->ShippingAddress['Postcode'],
'country_id' =>
getCountryId($orderData->ShippingAddress['Country']),
'telephone' => $orderData->ShippingAddress['Telephone']
));
// Collect Rates and Set Shipping & Payment Method
$shippingAddress->setCollectShippingRates(true)
->collectShippingRates()
->setShippingMethod($orderData->ShippingMethod)
->setPaymentMethod($orderData->PaymentMethod);
// Set Sales Order Payment
$quote->getPayment()->importData(array('method' =>
$orderData->PaymentMethod));
// Collect Totals & Save Quote
$quote->collectTotals()->save();
// Create Order From Quote
$service = Mage::getModel('sales/service_quote', $quote);
$service->submitAll();
$increment_id = $service->getOrder()->getIncrementId();
// Resource Clean-Up
$quote = $customer = $service = null;
// Finished
return $increment_id;
}
catch (Exception $e)
{
// Error
exit($e->getMessage());
}
}
// HELPER FUNCTION
function getCountryId($countryName) {
$countryId = '';
$countryCollection =
Mage::getModel('directory/country')->getCollection();
foreach ($countryCollection as $country) {
if ($countryName == $country->getName()) {
$countryId = $country->getCountryId();
break;
}
}
$countryCollection = null;
return $countryId;
}
// TEST Order Create Function
echo CreateOrder(array(
'Currency' => 'EUR', // Euro
'StoreId' => 3, // Trade Store View
'CustomerWebsiteId' => 2, // Trade Website
'CustomerId' => 5, // Latheesan K.
'SendConfirmation' => false,
'BasketData' => array
(
array('ProductId' => 3, 'Price' => 13.00, 'Qty' => 1), // VCF001
array('ProductId' => 6, 'Price' => 1.00, 'Qty' => 1), // VCF002
array('ProductId' => 8, 'Price' => 14.99, 'Qty' => 1), // VCF003
),
'BillingAddress' => array
(
'Firstname' => 'Latheesan',
'Lastname' => 'Kanes',
'Company' => 'Intelli B.I. Ltd',
'AddressLine1' => 'Unit 1, Eastman Road',
'AddressLine2' => 'Acton',
'Region' => '',
'City' => 'London',
'Postcode' => 'W3 7QS',
'Country' => 'United Kingdom',
'Telephone' => '0208 428 2832',
),
'ShippingAddress' => array
(
'Firstname' => 'Latheesan',
'Lastname' => 'Kanes',
'Company' => 'Intelli B.I. Ltd',
'AddressLine1' => 'Unit 1, Eastman Road',
'AddressLine2' => 'Acton',
'Region' => '',
'City' => 'London',
'Postcode' => 'W3 7QS',
'Country' => 'United Kingdom',
'Telephone' => '0208 428 2832',
),
'ShippingMethod' => 'flatrate_flatrate',
'PaymentMethod' => 'checkmo'
));
?>
Also, this line isn't turning on email notification on order create:
// Configure Notification
$quote->setSendCconfirmation($orderData->SendConfirmation ? '1' : '0');
How do you enable email notification?
Regards, Latheesan
Break mysql row examination with primary key
Break mysql row examination with primary key
id int(primary key , unique)
status enum('enable','disable')
round tinyint(1) (index)
core tinyint(1) (index)
timestamp int(10) (index)
I got a query in a table about 1,800,000 rows.
there's a query like
SELECT * FROM tblmatch WHERE status = 'disable' and round=0 AND core = 3
AND time_stamp < UNIX_TIMESTAMP() ORDER BY time_stamp ASC LIMIT 0,10
Row examination of the query is about 1,680,000 rows
So, i added a id > 1600000 statement to the query , so it looks like
SELECT * FROM tblmatch WHERE id > 1600000 AND status = 'disable' and
round=0 AND time_stamp < UNIX_TIMESTAMP() ORDER BY time_stamp ASC LIMIT
0,10
yet row examinations is the same.
is there anyway to break row examination?
id int(primary key , unique)
status enum('enable','disable')
round tinyint(1) (index)
core tinyint(1) (index)
timestamp int(10) (index)
I got a query in a table about 1,800,000 rows.
there's a query like
SELECT * FROM tblmatch WHERE status = 'disable' and round=0 AND core = 3
AND time_stamp < UNIX_TIMESTAMP() ORDER BY time_stamp ASC LIMIT 0,10
Row examination of the query is about 1,680,000 rows
So, i added a id > 1600000 statement to the query , so it looks like
SELECT * FROM tblmatch WHERE id > 1600000 AND status = 'disable' and
round=0 AND time_stamp < UNIX_TIMESTAMP() ORDER BY time_stamp ASC LIMIT
0,10
yet row examinations is the same.
is there anyway to break row examination?
I need a basic jQuery FancyBox [on hold]
I need a basic jQuery FancyBox [on hold]
i need a basic javaScript code to create a basic jQuery FancyBox. please
help me to create a javascript FancyBox ?
i am new for javascript programming.
Thank You !!!
i need a basic javaScript code to create a basic jQuery FancyBox. please
help me to create a javascript FancyBox ?
i am new for javascript programming.
Thank You !!!
Friday, 13 September 2013
how to pass html table data to controller in mvc 4.0
how to pass html table data to controller in mvc 4.0
I have a HTML table in view . I want to pass the html table data to
controller in mvc 4.0. I read this Answer how to pass html table data to
controller in mvc2.0 But I don't know how to use jquery and Json to pass
data. Can any one help me.
I have a HTML table in view . I want to pass the html table data to
controller in mvc 4.0. I read this Answer how to pass html table data to
controller in mvc2.0 But I don't know how to use jquery and Json to pass
data. Can any one help me.
Using quit/q in a function causes RStudio to fatal error
Using quit/q in a function causes RStudio to fatal error
More of a curiosity but when you use q or quit inside of a function inside
of R studio it causes a fatal error as seen here:
But the same function in rgui causes R to stop as usual. And using just
q() in RStudio closes R as expected. Why does q in a function cause
RStudio to literally bomb?
Example function that causes the bomb:
FUN <- function() q()
FUN()
Here's my sessionInfo:
R Under development (unstable) (2013-09-04 r63830)
Platform: i386-w64-mingw32/i386 (32-bit)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United
States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] tools_3.1.0
RStudio Version 0.97.551
More of a curiosity but when you use q or quit inside of a function inside
of R studio it causes a fatal error as seen here:
But the same function in rgui causes R to stop as usual. And using just
q() in RStudio closes R as expected. Why does q in a function cause
RStudio to literally bomb?
Example function that causes the bomb:
FUN <- function() q()
FUN()
Here's my sessionInfo:
R Under development (unstable) (2013-09-04 r63830)
Platform: i386-w64-mingw32/i386 (32-bit)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United
States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] tools_3.1.0
RStudio Version 0.97.551
Autocomplete from database mysqli
Autocomplete from database mysqli
I am using auto complete where the suggestions come from database and it
is working fine, however I tried to change it to mysqli but it doesn't
work. It doesn't show any suggestions;no error.
what I am missing on the mysqli end?
How can I be able to add more tables(I have like 40 tables)? Thanks.
MySQL:
<?php
mysql_connect("localhost","root","");
mysql_select_db("database");
$term=$_GET["term"];
$query=mysql_query("SELECT * FROM products1 where title like
'%".$term."%' order by id ");
$json=array();
while($student=mysql_fetch_array($query)){
$json[]=array(
'value'=> $student["title"],
'label'=>$student["title"]
);
}
echo json_encode($json);
?>
What I tried with MySQLi:
<?php
$mydb = new mysqli('localhost', 'root', '', 'database');
$q = $_POST['term'];
$stmt = $mydb->prepare(" SELECT * from products1 where title LIKE ? ");
echo $mydb->error;
$stmt->bind_param('s', $q);
$stmt->execute();
?>
<?php
$result = $stmt->get_result();
while ($row = $result->fetch_assoc()) {
$json[]=array(
'value'=> $student["title"],
'label'=>$student["title"]
);
}
echo json_encode($json);
?>
I am using auto complete where the suggestions come from database and it
is working fine, however I tried to change it to mysqli but it doesn't
work. It doesn't show any suggestions;no error.
what I am missing on the mysqli end?
How can I be able to add more tables(I have like 40 tables)? Thanks.
MySQL:
<?php
mysql_connect("localhost","root","");
mysql_select_db("database");
$term=$_GET["term"];
$query=mysql_query("SELECT * FROM products1 where title like
'%".$term."%' order by id ");
$json=array();
while($student=mysql_fetch_array($query)){
$json[]=array(
'value'=> $student["title"],
'label'=>$student["title"]
);
}
echo json_encode($json);
?>
What I tried with MySQLi:
<?php
$mydb = new mysqli('localhost', 'root', '', 'database');
$q = $_POST['term'];
$stmt = $mydb->prepare(" SELECT * from products1 where title LIKE ? ");
echo $mydb->error;
$stmt->bind_param('s', $q);
$stmt->execute();
?>
<?php
$result = $stmt->get_result();
while ($row = $result->fetch_assoc()) {
$json[]=array(
'value'=> $student["title"],
'label'=>$student["title"]
);
}
echo json_encode($json);
?>
Titanium - Error Loading Browser - MOZILLA_HOME_FIVE not set
Titanium - Error Loading Browser - MOZILLA_HOME_FIVE not set
Firstly, I am running on Manjaro Linux.
I downloaded Titanium, unzipped it, then ran it. All fine. However, at
startup it is throwing a "Cannot find chromimum. See documentation for
possible workaround/fixes" error which is then followed by a
MOZILLA_FIVE_HOME not set error and lastly it suggests that I should
terminate the workbench due to a SWT Error.
I've tried the many suggestions I've found online including:
Installing xulrunner. Did not work.
Setting an env variable called MOZILLA_FIVE_HOME according to
(http://www.eclipse.org/swt/faq.php#browserlinuxrcp). However, I may have
messeg up following these instructions. If anyone would kindly explain
what step number 2 means with a little bit of extra detail, I would
seriously appreciate it.
I will post the full error I am getting below:
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
No more handles [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)]
org.eclipse.swt.SWTError: No more handles [Unknown Mozilla path
(MOZILLA_FIVE_HOME not set)] at org.eclipse.swt.SWT.error(SWT.java:4308)
at org.eclipse.swt.browser.Mozilla.initMozilla(Mozilla.java:1826) at
org.eclipse.swt.browser.Mozilla.create(Mozilla.java:687) at
org.eclipse.swt.browser.Browser.(Browser.java:99) at
org.eclipse.ui.internal.browser.BrowserViewer.(BrowserViewer.java:225) at
com.aptana.portal.ui.internal.BrowserViewerWrapper.createSWTBrowserViewer(BrowserViewerWrapper.java:26)
at
com.aptana.portal.ui.browser.AbstractPortalBrowserEditor.createBrowserViewer(AbstractPortalBrowserEditor.java:211)
at
com.aptana.portal.ui.browser.AbstractPortalBrowserEditor.createPartControl(AbstractPortalBrowserEditor.java:108)
at
org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:670)
at
org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:465)
at
org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:595)
at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:313) at
org.eclipse.ui.internal.presentations.PresentablePart.setVisible(PresentablePart.java:180)
at
org.eclipse.ui.internal.presentations.util.PresentablePartFolder.select(PresentablePartFolder.java:270)
at
org.eclipse.ui.internal.presentations.util.LeftToRightTabOrder.select(LeftToRightTabOrder.java:65)
at
org.eclipse.ui.internal.presentations.util.TabbedStackPresentation.selectPart(TabbedStackPresentation.java:473)
at
org.eclipse.ui.internal.PartStack.refreshPresentationSelection(PartStack.java:1245)
at org.eclipse.ui.internal.PartStack.setSelection(PartStack.java:1198) at
org.eclipse.ui.internal.PartStack.showPart(PartStack.java:1597) at
org.eclipse.ui.internal.PartStack.add(PartStack.java:493) at
org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103) at
org.eclipse.ui.internal.PartStack.add(PartStack.java:479) at
org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112) at
org.eclipse.ui.internal.EditorSashContainer.addEditor(EditorSashContainer.java:63)
at
org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorAreaHelper.java:225)
at
org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAreaHelper.java:213)
at
org.eclipse.ui.internal.EditorManager.createEditorTab(EditorManager.java:808)
at
org.eclipse.ui.internal.EditorManager.openEditorFromDescriptor(EditorManager.java:707)
at
org.eclipse.ui.internal.EditorManager.openEditor(EditorManager.java:666)
at
org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched(WorkbenchPage.java:2942)
at
org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:2850)
at
org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPage.java:2842)
at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.java:2793)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at
org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2789)
at
org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2773)
at
org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2756)
at com.aptana.portal.ui.internal.Portal$1.runInUIThread(Portal.java:227)
at org.eclipse.ui.progress.UIJob$1.run(UIJob.java:95) at
org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at
org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3563) at
org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3212) at
org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701) at
org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665) at
org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499) at
org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679) at
org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at
com.appcelerator.titanium.rcp.IDEApplication.start(IDEApplication.java:125)
at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606) at
org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622) at
org.eclipse.equinox.launcher.Main.basicRun(Main.java:577) at
org.eclipse.equinox.launcher.Main.run(Main.java:1410) at
org.eclipse.equinox.launcher.Main.main(Main.java:1386)
Firstly, I am running on Manjaro Linux.
I downloaded Titanium, unzipped it, then ran it. All fine. However, at
startup it is throwing a "Cannot find chromimum. See documentation for
possible workaround/fixes" error which is then followed by a
MOZILLA_FIVE_HOME not set error and lastly it suggests that I should
terminate the workbench due to a SWT Error.
I've tried the many suggestions I've found online including:
Installing xulrunner. Did not work.
Setting an env variable called MOZILLA_FIVE_HOME according to
(http://www.eclipse.org/swt/faq.php#browserlinuxrcp). However, I may have
messeg up following these instructions. If anyone would kindly explain
what step number 2 means with a little bit of extra detail, I would
seriously appreciate it.
I will post the full error I am getting below:
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
No more handles [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)]
org.eclipse.swt.SWTError: No more handles [Unknown Mozilla path
(MOZILLA_FIVE_HOME not set)] at org.eclipse.swt.SWT.error(SWT.java:4308)
at org.eclipse.swt.browser.Mozilla.initMozilla(Mozilla.java:1826) at
org.eclipse.swt.browser.Mozilla.create(Mozilla.java:687) at
org.eclipse.swt.browser.Browser.(Browser.java:99) at
org.eclipse.ui.internal.browser.BrowserViewer.(BrowserViewer.java:225) at
com.aptana.portal.ui.internal.BrowserViewerWrapper.createSWTBrowserViewer(BrowserViewerWrapper.java:26)
at
com.aptana.portal.ui.browser.AbstractPortalBrowserEditor.createBrowserViewer(AbstractPortalBrowserEditor.java:211)
at
com.aptana.portal.ui.browser.AbstractPortalBrowserEditor.createPartControl(AbstractPortalBrowserEditor.java:108)
at
org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:670)
at
org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:465)
at
org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:595)
at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:313) at
org.eclipse.ui.internal.presentations.PresentablePart.setVisible(PresentablePart.java:180)
at
org.eclipse.ui.internal.presentations.util.PresentablePartFolder.select(PresentablePartFolder.java:270)
at
org.eclipse.ui.internal.presentations.util.LeftToRightTabOrder.select(LeftToRightTabOrder.java:65)
at
org.eclipse.ui.internal.presentations.util.TabbedStackPresentation.selectPart(TabbedStackPresentation.java:473)
at
org.eclipse.ui.internal.PartStack.refreshPresentationSelection(PartStack.java:1245)
at org.eclipse.ui.internal.PartStack.setSelection(PartStack.java:1198) at
org.eclipse.ui.internal.PartStack.showPart(PartStack.java:1597) at
org.eclipse.ui.internal.PartStack.add(PartStack.java:493) at
org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103) at
org.eclipse.ui.internal.PartStack.add(PartStack.java:479) at
org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112) at
org.eclipse.ui.internal.EditorSashContainer.addEditor(EditorSashContainer.java:63)
at
org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorAreaHelper.java:225)
at
org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAreaHelper.java:213)
at
org.eclipse.ui.internal.EditorManager.createEditorTab(EditorManager.java:808)
at
org.eclipse.ui.internal.EditorManager.openEditorFromDescriptor(EditorManager.java:707)
at
org.eclipse.ui.internal.EditorManager.openEditor(EditorManager.java:666)
at
org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched(WorkbenchPage.java:2942)
at
org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:2850)
at
org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPage.java:2842)
at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.java:2793)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at
org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2789)
at
org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2773)
at
org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2756)
at com.aptana.portal.ui.internal.Portal$1.runInUIThread(Portal.java:227)
at org.eclipse.ui.progress.UIJob$1.run(UIJob.java:95) at
org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at
org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3563) at
org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3212) at
org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701) at
org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665) at
org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499) at
org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679) at
org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at
com.appcelerator.titanium.rcp.IDEApplication.start(IDEApplication.java:125)
at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606) at
org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622) at
org.eclipse.equinox.launcher.Main.basicRun(Main.java:577) at
org.eclipse.equinox.launcher.Main.run(Main.java:1410) at
org.eclipse.equinox.launcher.Main.main(Main.java:1386)
How to swipe images up or down using the Gallery widget
How to swipe images up or down using the Gallery widget
I have a project for which I have to display some images. Even if the
Gallery widget is deprecated, it seems to be the best choice, since I have
not so much time to spend on it.
I would like to mimic Android's photo gallery and deleting an image when
swiping it up or down (see the screenshots below). I saw another in SO
question that we can detect vertical swipings (see the code below), but I
would like to move the image during the movement, as in Android's photo
gallery.
How could I implement this feature?
public class CustomGallery extends Gallery
{
[...]
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float
velocityX, float velocityY)
{
if (Math.abs(velocityX) > Math.abs(velocityY))
// Moving horizontally
else
// Moving vertically
return super.onFling(e1, e2, velocityX, velocityY);
}
}
NB: I can also accept an answer based on HorizontalScrollView if it
implements the up- or down-swiping feature and if it has center-locking.
!
I have a project for which I have to display some images. Even if the
Gallery widget is deprecated, it seems to be the best choice, since I have
not so much time to spend on it.
I would like to mimic Android's photo gallery and deleting an image when
swiping it up or down (see the screenshots below). I saw another in SO
question that we can detect vertical swipings (see the code below), but I
would like to move the image during the movement, as in Android's photo
gallery.
How could I implement this feature?
public class CustomGallery extends Gallery
{
[...]
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float
velocityX, float velocityY)
{
if (Math.abs(velocityX) > Math.abs(velocityY))
// Moving horizontally
else
// Moving vertically
return super.onFling(e1, e2, velocityX, velocityY);
}
}
NB: I can also accept an answer based on HorizontalScrollView if it
implements the up- or down-swiping feature and if it has center-locking.
!
CKEdtor 4: How to add CSS stylesheet from plugin?
CKEdtor 4: How to add CSS stylesheet from plugin?
Tried this for now, but no luck
editor.addCss(this.path + 'tabber.css');
editor.document.appendStyleSheet(this.path + 'tabber.css');
Full code
(function () {
CKEDITOR.plugins.add('tabber', {
init: function (editor) {
editor.ui.addButton('addTab', {
command: 'addTab',
icon: this.path + 'icons/tabber.png',
label: Drupal.t('Insert tabs')
});
editor.addCss(this.path + 'tabber.css');
editor.document.appendStyleSheet(this.path + 'tabber.css');
editor.addCommand('addTab', {
exec: function (editor) {
editor.insertHtml('<dl>' +
'<dt>Tab title 1</dt>' +
'<dd><p>Tab content 1.</p></dd>' +
'<dt>Tab title 2</dt>' +
'<dd><p>Tab content 2.</p></dd>' +
'</dl>');
}
});
}
});
})();
Tried this for now, but no luck
editor.addCss(this.path + 'tabber.css');
editor.document.appendStyleSheet(this.path + 'tabber.css');
Full code
(function () {
CKEDITOR.plugins.add('tabber', {
init: function (editor) {
editor.ui.addButton('addTab', {
command: 'addTab',
icon: this.path + 'icons/tabber.png',
label: Drupal.t('Insert tabs')
});
editor.addCss(this.path + 'tabber.css');
editor.document.appendStyleSheet(this.path + 'tabber.css');
editor.addCommand('addTab', {
exec: function (editor) {
editor.insertHtml('<dl>' +
'<dt>Tab title 1</dt>' +
'<dd><p>Tab content 1.</p></dd>' +
'<dt>Tab title 2</dt>' +
'<dd><p>Tab content 2.</p></dd>' +
'</dl>');
}
});
}
});
})();
How to make all the textarea disabled used as ckeditor
How to make all the textarea disabled used as ckeditor
I have a set of textareas which are used as editors. I want to make those
textareas readonly in some condition. I am able to do it for individual
textareas.
$("#txtHtmlHead").ckeditorGet().setReadOnly();
but when looping through each textareas is not working
$('textarea').each(function() {
$(this).ckeditorGet().setReadOnly();
});
I am getting the below exception
CKEditor is not initialized yet, use ckeditor() with a callback.
Can anybody help?
I have a set of textareas which are used as editors. I want to make those
textareas readonly in some condition. I am able to do it for individual
textareas.
$("#txtHtmlHead").ckeditorGet().setReadOnly();
but when looping through each textareas is not working
$('textarea').each(function() {
$(this).ckeditorGet().setReadOnly();
});
I am getting the below exception
CKEditor is not initialized yet, use ckeditor() with a callback.
Can anybody help?
Thursday, 12 September 2013
How can I join path fragments using objective-C in iOS?
How can I join path fragments using objective-C in iOS?
What's the objective-C equivalent of python's os.path.join in iOS? e.g.:
>>> import os
>>> os.path.join("foo", "bar", "buuxometer", "hi.jpg")
'foo/bar/buuxometer/hi.jpg'
What's the objective-C equivalent of python's os.path.join in iOS? e.g.:
>>> import os
>>> os.path.join("foo", "bar", "buuxometer", "hi.jpg")
'foo/bar/buuxometer/hi.jpg'
Implementing PHPBB3 user management on external page
Implementing PHPBB3 user management on external page
I'm trying to figure out how to modify the PHPBB3 user management
information to have it redirect back to my pages instead of the forum
index. For example, when a user registers it or requests their password be
resent it will redirect them to the forum index instead of one of my
external pages. How can I begin tracing this logic back through the PHPBB3
code so I know what I need to modify?
I'm trying to figure out how to modify the PHPBB3 user management
information to have it redirect back to my pages instead of the forum
index. For example, when a user registers it or requests their password be
resent it will redirect them to the forum index instead of one of my
external pages. How can I begin tracing this logic back through the PHPBB3
code so I know what I need to modify?
Subscribe to:
Comments (Atom)