Downsizing Many Large Images Attached to Posts, in Bulk?

Great question! WordPress lacks some of the higher level imaging management features that would make it file maintenance like you need so much easier. The core WordPress team has been threatening to add enhance image features for many versions; eventually they might actually do it! Until then you'll have to use a patchwork of plugins and/or custom code.More good news and bad news: The good news is WordPress combined with PHP has tons of lower level imaging handling features but the bad news is it has tons of lower level imaging handling features from which you have to decide which to use! A while back I posted a list of image handling functions found in WordPress and if you'll scan it you'll probably see there are several different ways to skin this cat. That said, I picked one approach and it follows below with copious comments rather than explain here in the text. You can just copy it to the root of your website as something like /downsize-images.php and call it from your browser. If it times out, don't worry; I wrote it to keep track of what it had already done so just keep running it until you see it print "Done!" NOTE: You need to set the constant MAX_RESIZE_IMAGE_TO to whatever you want your maximum dimension to be; my example used 640 pixels. After it runs you'll have a bunch of image files with an extension of .save appended. Once you are happy that it ran like you wanted you can just delete those .save files. I didn't automatically delete them in case something went wrong with the script.

(IMPORTANT: Be SURE TO BACKUP both your database and your upload directory BEFORE you run this. It worked on my machine but you might have something I didn't test and it might cause corruption so backup! DO NOT come back later and say I didn't warn you!!!):

