Rails in Action - Privatizing Assets
Admin logged in and created a ticket related to project then uploaded an
attachment correctly with no errors then when i try to download it it goes
to the false condition , when i replaced can? with cannot? he was able to
download the asset , so what is needed to make admin able to download it
without changing the current controller show action ?
Note: the false condition it should happen if the user do not have a
permission to see assets , but i don't how how this could happen to the
admin also cant find it in the book. Does anyone go through this before ?
class FilesController < ApplicationController
before_filter :authenticate_user!
def show
asset = Asset.find(params[:id])
if can?(:view, asset.ticket.project)
send_file asset.asset.path, :filename => asset.asset_file_name,
:content_type =>
asset.asset_content_type
else
flash[:alert] = "The asset you were looking for could not be
found."
redirect_to root_path
end
end
end
Tuesday, 3 September 2013
Prevent copy-pasted base64 encoded images in WordPress post editor
Prevent copy-pasted base64 encoded images in WordPress post editor
When editing a post in the WordPress post editor, it's possible to
directly copy-paste in an image.
The problem is, this stores image data in the database, increasing the
database size and causing potential performance issues. (Consider that
WordPress stores post revisions for every draft.)
Is it possible to disable this in order to prevent this from happening?
When editing a post in the WordPress post editor, it's possible to
directly copy-paste in an image.
The problem is, this stores image data in the database, increasing the
database size and causing potential performance issues. (Consider that
WordPress stores post revisions for every draft.)
Is it possible to disable this in order to prevent this from happening?
java Which in-memory is suitable for me?
java Which in-memory is suitable for me?
I am developing system like pinterest.com, My ER diagram is [1]: I thought
of storing important user details in in-memory for fast access, what is
the best in-memory database can be used for my requirement? By the way I
am developing using java and mysql.
ER Diagram [1] http://s14.postimg.org/9wkj2bbxd/image.png
I am developing system like pinterest.com, My ER diagram is [1]: I thought
of storing important user details in in-memory for fast access, what is
the best in-memory database can be used for my requirement? By the way I
am developing using java and mysql.
ER Diagram [1] http://s14.postimg.org/9wkj2bbxd/image.png
Recycling an inflated view on Android
Recycling an inflated view on Android
I have a complicated ViewGroup for a fragment which is created every now
and then. Only 1 instance fragment can be shown at a time.
I was wondering if it is possible to somehow store the inflated view and
just reuse it when the fragment is created again.
Obviously the view properties will have to be changed, but at least the
view will not need to be inflated again.
I tried simply to store the view element as a static element and then
check if it exists, and if does, use it.
However, I believe the View element has some fragment specific properties
and if you use it with a fragment which has a different reference id, it
will fail - well..it failed.
Has anyone tried to cache inflated views and reuse them?
I have a complicated ViewGroup for a fragment which is created every now
and then. Only 1 instance fragment can be shown at a time.
I was wondering if it is possible to somehow store the inflated view and
just reuse it when the fragment is created again.
Obviously the view properties will have to be changed, but at least the
view will not need to be inflated again.
I tried simply to store the view element as a static element and then
check if it exists, and if does, use it.
However, I believe the View element has some fragment specific properties
and if you use it with a fragment which has a different reference id, it
will fail - well..it failed.
Has anyone tried to cache inflated views and reuse them?
MPMoviePlayer playing audio but not video when seeking into a file
MPMoviePlayer playing audio but not video when seeking into a file
I'm trying to seek into a video file at a certain point. Lets say the
video is 5 minutes long and I'm jumping in at 110 seconds.
When I play from the beginning, everything plays through fine, however,
when I try to seek into the file, I can hear the audio but I can't see the
video. I first thought this was maybe an issue with the order I'm loading
the subviews but I can still see (and use) the controls for the player.
Sliding back to 0:00 starts the video.
The following is code from my video class. The initIntoView method accepts
a UIView and then returns an amended copy which then gets written to the
main view. Sorry in advance for the messy code. I'm still quite new to
Objective-C.
Init the Video view
- (WWFVideo*) initIntoView: (UIView*) view
withContent:(NSDictionary*)contentDict{
self=[super init];
viewRef=view;
contentData = contentDict;
NSURL *videoUrl = [[NSURL alloc]initWithString:[contentDict
objectForKey:@"cnloc"]]; //Returns a HTTP link to my video file (MP4,
H.246, AAC Audio)
videoController = [[MPMoviePlayerController alloc] init];
videoController.movieSourceType = MPMovieSourceTypeFile;
[videoController setContentURL:videoUrl];
videoController.view.frame = viewRef.bounds;
[videoController.view
setAutoresizingMask:UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleHeight];
[viewRef addSubview:videoController.view];
return self;
}
Start playing the video
-(void)play:(int)offset { //Offset is "110"
[videoController setInitialPlaybackTime:offset];
[videoController play];
}
I've tried adding the videoController to viewRef both before and after the
video starts playing but it has the same outcome.
I've also tried using an MPMoviePlayerViewController with no avail.
If I've missed any more vital code, just ask and I'll see what I can do.
Edit:
Xcode 4.6.3
iOS 6
Testing on an iPad 2
I'm trying to seek into a video file at a certain point. Lets say the
video is 5 minutes long and I'm jumping in at 110 seconds.
When I play from the beginning, everything plays through fine, however,
when I try to seek into the file, I can hear the audio but I can't see the
video. I first thought this was maybe an issue with the order I'm loading
the subviews but I can still see (and use) the controls for the player.
Sliding back to 0:00 starts the video.
The following is code from my video class. The initIntoView method accepts
a UIView and then returns an amended copy which then gets written to the
main view. Sorry in advance for the messy code. I'm still quite new to
Objective-C.
Init the Video view
- (WWFVideo*) initIntoView: (UIView*) view
withContent:(NSDictionary*)contentDict{
self=[super init];
viewRef=view;
contentData = contentDict;
NSURL *videoUrl = [[NSURL alloc]initWithString:[contentDict
objectForKey:@"cnloc"]]; //Returns a HTTP link to my video file (MP4,
H.246, AAC Audio)
videoController = [[MPMoviePlayerController alloc] init];
videoController.movieSourceType = MPMovieSourceTypeFile;
[videoController setContentURL:videoUrl];
videoController.view.frame = viewRef.bounds;
[videoController.view
setAutoresizingMask:UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleHeight];
[viewRef addSubview:videoController.view];
return self;
}
Start playing the video
-(void)play:(int)offset { //Offset is "110"
[videoController setInitialPlaybackTime:offset];
[videoController play];
}
I've tried adding the videoController to viewRef both before and after the
video starts playing but it has the same outcome.
I've also tried using an MPMoviePlayerViewController with no avail.
If I've missed any more vital code, just ask and I'll see what I can do.
Edit:
Xcode 4.6.3
iOS 6
Testing on an iPad 2
Calling complicated C++ functions in Python (linux)
Calling complicated C++ functions in Python (linux)
I have some functions in C++ source, declared like this:
extern "C" {
int32_t comp_ip_long(const std::vector<EachColumn>& in,
std::vector<EachColumn>& out);
}
The C++ code is compiled into xxx.so (linux shared object) and I want to
call the function in Python. notice that I cannot modify the C++ code, so
something like boost::python is not accessable.
I've tried ctypes.CDLL, but I don't know how to pass the complicated
argument to xxx.so?
I have some functions in C++ source, declared like this:
extern "C" {
int32_t comp_ip_long(const std::vector<EachColumn>& in,
std::vector<EachColumn>& out);
}
The C++ code is compiled into xxx.so (linux shared object) and I want to
call the function in Python. notice that I cannot modify the C++ code, so
something like boost::python is not accessable.
I've tried ctypes.CDLL, but I don't know how to pass the complicated
argument to xxx.so?
JQM + Phonegap transition broken by dragging
JQM + Phonegap transition broken by dragging
I have a link navigating to a page in the same HTML document in my
project, the fade transition works (if for the annoying appearance of a
small white gap above the header for a few seconds)
My problem is if I drag about the screen (as if scrolling) during the
transition, it behaves oddly.
If the transition is set to fade the thing will not complete and stays white.
If the transition is a slide then during the transition I am able to
scroll the 2 combined pages left and right, obviously this is undesirable.
It should be noted that I am using Phonegap to build the project on to my
Galaxy Tab 2 with android 4.1.1
Using JQuery 2.0.3 JQuery-Mobile 1.3.2 Phonegap 3.0.0
I have a link navigating to a page in the same HTML document in my
project, the fade transition works (if for the annoying appearance of a
small white gap above the header for a few seconds)
My problem is if I drag about the screen (as if scrolling) during the
transition, it behaves oddly.
If the transition is set to fade the thing will not complete and stays white.
If the transition is a slide then during the transition I am able to
scroll the 2 combined pages left and right, obviously this is undesirable.
It should be noted that I am using Phonegap to build the project on to my
Galaxy Tab 2 with android 4.1.1
Using JQuery 2.0.3 JQuery-Mobile 1.3.2 Phonegap 3.0.0
Subscribe to:
Posts (Atom)