Things to take care of while writing a file downloader
I understand this is a pretty vague question but I just want to somethings
you feel are important to take care of and are usually forgotten. I am
writing a Video down-loader in Java, and all I am doing is making URL
connection , get file headers and download (don't need to support
multi-threading).
so, is there anything I need to take care of in HTTP,HTTPS,FTP or file
sizes or anything a beginner programmer will have o idea of.
Monday, 9 September 2013
Preg_match_all repeated group
Preg_match_all repeated group
this is my string:
zzzzzzz-------eh="koko"------eh="zizi"--------eh="mimi"--------xxxxxx
i need a reg-expression to extract koko, zizi and mimi
but eh='zizi' is optional: so if it doesn't exist like in :
zzzzzzz----------eh="koko"-----------------eh="mimi"----------xxxxxx
i should get only koko and mimi.
the '---' are some text.
i tried
preg_match_all('#zzzzzzz(.*eh="([^"]*)"){2,3}.*xxxxxx#Uix', $strg , $out,
PREG_SET_ORDER);
but it doesn't work.
this is my string:
zzzzzzz-------eh="koko"------eh="zizi"--------eh="mimi"--------xxxxxx
i need a reg-expression to extract koko, zizi and mimi
but eh='zizi' is optional: so if it doesn't exist like in :
zzzzzzz----------eh="koko"-----------------eh="mimi"----------xxxxxx
i should get only koko and mimi.
the '---' are some text.
i tried
preg_match_all('#zzzzzzz(.*eh="([^"]*)"){2,3}.*xxxxxx#Uix', $strg , $out,
PREG_SET_ORDER);
but it doesn't work.
Select database used depending on URL
Select database used depending on URL
Is there any way I can have a single codebase connecting to different
databases depending on the URL used for access?
Example:
company1.example.com connects to database db_company1
company2.example.com connects to database db_company2
Is there any way I can have a single codebase connecting to different
databases depending on the URL used for access?
Example:
company1.example.com connects to database db_company1
company2.example.com connects to database db_company2
Altering Url with onclick tag in btn
Altering Url with onclick tag in btn
I used the following in one view in order to navigate to a specific tab on
an Index view...
button type="button" class="btn blue"
onclick="location.href='Index/#rooms'"><i class="m-icon-swapleft
m-icon-white"></i> Back to Room List</button>
The Url reads like.....ReferralTarget/Index/#rooms
rooms being one of the tabs on the Index view..
<li><a href="#rooms" data-toggle="tab">Rooms</a></li>
<div class="tab-pane" id="rooms">
When I use the same code in another view, I get an error 400 - Bad request
and the Url reads like... /ReferralTarget/EditRoom/Index/#rooms
Is there a way of altering the url to remove text, in this case "Edit
room"..??
If it's related back to the controller, the only difference in the two
views is the EditView Get ActionResult uses a (string id), where the
AddView does not....
Thanks
I used the following in one view in order to navigate to a specific tab on
an Index view...
button type="button" class="btn blue"
onclick="location.href='Index/#rooms'"><i class="m-icon-swapleft
m-icon-white"></i> Back to Room List</button>
The Url reads like.....ReferralTarget/Index/#rooms
rooms being one of the tabs on the Index view..
<li><a href="#rooms" data-toggle="tab">Rooms</a></li>
<div class="tab-pane" id="rooms">
When I use the same code in another view, I get an error 400 - Bad request
and the Url reads like... /ReferralTarget/EditRoom/Index/#rooms
Is there a way of altering the url to remove text, in this case "Edit
room"..??
If it's related back to the controller, the only difference in the two
views is the EditView Get ActionResult uses a (string id), where the
AddView does not....
Thanks
301 Redirect *.php to *.html via .htaccess?
301 Redirect *.php to *.html via .htaccess?
Currently I'm rewriting all incoming requests for *.html to *.php in my
.htaccess:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
RewriteRule ^(.*).html$ $1.php [QSA]
ErrorDocument 404 /404.html
So /something.html is rewritten to /something.php.
However, /something.php is still directly accessible in the browser. Now I
want it to redirect to /something.html when people are accessing it in the
browser, so as to avoid 2 distinct URLs for the same page of content.
Is this possible to do in my .htaccess? How? I tried R=301 but it's always
a redirect loop or something. Any help would be appreciated. Thanks!
Currently I'm rewriting all incoming requests for *.html to *.php in my
.htaccess:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
RewriteRule ^(.*).html$ $1.php [QSA]
ErrorDocument 404 /404.html
So /something.html is rewritten to /something.php.
However, /something.php is still directly accessible in the browser. Now I
want it to redirect to /something.html when people are accessing it in the
browser, so as to avoid 2 distinct URLs for the same page of content.
Is this possible to do in my .htaccess? How? I tried R=301 but it's always
a redirect loop or something. Any help would be appreciated. Thanks!
Sunday, 8 September 2013
Rails + Carrierwave + RMagick : Crop only if image is large
Rails + Carrierwave + RMagick : Crop only if image is large
I am using carrier-wave to upload images. On upload I am creating
thumbnails for the image which is done using Rmagick method,
resize_to_fill like below.
version :thumb do
process :resize_to_fill=> [150, 150]
end
Here is output of all the RMagick methods carrierwave supports (none of
which i want):
1] :resize_to_fill => [150,150
This works fine on larger images but my smaller images are enlarged to 150
x 150.
2] :resize_to_fit => [150,150]
Again it was resized, I want it left alone!
3] :resize_to_limit => [150,150]
This one leaves it as is, but larger images are not cropped. They are
resized to keep the aspect ratio.
Here is the result I want and how my small and larger images should look.
How do this? I want smaller images to be left alone and crop only larger
images to 150 x 150. Is there another method or options I can pass to
resize_to_fill?
Thanks
I am using carrier-wave to upload images. On upload I am creating
thumbnails for the image which is done using Rmagick method,
resize_to_fill like below.
version :thumb do
process :resize_to_fill=> [150, 150]
end
Here is output of all the RMagick methods carrierwave supports (none of
which i want):
1] :resize_to_fill => [150,150
This works fine on larger images but my smaller images are enlarged to 150
x 150.
2] :resize_to_fit => [150,150]
Again it was resized, I want it left alone!
3] :resize_to_limit => [150,150]
This one leaves it as is, but larger images are not cropped. They are
resized to keep the aspect ratio.
Here is the result I want and how my small and larger images should look.
How do this? I want smaller images to be left alone and crop only larger
images to 150 x 150. Is there another method or options I can pass to
resize_to_fill?
Thanks
MySQL shutdown unexpectedly
MySQL shutdown unexpectedly
2013-09-09 10:21:44 5776 [Note] Plugin 'FEDERATED' is disabled.
2013-09-09 10:21:44 1624 InnoDB: Warning: Using
innodb_additional_mem_pool_size is DEPRECATED. This option may be removed
in future releases, together with the option innodb_use_sys_malloc and
with the InnoDB's internal memory allocator.
2013-09-09 10:21:44 5776 [Note] InnoDB: The InnoDB memory heap is disabled
2013-09-09 10:21:44 5776 [Note] InnoDB: Mutexes and rw_locks use Windows
interlocked functions
2013-09-09 10:21:44 5776 [Note] InnoDB: Compressed tables use zlib 1.2.3
2013-09-09 10:21:44 5776 [Note] InnoDB: Not using CPU crc32 instructions
2013-09-09 10:21:44 5776 [Note] InnoDB: Initializing buffer pool, size =
16.0M
2013-09-09 10:21:44 5776 [Note] InnoDB: Completed initialization of buffer
pool
2013-09-09 10:21:44 5776 [Note] InnoDB: Highest supported file format is
Barracuda.
2013-09-09 10:21:44 5776 [Note] InnoDB: The log sequence numbers 0 and 0
in ibdata files do not match the log sequence number 19862295 in the
ib_logfiles!
2013-09-09 10:21:44 5776 [Note] InnoDB: Database was not shutdown normally!
2013-09-09 10:21:44 5776 [Note] InnoDB: Starting crash recovery.
2013-09-09 10:21:44 5776 [Note] InnoDB: Reading tablespace information
from the .ibd files...
2013-09-09 10:21:44 5776 [ERROR] InnoDB: Attempted to open a previously
opened tablespace. Previous tablespace casualme/scraped_user uses space
ID: 2 at filepath: .\casualme\scraped_user.ibd. Cannot open tablespace
mysql/innodb_index_stats which uses space ID: 2 at filepath:
.\mysql\innodb_index_stats.ibd
InnoDB: Error: could not open single-table tablespace file
.\mysql\innodb_index_stats.ibd
InnoDB: We do not continue the crash recovery, because the table may become
InnoDB: corrupt if we cannot apply the log records in the InnoDB log to it.
InnoDB: To fix the problem and start mysqld:
InnoDB: 1) If there is a permission problem in the file and mysqld cannot
InnoDB: open the file, you should modify the permissions.
InnoDB: 2) If the table is not needed, or you can restore it from a backup,
InnoDB: then you can remove the .ibd file, and InnoDB will do a normal
InnoDB: crash recovery and ignore that table.
InnoDB: 3) If the file system or the disk is broken, and you cannot remove
InnoDB: the .ibd file, you can set innodb_force_recovery > 0 in my.cnf
InnoDB: and force InnoDB to continue crash recovery here.
Hello guys.I need your help. my phpmyadmin is not working. How can i make
it working again, i have a very large data, please help me how to fix
this. i just want to get my database
2013-09-09 10:21:44 5776 [Note] Plugin 'FEDERATED' is disabled.
2013-09-09 10:21:44 1624 InnoDB: Warning: Using
innodb_additional_mem_pool_size is DEPRECATED. This option may be removed
in future releases, together with the option innodb_use_sys_malloc and
with the InnoDB's internal memory allocator.
2013-09-09 10:21:44 5776 [Note] InnoDB: The InnoDB memory heap is disabled
2013-09-09 10:21:44 5776 [Note] InnoDB: Mutexes and rw_locks use Windows
interlocked functions
2013-09-09 10:21:44 5776 [Note] InnoDB: Compressed tables use zlib 1.2.3
2013-09-09 10:21:44 5776 [Note] InnoDB: Not using CPU crc32 instructions
2013-09-09 10:21:44 5776 [Note] InnoDB: Initializing buffer pool, size =
16.0M
2013-09-09 10:21:44 5776 [Note] InnoDB: Completed initialization of buffer
pool
2013-09-09 10:21:44 5776 [Note] InnoDB: Highest supported file format is
Barracuda.
2013-09-09 10:21:44 5776 [Note] InnoDB: The log sequence numbers 0 and 0
in ibdata files do not match the log sequence number 19862295 in the
ib_logfiles!
2013-09-09 10:21:44 5776 [Note] InnoDB: Database was not shutdown normally!
2013-09-09 10:21:44 5776 [Note] InnoDB: Starting crash recovery.
2013-09-09 10:21:44 5776 [Note] InnoDB: Reading tablespace information
from the .ibd files...
2013-09-09 10:21:44 5776 [ERROR] InnoDB: Attempted to open a previously
opened tablespace. Previous tablespace casualme/scraped_user uses space
ID: 2 at filepath: .\casualme\scraped_user.ibd. Cannot open tablespace
mysql/innodb_index_stats which uses space ID: 2 at filepath:
.\mysql\innodb_index_stats.ibd
InnoDB: Error: could not open single-table tablespace file
.\mysql\innodb_index_stats.ibd
InnoDB: We do not continue the crash recovery, because the table may become
InnoDB: corrupt if we cannot apply the log records in the InnoDB log to it.
InnoDB: To fix the problem and start mysqld:
InnoDB: 1) If there is a permission problem in the file and mysqld cannot
InnoDB: open the file, you should modify the permissions.
InnoDB: 2) If the table is not needed, or you can restore it from a backup,
InnoDB: then you can remove the .ibd file, and InnoDB will do a normal
InnoDB: crash recovery and ignore that table.
InnoDB: 3) If the file system or the disk is broken, and you cannot remove
InnoDB: the .ibd file, you can set innodb_force_recovery > 0 in my.cnf
InnoDB: and force InnoDB to continue crash recovery here.
Hello guys.I need your help. my phpmyadmin is not working. How can i make
it working again, i have a very large data, please help me how to fix
this. i just want to get my database
Subscribe to:
Posts (Atom)