(Moderator's note: The original title was: "Shrink full size images in post")

I built a WordPress site for someone and they entered a ton of posts with images that are wider than the content area. Is there a way to shrink all of the image attachements to use a max width? They are entered as "full size", not as thumbnail, medium, etc.

HOT PRODUCTS
데이터 없음
GET IN TOUCH WITH US
추천 기사
How to Create a Swapfile?
The basic steps of how to create a swap file are described in Arch Wiki article on swap. I took the liberty of condensing all those steps into a script Basic usage:Usage is very simple:For adding 1 gigabyte you would do sudo ./addswap.sh 1 G. For adding 1 megabyte do sudo ./addswap.sh 1 M. This script is also available on my personal GitHub repository.I have a 500Gib hard disk and 2Gib of RAM. I have ubuntu 12.04When I originally particioned the disk, I had unallocated space because I had another disk with Windows in it. This disk died, so I had to install Windows in this disk and had to erase Swap Partition.Now, as I work with lot of pictures, videos and so on, computer is turning slow and I think it is because I haven't swapfile.A friend of mine gave me the command below, but the count number give me 2Gib of swapfile and I want to have 4 Gib of swapfile.Please can you tell me which number to put in count?sudo dd if/dev/zero of/swapfile.swap bs4096 count1048576·OTHER ANSWER:I have a 500Gib hard disk and 2Gib of RAM. I have ubuntu 12.04When I originally particioned the disk, I had unallocated space because I had another disk with Windows in it. This disk died, so I had to install Windows in this disk and had to erase Swap Partition.Now, as I work with lot of pictures, videos and so on, computer is turning slow and I think it is because I haven't swapfile.A friend of mine gave me the command below, but the count number give me 2Gib of swapfile and I want to have 4 Gib of swapfile.Please can you tell me which number to put in count?sudo dd if/dev/zero of/swapfile.swap bs4096 count1048576
Physics Engine Recommendation Which Can Simulate Pool Game Correctly? Closed
Several solutions.For Box2D, set b2_velocityThreshold in b2Settings.h file. In my case, I set it to 0.0f and it worked! Mass, friction, damping were NOT problem.Check this discussion thread for more details.http://www.box2d.org/forum/viewtopic.php?f3&t6906&p30782#p30782Using other physics engine.Newton Game Dynamics configured performing this correctly by default.However using Newton dynamics in iOS is possible but it's somewhat harder than others. I used several days configuring it for iOS.I'm also asking on BulletPhysics forums. I'll update this when I got a solution.-- (edit) --There are some threshold attributes in Bullet, however I couldn't find exactly same thing with b2_velocityThreshold.This looks similar, but didn't work well.Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Game Development Stack Exchange. Closed 6 years ago. Improve this questionI'm making a pool-game like game. This game requires correct (or very accurate) reflective bounces.I tried Box2D and Bullet Physics, but they both have this problem.If there is a wall on top of this image, red line is expected course of a real ball in a pool-game. But the engines often shows green line course. Especially,This happens after a slowly moving ball hits the wall.Sometimes a rapidly moving ball get slower suddenly.I'm finding a physics engine which can simulate pool-game accurately as much as possible without these problems. Can I get some recommendations? Now I'm digging Newton Game Dynamics, but I am not sure the engine will show what I want. I'm considering the PhysX engine as a next trial, and have to make my own if nothing works. But it's obvious it'll take very long time, so I wish I won't do that.I'll be very appreciated if you save my time. And of course, solution with Box2D / Bullet Physics are also welcomed.I am working with C/C/ObjectiveC on iOS.I attach my configuration with Box2D.Wallsstatic box shapelinear/angular damping 0.1restitution 1.0friction 100density 10bullet falsefixed rotation falseinertial scale 1.0Ballsdynamic sphere shapelinear/angular damping 0.1restitution 1.0friction 100density 20bullet truefixed rotation falseinertial scale 1.0·OTHER ANSWER:Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Game Development Stack Exchange. Closed 6 years ago. Improve this questionI'm making a pool-game like game. This game requires correct (or very accurate) reflective bounces.I tried Box2D and Bullet Physics, but they both have this problem.If there is a wall on top of this image, red line is expected course of a real ball in a pool-game. But the engines often shows green line course. Especially,This happens after a slowly moving ball hits the wall.Sometimes a rapidly moving ball get slower suddenly.I'm finding a physics engine which can simulate pool-game accurately as much as possible without these problems. Can I get some recommendations? Now I'm digging Newton Game Dynamics, but I am not sure the engine will show what I want. I'm considering the PhysX engine as a next trial, and have to make my own if nothing works. But it's obvious it'll take very long time, so I wish I won't do that.I'll be very appreciated if you save my time. And of course, solution with Box2D / Bullet Physics are also welcomed.I am working with C/C/ObjectiveC on iOS.I attach my configuration with Box2D.Wallsstatic box shapelinear/angular damping 0.1restitution 1.0friction 100density 10bullet falsefixed rotation falseinertial scale 1.0Ballsdynamic sphere shapelinear/angular damping 0.1restitution 1.0friction 100density 20bullet truefixed rotation falseinertial scale 1.0
Python File with Several Function Definitions Closed
I'd suggest using high-level fool-proof libraries like argparse.The problem with argparse is that its syntax is too verbose, so I developed Argh. It helps maintain the code simple and pythonic:Example usage:This can be easily tuned if you don't mind diving into the documentation.Of course it's not the only library in this fieldClosed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Code Review Stack Exchange. Closed 4 years ago. Improve this questionI have a Python file with several function definitions in it. One of the functions, named 'main' will be called as soon as the Python file is run.Example:myFile.pyimport sysdef main(arg1....): ---code-----more functions--main()When a person wants to run my file they'll type:python myFile.py arg1 arg2 ...The main function is supposed to accept in x number of arguments, however, in case the user doesn't wish to pass in any arguments we're supposed to have default values.My program looks something like this and I'm hoping there is actually a better way to do this than what I have:myFile.pyimport sys#Even though my function has default values, if the user doesn't wish#to input in any parameter values, they still must pass in the word False#otherwise, pls pass in parameter valuedef main(name "Bill", age 22, num_pets5, hobby "soccer"): if len(sys) > 1: i 0 while i --------etc. etc.-----------·OTHER ANSWER:Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Code Review Stack Exchange. Closed 4 years ago. Improve this questionI have a Python file with several function definitions in it. One of the functions, named 'main' will be called as soon as the Python file is run.Example:myFile.pyimport sysdef main(arg1....): ---code-----more functions--main()When a person wants to run my file they'll type:python myFile.py arg1 arg2 ...The main function is supposed to accept in x number of arguments, however, in case the user doesn't wish to pass in any arguments we're supposed to have default values.My program looks something like this and I'm hoping there is actually a better way to do this than what I have:myFile.pyimport sys#Even though my function has default values, if the user doesn't wish#to input in any parameter values, they still must pass in the word False#otherwise, pls pass in parameter valuedef main(name "Bill", age 22, num_pets5, hobby "soccer"): if len(sys) > 1: i 0 while i --------etc. etc.-----------
How Can I File a Case on Someone Who Is in US by Residing in India?
What kind a harassment? personal, sexual, employment? I guess you are talking about employment. Call the labor department in your state. Good luck1. would you spend money to file a case you know is fake?I would hesitate filing a case that had merit. I am not a litigious person. This crap against the Potus are pointless and a waste of time.2. What should I do when someone keeps looking at my window? There's an empty house in front of our house, and the workers there keep looking in my window. I want to file a case, but I don't know how.Maybe they are looking because you are freaking them out by watching them. Maybe they are looking so they can give the police a good description if anything comes up missing from their work site. Close your damn curtains and stop staring at the guys who are doing their job next door.3. Can i file a case against Tripadvisor?Filing a case will cost you more with the judge ordering you to just get it corrected instead4. The company in which I'm working now is listed in MCA.gov.in. There are more than 20 employees now and the company was started four years ago and we still don't get salary slip, PF, or any other benefits. Is it legal? Can I file a case against them?Yes you may file case.According to PF rules and regulations company having employees strength below 10 it's voluntary to apply for PF. For others it's a mandate.As far as salary slip is concerned, if you've properly formatted offer letter copy then you must receive salary slip to understand the components on monthly basis and deductions if any, if company doesn't give offer letter with salary breakup then they're fraud you all must ask for it.The company in which I am working now is listed in MCA. gov. in. There are more than 20 employees now and the company was started four years ago and we still do not get salary slip, PF, or any other benefits. Is it legal? Can I file a case against them?5. What is the need of 100 MB boot file in case of windows 7 installation?I just reinstalled Windows 7 on my hard drive today and delted it, now my cpu is faster6. How long does it take District Attorney to file a case against Sexual battery?Depends on if the VICTIM filed a police report Sounds like she did not7. Can I file a case against my apartment management?Maybe false advertisement, but I would not worry because your second month rent is a lot less now8. can i file a case of false allegation toward my son father?toward your son...or father? Also...details, please?9. Can we file a case against the British government for the Jallianwala Bagh massacre in Punjab? Why or why not?As a white English guy who can not speak a word of Hindi and only three words of Tamil I am sure my opinion does not carry much weight but......No.I will lay it out as clearly as I can but I am happy to be proved wrong.Starting with General Dyer. He was an officer in the British Indian Army or what we can call the Indian Army. He was not part of the British regular forces in India.The British Indian Army was an arm of the Indian Government, whilst the British Army in India was an arm of the British GovernmentEqually the troops that committed the massacre, 9th Gurkha, 54th Sikh and 59th Sindh all belonged to the British Indian Army.At Independence these units were transferred respectively to the new Indian Army (the Gurkhas) and to the Pakistan Army. If we followed a legal process similar to product liability - think asbestos or DDT - then the modern corporation which had absorbed the earlier company would be liable.Hmmm. India sues India for the Amritsar massacre..... not a popular move.So let's take a different tack. Dyer was under the authority of O'Dwyer the lieutenant governor of the Punjab. He did not repudiate his support of Dyer and met his just deserts when he was assassinated in 1940. He in turn was under the authority of the Governor General of India who in turn reported to the Secretary of State for India and thus to the British Parliament.So the Government of India Act 1919 (which became law after the massacre) transferred some powers but not military ones. So it's fairly clear that this chain of command is preserved up to 1947.What happens next is interesting. India and Pakistan do not get independence. Instead two new dominions are created out of the Indian Union and these are then separated from the UK and given the laws and constitution according to the Government of India Act 1935. ( see Indian Independence Act 1947 - Wikipedia for the details). Then India and Pakistan change their constitutions, rewrite the laws and everything starts anewNow a dive into the act Indian Independence Act 1947 or even the full act Indian Independence Act 1947. Its clear that there was no thought or consideration to protect the British Government from being sued. None of the clauses remotely cover that. What is clear is that there is a continuity of Governance and that the new Dominions (sorry but that is the wording used) carry forth the assets and liabilities of the Government of India before partition and that includes the legal ones.So again we end up with the Indian or Pakistani government being the party who could be sued. Hmmm. Ok let's have another attemptThe final attempt would be to argue that the British Government had responsibility because they were the ultimate authority. If that was true it could not be sued directly because of the provision in the Indian Independence Act 1947 which makes the High Commissioner the lightning rod for all that stuff.In my admittedly cursory reading on the subject I am baffled as to how he was apparently summarily sacked by one military superior, told to resign by the CinC India and still managed to retain his rank.That if nothing else suggests a culpable failure on the part of the British Indian Army. I've also found nothing that the Viceroy said on the matter. That could be damning of itself.But at the level of political power in Whitehall there is a clear repudiation of everything Dyer stood for (if not in terms a modern liberal can find palatable)Edwin Samuel Montagu, the Secretary of State for India, who called it "a grave error in judgement". In a debate in the House of Commons, he asked, "Are you going to keep your hold on India by terrorism, racial humiliation, subordination and frightfulness, or are you going to rest it upon the goodwill and the growing goodwill of the people of your Indian Empire?"So did the British Government do all they could to resolve the matter?Dyer was exiled from his homeland (India) and died a broken man. Was he tried? No. Should he have been? Yes. Could he have been? That's a different matter. A huge fighting fund worth more than 1 million (2013 ppp) was donated much of it by british soldiers and civil servants in India. You see the problem - if they would pushed for trial well much of the machinery of repression in India was against it. So case closed?Not quite. The Government of India did accept liability at the time and paid compensation, grudgingly, to the families of those who died. Rs500. I only have average wage figures for 1900 (The Cambridge Economic History of India: Volume 2, C.1751-c.1970 p422) and those suggest that the average wage was Rs187 in 1900. So almost certainly less than 2 years pay (it would be interesting to check the payouts against the 300 deaths official sources claim versus the 1500 other sources do)That really sucks to be honest and I would love to know the story of how it came to be granted and the struggles that were faced.However what it does do is to show that a particular part of the Government accepted liability and paid compensation at the time. It clearly took place in India which pushes liability back onto the present Governments of India or Pakistan. So with liability accepted and compensation paid at the time its difficult to argue that an entirely different state is liable a century away from the eventsAnyway I'm now off to sue Denmark and Norway for the return of the Danegeld and compensation for the appalling way they treated my ancestors 1200 years agoBlood Eagle. How the poor British were ritually sacrificed by the Danish :(Can we file a case against the British government for the Jallianwala Bagh massacre in Punjab? Why or why not?
Base64 Encoder/decoder Optimizations
I realise this is an old post but just came across it and couldn't help but notice the following pattern in the original post which was not addressed in the review:Constructs like that are dangerous as the data type of the encoding_buffer is char instead of unsigned char and it's up to the compiler to decide whether to use arithmetic (repeat the leftmost bit on the left) or logical (fill 0s to the left) right shift. Far safer would be to rewrite the expression as:As a general rule it's better to do the shift first and apply the mask later.The original code may or may not work on the designated platform but is certainly not portable.I've written a Base64 encoder/decoder, which works great. Now I want to see if I can get it working better. I've optimized as much as I can think of, but it may be missing some things. The encoder can encode a 160 MB file in 30 seconds, but the decoder takes nearly 60.So far the optimizations I've done are:Pre-allocated the file size using the formula on Wikipedia for encoding.Pre-allocate the file size using the reciprocal of the encoding formula for decoding.Use bitwise operations for byte and symbol manipulation.Use a in-memory array for encoding.One possible optimization that I don't know how to make better is the use of a std::map for decoding. O(log n) for searching and O(log n) for inserting for building the map (albeit only once).Encoder:#include "Base64Encoder.h"#include #include const char Base64Encoder::EncodingTable[64] 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z', /0-25 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z', /26-51 '0','1','2','3','4','5','6','7','8','9', /52-61 '',''; /62-63const char Base64Encoder::PADDING_CHAR '';Base64Encoder::Base64Encoder() /* DO NOTHING */ Base64Encoder::Base64Encoder() /* DO NOTHING */ int Base64Encoder::GetFirstSymbolIndex(char* encoding_buffer) return ((encoding_buffer[0] & 0xFC) >> 2);int Base64Encoder::GetSecondSymbolIndex(char* encoding_buffer) return (((encoding_buffer[0] & 0x03) > 4));int Base64Encoder::GetThirdSymbolIndex(char* encoding_buffer) return (((encoding_buffer[1] & 0x0F) > 6));int Base64Encoder::GetFourthSymbolIndex(char* encoding_buffer) return (encoding_buffer[2] & 0x3F);/Gets the 6 most significant digits of the first byte.char Base64Encoder::GetFirstSymbol(char* encoding_buffer) return Base64Encoder::EncodingTable[Base64Encoder::GetFirstSymbolIndex(encoding_buffer)];/Gets the 2 least significant digits from previous (first) byte and 4 most significant from the second byte.char Base64Encoder::GetSecondSymbol(char* encoding_buffer) return Base64Encoder::EncodingTable[Base64Encoder::GetSecondSymbolIndex(encoding_buffer)];/Gets the 4 least significant digits from previous (second) byte and 2 least significant from the third byte.char Base64Encoder::GetThirdSymbol(char* encoding_buffer) return Base64Encoder::EncodingTable[Base64Encoder::GetThirdSymbolIndex(encoding_buffer)];/Gets the 6 least significant digits from the third byte.char Base64Encoder::GetFourthSymbol(char* encoding_buffer) return Base64Encoder::EncodingTable[Base64Encoder::GetFourthSymbolIndex(encoding_buffer)];std::string Base64Encoder::Encode(const std::string& file_path) std::string output; std::ifstream ifs; ifs.open(file_path.c_str(), std::ios_base::binary); try output Encode(ifs); ifs.close(); catch(...) ifs.close(); return output;std::string Base64Encoder::Encode(std::istream& input_stream) if(input_stream.fail()) return ""; unsigned long file_size 0; char encoding_buffer[3] '0', '0', '0'; input_stream.seekg(0, std::ios::end); file_size static_cast(input_stream.tellg()); input_stream.seekg(0); std::string output(static_cast(4 * std::ceil(file_size / 3.0)), '0'); if(file_size 0) output.clear(); input_stream.clear(); return output; while(input_stream.read(reinterpret_cast(encoding_buffer), sizeof(encoding_buffer))) char firstsymbol GetFirstSymbol(encoding_buffer); char secondsymbol GetSecondSymbol(encoding_buffer); char thirdsymbol GetThirdSymbol(encoding_buffer); char fourthsymbol GetFourthSymbol(encoding_buffer); unsigned long s 4 * static_cast(input_stream.tellg()) / 3; output[s - 4] firstsymbol; output[s - 3] secondsymbol; output[s - 2] thirdsymbol; output[s - 1] fourthsymbol; output.erase(output.find_first_of('0')); if(input_stream.fail()) switch(input_stream.gcount()) case 0: /* DO NOTHING. Evenly divisible by 4. */ break; case 1: /* Only one byte read */ encoding_buffer[2] 0; encoding_buffer[1] 0; char firstsymbol GetFirstSymbol(encoding_buffer); char secondsymbol GetSecondSymbol(encoding_buffer); char thirdsymbol GetThirdSymbol(encoding_buffer); char fourthsymbol GetFourthSymbol(encoding_buffer); output.push_back(firstsymbol); output.push_back(secondsymbol); output.push_back(Base64Encoder::PADDING_CHAR); output.push_back(Base64Encoder::PADDING_CHAR); break; case 2: /* Only two bytes read */ encoding_buffer[2] 0; char firstsymbol GetFirstSymbol(encoding_buffer); char secondsymbol GetSecondSymbol(encoding_buffer); char thirdsymbol GetThirdSymbol(encoding_buffer); char fourthsymbol GetFourthSymbol(encoding_buffer); output.push_back(firstsymbol); output.push_back(secondsymbol); output.push_back(thirdsymbol); output.push_back(Base64Encoder::PADDING_CHAR); break; case 3: /* DO NOTHING All three bytes read. */ break; default: /* DO NOTHING */; input_stream.clear(); return output;std::string Base64Encoder::Execute(std::istream& input_stream) return Encode(input_stream);std::string Base64Encoder::Execute(const std::string& file_path) return Encode(file_path);Decoder:#include "Base64Decoder.h"#include const char Base64Decoder::PADDING_CHAR '';Base64Decoder::DecodingMap Base64Decoder::DecodingTable;Base64Decoder::Base64Decoder() BuildDecodingTable(DecodingTable);Base64Decoder::Base64Decoder() void Base64Decoder::BuildDecodingTable(DecodingMap& table) table.clear(); char cur_char 'A'; for(int i 0; i > 4; int result first_index | second_index; return result;/Second Byte is 4 least significant bits of second symbol and 4 most significant bits of third symbol.char Base64Decoder::GetSecondByte(char* decoding_buffer) DecodingMap::iterator second_iter DecodingTable.find(decoding_buffer[1]); DecodingMap::iterator third_iter DecodingTable.find(decoding_buffer[2]); int second_index; if(second_iter DecodingTable.end()) second_index decoding_buffer[1]; else second_index (*second_iter).second; int third_index; if(third_iter DecodingTable.end()) third_index decoding_buffer[2]; else third_index (*third_iter).second; second_index (second_index & 0x0F) > 2; int result second_index | third_index; return result;/Third Byte is 2 least significant bits of third symbol and all of fourth symbol.char Base64Decoder::GetThirdByte(char* decoding_buffer) DecodingMap::iterator third_iter DecodingTable.find(decoding_buffer[2]); DecodingMap::iterator fourth_iter DecodingTable.find(decoding_buffer[3]); int third_index; if(third_iter DecodingTable.end()) third_index decoding_buffer[2]; else third_index (*third_iter).second; int fourth_index; if(fourth_iter DecodingTable.end()) fourth_index decoding_buffer[3]; else fourth_index (*fourth_iter).second; third_index (third_index & 0x03) (input_stream.tellg()); input_stream.seekg(0); std::string output(static_cast(3 * std::ceil(file_size / 4.0)) (file_size % 3), '0'); if(file_size 0) output.clear(); input_stream.clear(); return ""; while(input_stream.read(reinterpret_cast(decoding_buffer), sizeof(decoding_buffer))) char firstbyte GetFirstByte(decoding_buffer); char secondbyte GetSecondByte(decoding_buffer); char thirdbyte GetThirdByte(decoding_buffer); unsigned long s static_cast(3 * std::ceil(static_cast(input_stream.tellg()) / 4.0)); if(firstbyte ! PADDING_CHAR) output[s - 3] firstbyte; if(secondbyte ! PADDING_CHAR) output[s - 2] secondbyte; if(thirdbyte ! PADDING_CHAR) output[s - 1] thirdbyte; decoding_buffer[0] '0'; decoding_buffer[1] '0'; decoding_buffer[2] '0'; decoding_buffer[3] '0'; /Erase extraneous null chars. output.erase(output.find_first_of('0')); if(input_stream.fail()) if(decoding_buffer[2] PADDING_CHAR) /Third character is PADDING_CHAR. Only one in decoding_buffer. char firstbyte GetFirstByte(decoding_buffer); char secondbyte GetSecondByte(decoding_buffer); char thirdbyte GetThirdByte(decoding_buffer); output.push_back(firstbyte); else if(decoding_buffer[3] PADDING_CHAR) /Fourth character is PADDING_CHAR. Only two in decoding_buffer. char firstbyte GetFirstByte(decoding_buffer); char secondbyte GetSecondByte(decoding_buffer); char thirdbyte GetThirdByte(decoding_buffer); output.push_back(firstbyte); output.push_back(secondbyte); else /* DO NOTHING */ input_stream.clear(); return output;std::string Base64Decoder::Execute(std::istream& input_stream) return Decode(input_stream);std::string Base64Decoder::Execute(const std::string& file_path) return Decode(file_path);·OTHER ANSWER:I've written a Base64 encoder/decoder, which works great. Now I want to see if I can get it working better. I've optimized as much as I can think of, but it may be missing some things. The encoder can encode a 160 MB file in 30 seconds, but the decoder takes nearly 60.So far the optimizations I've done are:Pre-allocated the file size using the formula on Wikipedia for encoding.Pre-allocate the file size using the reciprocal of the encoding formula for decoding.Use bitwise operations for byte and symbol manipulation.Use a in-memory array for encoding.One possible optimization that I don't know how to make better is the use of a std::map for decoding. O(log n) for searching and O(log n) for inserting for building the map (albeit only once).Encoder:#include "Base64Encoder.h"#include #include const char Base64Encoder::EncodingTable[64] 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z', /0-25 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z', /26-51 '0','1','2','3','4','5','6','7','8','9', /52-61 '',''; /62-63const char Base64Encoder::PADDING_CHAR '';Base64Encoder::Base64Encoder() /* DO NOTHING */ Base64Encoder::Base64Encoder() /* DO NOTHING */ int Base64Encoder::GetFirstSymbolIndex(char* encoding_buffer) return ((encoding_buffer[0] & 0xFC) >> 2);int Base64Encoder::GetSecondSymbolIndex(char* encoding_buffer) return (((encoding_buffer[0] & 0x03) > 4));int Base64Encoder::GetThirdSymbolIndex(char* encoding_buffer) return (((encoding_buffer[1] & 0x0F) > 6));int Base64Encoder::GetFourthSymbolIndex(char* encoding_buffer) return (encoding_buffer[2] & 0x3F);/Gets the 6 most significant digits of the first byte.char Base64Encoder::GetFirstSymbol(char* encoding_buffer) return Base64Encoder::EncodingTable[Base64Encoder::GetFirstSymbolIndex(encoding_buffer)];/Gets the 2 least significant digits from previous (first) byte and 4 most significant from the second byte.char Base64Encoder::GetSecondSymbol(char* encoding_buffer) return Base64Encoder::EncodingTable[Base64Encoder::GetSecondSymbolIndex(encoding_buffer)];/Gets the 4 least significant digits from previous (second) byte and 2 least significant from the third byte.char Base64Encoder::GetThirdSymbol(char* encoding_buffer) return Base64Encoder::EncodingTable[Base64Encoder::GetThirdSymbolIndex(encoding_buffer)];/Gets the 6 least significant digits from the third byte.char Base64Encoder::GetFourthSymbol(char* encoding_buffer) return Base64Encoder::EncodingTable[Base64Encoder::GetFourthSymbolIndex(encoding_buffer)];std::string Base64Encoder::Encode(const std::string& file_path) std::string output; std::ifstream ifs; ifs.open(file_path.c_str(), std::ios_base::binary); try output Encode(ifs); ifs.close(); catch(...) ifs.close(); return output;std::string Base64Encoder::Encode(std::istream& input_stream) if(input_stream.fail()) return ""; unsigned long file_size 0; char encoding_buffer[3] '0', '0', '0'; input_stream.seekg(0, std::ios::end); file_size static_cast(input_stream.tellg()); input_stream.seekg(0); std::string output(static_cast(4 * std::ceil(file_size / 3.0)), '0'); if(file_size 0) output.clear(); input_stream.clear(); return output; while(input_stream.read(reinterpret_cast(encoding_buffer), sizeof(encoding_buffer))) char firstsymbol GetFirstSymbol(encoding_buffer); char secondsymbol GetSecondSymbol(encoding_buffer); char thirdsymbol GetThirdSymbol(encoding_buffer); char fourthsymbol GetFourthSymbol(encoding_buffer); unsigned long s 4 * static_cast(input_stream.tellg()) / 3; output[s - 4] firstsymbol; output[s - 3] secondsymbol; output[s - 2] thirdsymbol; output[s - 1] fourthsymbol; output.erase(output.find_first_of('0')); if(input_stream.fail()) switch(input_stream.gcount()) case 0: /* DO NOTHING. Evenly divisible by 4. */ break; case 1: /* Only one byte read */ encoding_buffer[2] 0; encoding_buffer[1] 0; char firstsymbol GetFirstSymbol(encoding_buffer); char secondsymbol GetSecondSymbol(encoding_buffer); char thirdsymbol GetThirdSymbol(encoding_buffer); char fourthsymbol GetFourthSymbol(encoding_buffer); output.push_back(firstsymbol); output.push_back(secondsymbol); output.push_back(Base64Encoder::PADDING_CHAR); output.push_back(Base64Encoder::PADDING_CHAR); break; case 2: /* Only two bytes read */ encoding_buffer[2] 0; char firstsymbol GetFirstSymbol(encoding_buffer); char secondsymbol GetSecondSymbol(encoding_buffer); char thirdsymbol GetThirdSymbol(encoding_buffer); char fourthsymbol GetFourthSymbol(encoding_buffer); output.push_back(firstsymbol); output.push_back(secondsymbol); output.push_back(thirdsymbol); output.push_back(Base64Encoder::PADDING_CHAR); break; case 3: /* DO NOTHING All three bytes read. */ break; default: /* DO NOTHING */; input_stream.clear(); return output;std::string Base64Encoder::Execute(std::istream& input_stream) return Encode(input_stream);std::string Base64Encoder::Execute(const std::string& file_path) return Encode(file_path);Decoder:#include "Base64Decoder.h"#include const char Base64Decoder::PADDING_CHAR '';Base64Decoder::DecodingMap Base64Decoder::DecodingTable;Base64Decoder::Base64Decoder() BuildDecodingTable(DecodingTable);Base64Decoder::Base64Decoder() void Base64Decoder::BuildDecodingTable(DecodingMap& table) table.clear(); char cur_char 'A'; for(int i 0; i > 4; int result first_index | second_index; return result;/Second Byte is 4 least significant bits of second symbol and 4 most significant bits of third symbol.char Base64Decoder::GetSecondByte(char* decoding_buffer) DecodingMap::iterator second_iter DecodingTable.find(decoding_buffer[1]); DecodingMap::iterator third_iter DecodingTable.find(decoding_buffer[2]); int second_index; if(second_iter DecodingTable.end()) second_index decoding_buffer[1]; else second_index (*second_iter).second; int third_index; if(third_iter DecodingTable.end()) third_index decoding_buffer[2]; else third_index (*third_iter).second; second_index (second_index & 0x0F) > 2; int result second_index | third_index; return result;/Third Byte is 2 least significant bits of third symbol and all of fourth symbol.char Base64Decoder::GetThirdByte(char* decoding_buffer) DecodingMap::iterator third_iter DecodingTable.find(decoding_buffer[2]); DecodingMap::iterator fourth_iter DecodingTable.find(decoding_buffer[3]); int third_index; if(third_iter DecodingTable.end()) third_index decoding_buffer[2]; else third_index (*third_iter).second; int fourth_index; if(fourth_iter DecodingTable.end()) fourth_index decoding_buffer[3]; else fourth_index (*fourth_iter).second; third_index (third_index & 0x03) (input_stream.tellg()); input_stream.seekg(0); std::string output(static_cast(3 * std::ceil(file_size / 4.0)) (file_size % 3), '0'); if(file_size 0) output.clear(); input_stream.clear(); return ""; while(input_stream.read(reinterpret_cast(decoding_buffer), sizeof(decoding_buffer))) char firstbyte GetFirstByte(decoding_buffer); char secondbyte GetSecondByte(decoding_buffer); char thirdbyte GetThirdByte(decoding_buffer); unsigned long s static_cast(3 * std::ceil(static_cast(input_stream.tellg()) / 4.0)); if(firstbyte ! PADDING_CHAR) output[s - 3] firstbyte; if(secondbyte ! PADDING_CHAR) output[s - 2] secondbyte; if(thirdbyte ! PADDING_CHAR) output[s - 1] thirdbyte; decoding_buffer[0] '0'; decoding_buffer[1] '0'; decoding_buffer[2] '0'; decoding_buffer[3] '0'; /Erase extraneous null chars. output.erase(output.find_first_of('0')); if(input_stream.fail()) if(decoding_buffer[2] PADDING_CHAR) /Third character is PADDING_CHAR. Only one in decoding_buffer. char firstbyte GetFirstByte(decoding_buffer); char secondbyte GetSecondByte(decoding_buffer); char thirdbyte GetThirdByte(decoding_buffer); output.push_back(firstbyte); else if(decoding_buffer[3] PADDING_CHAR) /Fourth character is PADDING_CHAR. Only two in decoding_buffer. char firstbyte GetFirstByte(decoding_buffer); char secondbyte GetSecondByte(decoding_buffer); char thirdbyte GetThirdByte(decoding_buffer); output.push_back(firstbyte); output.push_back(secondbyte); else /* DO NOTHING */ input_stream.clear(); return output;std::string Base64Decoder::Execute(std::istream& input_stream) return Decode(input_stream);std::string Base64Decoder::Execute(const std::string& file_path) return Decode(file_path);
Problem of Arabic Numbers in Math Mode with 'New TX' Math Font Option Libertine Compiled by XeLaTeX
A simpler solution that works for me (with XeLaTeX) is this:The order of packages is important: If the line usepackagelibertinenewtxmath is above the others, Arabic fonts look like the CM font.The idea for the answer came from here• Related QuestionsSQL Server database backupsIn case you have SQL Backup database and it undergoes corruption case which you need to solve and thus you can visit here : http://sqlbackuprecoverytool.devhub.com/ it will help you to fix your corruption issue in .bak files of SQL Server------Fatal error: Class 'Varien_Data_Form_Element_Videos' not foundFinn this case, you need to create class for your custom input field Videos at magento library folder location lib/Varien/Data/Form/ElementHere you find list of input files relative class.For case of view,you need to create the------Which is faster, copying everything at once or one thing at a time?The electronic processing time saved by loading them individually would have to be appreciable to make up for the time lost between the physical act of waiting for each file to finish loading then moving the next one individually it would seem------Get URL of a specific fileGiven the file path...Results to...Building a plug-and-play library for wordpress that can either be "included" inside a theme or plugin can be difficult. Wordpress has no pre-defined function for getting the URL of that file.Treat plugins and themes separately------In Linux, are ALL user permissions attached to an object?Things such as SELinux permissions are not directly attached to the object, and must be inferred from the context attached to the object, the role of the current user, the domain of the current process, and the transitions given within the policy------Syntax error near unexpected token then'steeldriver is rightthe problem is your alias if.you can comment the line 141 and add this at the begining of your bashrcfor the next source .bashrc.after this you can delete the alias if and change the line 141 with something like regards------Error while restoring a Database from an SQL dumpHave you tried opening in notepad (or another editor) and converting/saving us to UTF-8?See: https://stackoverflow.com/questions/7256049/notepad-converting-ansi-encoded-file-to-utf-8Another option may be to use textwrangle to open and save the file as UTF-8: http://www.barebones.com/products/textwrangler/------Can the find command work more efficiently to delete many files?Much much faster to use rsync with the --delete option. Simply have an empty folder to sync to the destination folder and viola all gone super fast. The rm -rf command is slow as it checks each inode for linking before removing.------Custom Post Type pages are not foundIn my case it was missing rights in my development folder so .htaccess file could not have been created ad/or modified.So manual flushing or Saving changes in WP Permalinks was not helping.Solution was to create .htaccess file by myself.------Why is /etc/mysql/my.cnf EMPTY?The file isn't empty. It contains comments - the lines with a leading # - and import statements -the lines with a leading !. An import statement means other configurations will be used, too.Editing a configuration file also means adding new configuration lines.------How do translations work in Craft 3?You can see the changes made to static translations in Craft 3 in the Craft 3 upgrade docs here:https://docs.craftcms.com/v3/changes-in-craft-3.html#static-translation-filesIn your case, craft/translations/en_gb.php would need to change to craft/translations/en-GB/site.php.------How do I trim leading and trailing whitespace from each line of some output?An answer you can understand in a glance:Bonus: replace str.strip(chars) with arbitrary characters to trim or use .lstrip() or .rstrip() as needed. Like rubo77's answer, save as script /usr/local/bin/trim and give permissions with chmod x.------Fail in restoring whatsapp chatsFile name in "Whatsapp/Database" folder should be "msgstore.db.crypt". If it is have date etc then rename it to "msgstore.db.crypt" only. In my case it was "msgstore.db.crypt8" i rename it "msgstore.db.crypt" and it workder------Getting blank screen at domain.com/admin when installingI'm documenting this here in case it helps someone else. My white screen during installation was caused by a missing comma between array items in my general.php and db.php config files. Once I added it, the install page loaded correctly.------How to invoke a script when closing any file with a given extensionIf the script could also be run when you open a file (or in other cases), you could use opensnoop./test:/Library/LaunchAgents/test.plist:chmod x /test, sudo chown root /Library/LaunchAgents/test.plist, and launchctl load /Library/LaunchAgents/test.plist.------Copy directory not just the contentsJust do as you did:cp -r dir1 dir2and you will have dir1 (with its content as well) inside dir2. Try if you don't believe ;-).The command that would copy content of dir1 into dir2 is:cp -r dir1/* dir2------Where are logon and startup scripts for graphical settings located and how are they managed?Programs that start at login in a graphical environment are called from .desktop launcher files in /.config/autostart and in /etc/xdg/autostart/. Here are the specifications for the autostart launchers. It's basically just a special case of the normal .desktop specification------Why can't I update my Pi?Because somewhere on the way you must have configured an APT repository pointing to an HTTPS URL (check the files at /etc/apt/sources.list.d/).Per the error message to fix the problem you need to run:and most likely also:------17.10 openjdk and oracle jdk 8 and 9 the trustAnchors parameter must be non-emptyI reinstalled everything using apt-get and that didn't solve the problem. The solution that I found to work: Go to Oracle and download the tar.gz version of jdk-8. Then copy the cacerts file from that into /etc/ssl/certs/java/cacerts.------Validating CSV headers against an expected listMove the data column validation into a functionAnd call it within the if condition.The condition could be reduced further by moving the entire thing into its own function as wellwhich now simplifies the code toUnit test used to verify expected behavior------Modify existing block programmatically by block idIn your case, the best solution is to use hook_block_view_MODULE_DELTA_alter as @Artur explained. But there is another way to to customize a custom bloc programmatically using an update function (inside a .install file) in drupal 7 by using:------Can we restore mysql db without .ibd & .frm files?I assume that you used the innodb_file_per_table option. In this case I'm afraid that there is no way to restore the database only from the ibdata1 and the two ib_logfiles, which are actually the innodb redo log files------Drop-down list with advanced searchConsider this layout:The search field is clearly visible, distinct, and the filtered results appear below, to be chosen by the user. For multi select, you can use the tag approach:Both examples are part of an open source Javascript plugin, Chosen------Will cibil score increase if I file ITR?It does not matter if you have filed your ITR. It will not have impact of your credit score. If otherwise, people who has TDS, their score should be high. But its not the case.The following will only impact your score------What are the best sites to share photo galleries with friends?I have used, Facebook, Flickr, and other small sites, and just started to use SmugMug. I love SmugMug the most don't ask why. Of course there is always room for improvement but it's really easy to use and support is really good------List files appended with an order numberyes there is. just pipe nl to the end of the your command:In this case you should write in this way:and the result is :nl refers to number line of files.also look at here :) http://www.sitepoint.com/15-little-known-unix-commands/?------Get a word's individuality!-3 bytes thanks to Kade, for assuming w to be the word list as list:Previous solution:Assumes w to be the word list. I choose Python 3 because in my word list there are some Non-ASCII chars and Python 2 does not like them------Linux command: find a program name and run the programsorBoth commands first list the files that named "abc" before the first pipe. Between the first and second pipe, both command appends the parameter -p after each line. Finally, after the second pipe, these "abc" commands are sent to bash for execution.------Migration sources files problemHow are you providing the location of the files? IIRC, you can give it an absolute path ( /home/www/drupal ) or a URL ( http://www.example.com ).In either case are you including a final '/'? If so, try removing it------How to encrypt a folder such that you can decrypt it on an unknown windows target systemYou could also use trucrypt.Create an ntfs container and put your files on that.Copy the container file to your pendrive.Copy the file to your Windows pc.Via truecrypt on Windows, you can be able to decrypt that container file------Using pdflatex in batch scripts to build pdf's with different version numbers?This link describes exactly what I needed to do to implement my script as I wanted to. https://stackoverflow.com/questions/2768608/batch-equivalent-of-bash-backticks Using a combination of the accepted answer and the highest voted answer gave me the answer I was looking for------Batch Renaming Automation *_2.* TO *.*You could try this as a little .cmd :which seems to do what you expect (remove the echo if satisfied by test run).I just see a possible issue if you have several _2. in the filenameEDIT : replaced incomplete proposal as per suggestion.------Can't SSH to server using Private Key duplicateCheck permission on /.ssh files on the server. Verify in sshd_config that the authorized_keys file (AuthorizedKeysFile) is indeed the right one.Also, just in case, verify that the files are readable server side (SELinux and AppArmor frameworks might be interfering)------Exchange 2010 search index fails to build, event 9877Yes, issues are related to indexing in Exchange Server. Whenever Indexing issue arise in Exchange Event Code 9877 generated with specific id details, in your case Error code 0x80004005.Possible Resolution of the Error Code 0x80004005Know more about solution of error 0x80004005.------How do I Pass a Nid to a webform and create a token for a different field on that node?How many teams are there?If not too many, you could set up categories in your site contact form in admin/structure/contact that represent each team then pass the team name to the contact form, thus not exposing the email address------Create file with certain specifications from vector graphic/PDFWith Shift-Ctrl-D you enter the settings of your document. There you may set calculated values from Rafael et.al. and resize your image to the document size. With Shift-Ctrl-E you get the file export dialog, where you simply set the DPI to 300------Some Unicode fonts not working in Windows 7/FirefoxI had same problem with software which had char of my language in it's windows it didn't show true char, then i changed setting in control panel ->region and language-> administrative ->Language for non-Unicode, and set it for my language------Add content to Order View Magento 2After a lot of trial and error I found a safer solution than many of these answersI've got a custom block file and template fileBut no need to rewrite all the template logic like the answer shown herehttps://magento.stackexchange.com/a/180620/70343------TestNG.java.lang.NullPointerException running second @TestMight be your driver is not initialized in landingpage.gotoProfile();Check in gotoProfile() method if driver is initialized, properly.Things you can try landingpage.gotoProfile(driver);and accepting argument in gotoProfile method as bellowORCreating objectInitialize driver value in analyticsLandingPage classEdit Profile class.------Save Graphic As does not include plot legendsI have found a way of making a pdf or eps file from a Plot with a Legend. Click on the plot till everything is selected, including the legends. Then save it a a pdf or eps file.... and that is it------Submitting Web-to-Lead via POST returning 401: Unauthorized?To avoid being DenverCoder9, I've come back to provide the answer. It took an embarrassing amount of time to discover that DemandConnectForm needed to be DemandConnect.Form. A very small and easy to miss typo that returns a completely irrelevant error message.------Sorting a set of numbers in a file using Java BitSetThis example is a good way to learn BitSet. But it can't handle the case when there may be duplicate integers in the file.If there are duplicate numbers: for example, 2, 2 in the file. In the output, there would be only one 2------Google Now Launcher still exists inside launcher settingsDid you install Google Now Launcher as part of a Google Apps package? If this is the case, Google Now Launcher will be installed as a /system app. Therefore, you'll have to remove it manually using a file manager or recovery mode------Removing apache@localhost from email headers?System -> Configuration -> Advanced -> System -> Set Return-Path -> Yesor set it to email that you want to use. Just found this today - apparently some of the emails were getting rejected by mailservers with strict rules (.edu, .gov...etc)------Problem with quotation marks on PHP exportI would recommend working with php native functions when building csv files. For example fputcsv would probably work for you. In this case you can define:Direct example from php.netExample #1 fputcsv() exampleThe above example will write the following to file.csv:------How can I uninstall the FTDIUSBSerialDriver?First, find out if the package is installed, and it's name:It should output:Then get a list of files:In my case, this was the result:Then simply delete the files in question:And follow it up with "forgetting" the package:
Rsync to Move Large Files Across Network
Without seeing your rsync command line, it's hard to be sure what is going on, but check out man rsync and look into the --verbose, --inplace, --partial and --progress options.Generally, I use a command like rsync -e ssh -avzP --inplace to transfer files in-place via ssh with archive mode (a), verbose messages (v), compression (z) and partialprogress support (P).-Rich Alloway (RogueWave)• Related QuestionsChild theme - copied some files from parent to child website still uses parent filesPerhaps one of the answers above has worked for you... If not:You don't want to copy the parent file to the child theme. Instead, create a new empty file with the same name in your child theme, then populate it with the snippets you need.Hope that helps.Oh, and you must mirror the path in your child theme folder also, so inc/header-functions.php------Setting permissions for mp4 and png files in .htaccessFinally got to find the solution:With this, I'm telling "By default, prohibit access to everything. Then if a file is PNG or MP4 type (yes, ?i: effectively ignores case), allow access to it from everywhere.Please note that I've had to override all AllowOverride None entries in httpd.conf into AllowOverride All so that .htaccess is actually taken into account (it was being ignored before)------Make every file in a Directory Structure Lowercase (Windows)This VBScript will do it. Be sure to set the variable objStartFolder to the right location. Save as a .VBS and double click to run. It will rename all the files in the specified directory to all lower case.PS. Technically, I am not renaming the file, but moving it, but the results are the same. Renaming the file will fail, since the filename already exists------jenkins stuck Please wait while Jenkins is getting ready to workOK, a good week-end does its job as usual: My issue was indeed caused by my company proxy (a good thing would be to add this requirement in the jenkins doc, i might have missed it anyway).So the fix is actually simple, just need to add the correct options to the jenkins start command, as in:Full example:tcpdump was the savior here ( a colleague :) )------Accessing Jdatabase via JavaScript Or Passing PHP varibles to JavaScriptYou can minimize your coding by passing the exact data (json object) that drawPieChart() is asking for in a single variable.In side of your loop:Then after your loop is finished iterating, write the multiple drawPieChart() calls in a single block of code so that you aren't making seperate declarations for each call.I haven't tested the above snippets, but the logic should be sound.------PHP-CGI Started Serving Blank PagesCheck the response status of your requests if it happens again (eg. curl -i) and if the status isn't 200, check your error pages (specifically the one(s) for the error number shown) and ensure they aren't set to redirect in a way which might cause an infinite loop.If the response status is 200, check whether there's any text in the response other than the HTTP headers.------Do I check generated code in to source control or not? duplicateAs a general rule, generated files do not belong in the source code repository.The biggest risk you run when you do put those files in the repository is that they become out of sync with their source and the build runs with different protocol buffer files than you would think based on the .proto files.A few reasons for deviating from the general rule are.------Creating a dynamic class name in my custom widgetYour problem is due to your trying to include a file over the http protocol. That kind of include is disabled on your server-- hence the message saying pretty much just that.Use get_template_directory instead, which will give you a filesystem path.If that does not solve it, post your code in more context. Disjointed like that, it is near impossible to test anything------Look for a value that might be in many columnsyou can construct a virtual table from columns you want:IFERROR(VLOOKUP($A2, 'ac6'!$D:$D, 'ac6'!$L:$L; 'ac6'!$F:$F, 'ac6'!$L:$L; 'ac6'!$H:$H, 'ac6'!$L:$L, 2, 0), 0)ARRAYFORMULA(IFERROR(VLOOKUP($A2:$A, 'ac6'!$D:$D, 'ac6'!$L:$L; 'ac6'!$F:$F, 'ac6'!$L:$L; 'ac6'!$H:$H, 'ac6'!$L:$L, 2, 0), 0)------wget -o writes empty files on failurewget returns a non-zero exit status when the URL is not found, so you can append a remove command on failure:Or create a temporary file and only move it where you want on success:The second has the benefit of not deleting an existing file on failure, but be sure to use unique temporary names (see man tempfile) if you're running multiple instances in parallel------CKEditor tabber shows tabs to the right on the screen when logged in as adminIn case anyone else has the same problem I will answer my own question. I found the answer to my problem in this issue for the same module: https:/www.drupal.org/node/2774763The problem was not exactly the same to begin with, but the solution was the same. The variable tabIndex needed to be placed within the function, not outside as a global. Problem solved.------ffmpeg - burning in subtitles with non-square pixelsYou can try adding the original_size filter option, such as:Specify the size of the original video, the video for which the ASS file was composed. For the syntax of this option, check the Video size section in the ffmpeg-utils manual. Due to a misdesign in ASS aspect ratio arithmetic, this is necessary to correctly scale the fonts if the aspect ratio has been changed.------Is there some way to protect apk file from being decompiled?OllyDbg is a debugger, not a decompiler.From your question, I see what you want is Android anti-debugging protection, then you could find some examples in the following articles:https:/mobile-security.gitbook.io/mobile-security-testing-guide/android-testing-guide/0x05j-testing-resiliency-against-reverse-engineering#testing-anti-debugging-detection-mstg-resilience-2Some Android protection solutions are mentioned in OWASP Bytecode Obfuscation control:DashO: https:/www.preemptive.com/products/dasho/overviewProGuard Java Optimizer and Obfuscator: https:/sourceforge.net/projects/proguard/------Why in numcases centering is disabled when using texlive2020 in win10Update cases.sty. The current version is 2020/03/29 ver 3.2, and if texlive can't provide it, get it from CTAN.The conflict fixed then was with calc.sty, and the effect wasn't exactly being "pushed right", in that the equation numbers are pushed left from the margin, accompanied by "overfull hbox" warnings. I don't see calc loaded in your example, but it gets loaded deep within empheq apparently.------Magento 2: Conditionally process layout XML fileYou can use ifconfig parameter on your node to enable/disable it on the basis of value of a specified field in system configuration system.xml.You can specify the field from system.xml by mentioning ifconfig"section/group/field" from your system.xml. Preferably keep the field to be a select of yes/no type.Feel free to ask any queries in case of confusion------Best way to model a singleton in a relational databaseYou could create a table called STATIC_CONTENT and have columns for a key as well as the content, active/inactive trackers, etc. Then, create a row with a key of "HomePage" and in your homepage, load the static content for that key and display it. That way, when you have other static content (about page, contact page, etc.), you can add rows to that table.------How to open tar gz file created using tar piped to gzipIf all is ok it should be enoughthe z option is needed for the gzip compression.On tar (GNU tar) 1.27.1 it works too withoutIt there is no special reason to do in the way you used, you can directly create a tarred gzipped file withor with a different compression program as To check which kind of file you have to dial with use the command file------How to write integration tests for numeric simulation software?A few additional points I would like to add to other answers.In case of iterative solvers, one might get the correct answer but numerical bugs, or incorrect pre-conditioner construction/factoringmight make the solver slow to converge. So performance needs to be compared with the old code for the same stopping tolerance setting.Stopping tolerance needs to be tightened progressively and number of iterations noted.PS:------FTP response 550 Permission denied.Since you are using the guest_username option, the vsftpd.conf file needs to have the following line added:virtual_use_local_privsYESfrom the manual:virtual_use_local_privs If enabled, virtual users will use the same privileges as local users. By default, virtual users will use the same privileges as anonymous users, which tends to be more restrictive (especially in terms of write access).------Converting a VMware ESXi 4.0 Thin Provisioned VM to CitrixOne method I am certain you could use is to download the free VMware vCenter Converter Standalone. Use that to pull a copy of the VM off the ESXi server, it has several different output formats. It seems very likely that one of them will be compatible with XenServer.Using the XenServer P2V should probably work as well, though I am not familiar with XenServer------Extracting numbers with a decimal point from ls output in BashWithout ls, since you're just populating its list with shell globs anyway, you can cut out the middle-man like:Call it without arguments and it will glob your hsli* files and only print the 1st occurring middle *.string.h5 part in the results for the current directory, or it will return with error and a meaningful error message printed to stderr if it cannot do so------How to create individual chapter PDFs from included TeXs?I have a similar workflow, and what I do is only semi-automatic, but it's enough for my use case. After I read this post, I wrote a simple (and funny, I guess) LaTeX template for doing this. (It might not be useful for you, since one has to know the pagenumbers, but it is still more comfortable for me than pdfsam or "print to file" solutions.).------Approve an email before sendingMaybe a custom object, child object of Case, in which the L1 agents create the reply and add attachments to it (it would also contain the email address (formula) of the customer). You can then have an approval process on this object to route it to an approver and then once it gets approved, you could then send your email using a flow, process or apex------How to create local account on NIS clients?OK, this should work for you (make a backup of /etc/nsswitch.conf). Change the passwd: and group: entries like this:Add a user that's in the NIS database, then shutdown the NIS client and test. This should force NIS to be the first lookup, then fallback to local /etc/passwd if it's not found. Gotta admit, though - it's been decades since I've used NIS------magento price slider not working when i min walue is $0?Your problem is of course in the core code, and I just learned how the price slider works.Your problem with the 0 lies here:This validation checks whether ALL filters are > 0, and if this is not the case the filter is ignored (I guess, no idea what happens if this method returns false, but makes sense), so you should have at least 0.01$ or 1$ as bottom limit------Wordpress custom upload field errorYou can use the great wordpress media manager. I've prepared a plugin to attach PDF files to noraml posts. You can download it here.The php:The javascript:The plugin stores the ID of the attached PDF file in the meta field "pdf-id". To get it in the front end you can use different ways. For example, if you are inside the loop you can use:------Name Servers not resolvingSo when you setup your DNS name server records, there are two components:1) Glue Record - This is what happens when you register your name servers with the registrar. 2) NS Records - You need to create a dns zone for example.org or whatever your domain is, and create A records for ns1 and ns2, pointing to the IPs that you set in your Glue records.------Cannot get JQuery plugin working on Drupal 7From the Drupal 7 upgrade guide:Javascript should be made compatible with other libraries than jQuery by adding a small wrapper around your existing code:The $ global will no longer refer to the jquery object. However, with this construction, the local variable $ will refer to jquery, allowing your code to access jQuery through $ anyway, while the code will not conflict with other libraries that use the $ global.------diff two directories, but ignore the extensionsYou could use this command:This uses find to list all the files in each directory, then basename and parameter substitution to strip off the directory names and file extensions. comm compares the two lists.Example:comm -12 will show all the filenames common to both directories. comm -23 will show all the filenames unique to dir1, comm -13 will show the filenames unique to dir2.
Easy Way to Limit File Size (stdout) on a Shell Script Level?
Set the maximum file size for a user that will only be used to run these scripts.The file /etc/security/limits limits a user with the values of "default" unless there are explicit values for a specific user. These user specific values will overwrite the default values. The file may have a slightly different name depending on your OS.If your log user is named log_maker, then add this line to the file:log_maker hard fsize 1000000The number after fsize is the maximum file size in KBOk, this is a very practial use case from my point of view.Let say I have a some simple shell oneliner which does log the output into a file. This can be simply anything, for example tcpdump. Is there any generic and trivial way, to make sure, that the output file won't exceed given size?Resoning behind this, is to protect from filling the whole available space on the mount point by mistake. If I forget about the script, or it will yield GBs of data per hour, then this simple debugging task can lead to a potential system crash.Now, I am aware of the options build in some of the tools (like combination of -W/-C in tcpdump). What I need is a very generic failsafe.Long story short - when I run a script like:% this -is --myvery|awsome|script >> /var/tmp/output.logHow to make sure that output.log will never get bigger than 1GB.Script can crash, be killed or whatever.Solution I am looking for should be easy and simple, using only tools available in popular distros like ubuntu/debian/fedora. In general something widely available. Complicated, multiline program is not an options here regardless of the language/technology.·OTHER ANSWER:Ok, this is a very practial use case from my point of view.Let say I have a some simple shell oneliner which does log the output into a file. This can be simply anything, for example tcpdump. Is there any generic and trivial way, to make sure, that the output file won't exceed given size?Resoning behind this, is to protect from filling the whole available space on the mount point by mistake. If I forget about the script, or it will yield GBs of data per hour, then this simple debugging task can lead to a potential system crash.Now, I am aware of the options build in some of the tools (like combination of -W/-C in tcpdump). What I need is a very generic failsafe.Long story short - when I run a script like:% this -is --myvery|awsome|script >> /var/tmp/output.logHow to make sure that output.log will never get bigger than 1GB.Script can crash, be killed or whatever.Solution I am looking for should be easy and simple, using only tools available in popular distros like ubuntu/debian/fedora. In general something widely available. Complicated, multiline program is not an options here regardless of the language/technology.
데이터 없음

Copyright © 2020 Concises YuGa Sports | Sitemap