Posts

Showing posts from July, 2018

Android take picture, but save a small size 160x160 image in internal memory

Image
Clash Royale CLAN TAG #URR8PPP Android take picture, but save a small size 160x160 image in internal memory I have looked around but I could not find a suitable answer, hence asking it here. I want to take a picture, and save a lower size version eg. 160x160 size in phone's internal memory. Now, I have seen code saving full size picture in internal and external memory. I have seen code getting a bitmap thumbnail from the picture, but this exact scenario is not explored in depth anywhere. I do not want any copy of this picture to exist except a 160 x 160 size (whichever height/width limit applies) in internal memory. By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

jQuery Validation rule based on select value

Image
Clash Royale CLAN TAG #URR8PPP jQuery Validation rule based on select value I have the following form. <form id="myform"> <select id="country" name="country"> <option value="US">United States</option> <option value="CA">Canada</option> <option value="AU">Australia</option> <option value="NZ">New Zealand</option> <option value="IE">Ireland</option> </select> <input type="text" name="zip_code" id="zip-code"> <input type="submit"> </form> I want the zip_code field to contain the digits: true rule when the selected country is United States . This is what I have tried based on this code. zip_code digits: true United States $("$myform").validate({ rules:{ zip_code: { required: true,

Best way to set environment variable and execute command in one line

Image
Clash Royale CLAN TAG #URR8PPP Best way to set environment variable and execute command in one line I want to make a backup with PostGreSQL pg_dump command with command line like : "<c:Program FilesPostgreSQL9.6binpg_dump>" -h localhost -p 5432 -d test_backup_bat -U user -f D:destination_backuptest.backup but I need to set PGPASSWORD before as environment variable to execute the backup command PGPASSWORD=mypassword How can I make this in only one command line into Windows CLI ? By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Force the navigation bar to add space for the status bar

Image
Clash Royale CLAN TAG #URR8PPP Force the navigation bar to add space for the status bar I have a UIPageViewController subclass that allows the user to swipe upward from the initial view controller to a second view controller. The initial view controller does not have a navigation bar (it's not connected to a UINavigationController ), but the second one does. Currently, when I swipe up to present the second view controller, there is no space in the navigation bar for the status bar. When the transition is complete, the entire view controller layout updates instantly to add the status bar space. I want to make the second view controller anticipate that the status bar will be there and add the space for it so the view doesn't jolt after the transition. UIPageViewController UINavigationController Short video clip showing the jolt Similar, but unanswered question EDIT: After closely looking at the way the view controller behaves during the transition, I was able to get a good l

Java Enum why static line executes only once?

Image
Clash Royale CLAN TAG #URR8PPP Java Enum why static line executes only once? The result is: 1 3 1 3 1 3 2 The constructor runs for A,B and for C (3 times). But if you use static keyword it runs only once. What is the reason of this? And why does this line executes last? enum Enums { A, B, C; { System.out.println(1); } static { System.out.println(2); } private Enums() { System.out.println(3); } } public class MainClass { public static void main(String args) { Enum en = Enums.C; } } By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

JFrame size is too small

Image
Clash Royale CLAN TAG #URR8PPP JFrame size is too small i have created a JFrame in netbeans. But when i run the program, the Jframe size is too small. here is my code. import javax.swing.JFrame; public class Window { private static void demo() { JFrame frame =new JFrame(); frame.setVisible(true); } public static void main(String args) { javax.swing.SwingUtilities.invokeLater(new Runnable(){ public void run() { demo(); } }); } } Swing JComponents by default accepting only PreferredSize, – mKorbel Oct 27 '12 at 12:35 "frame size is too small" Put components in it, then call pack() . The frame will become the smallest size it needs to be, in order to display the compo

How to update an object with another object value in JPQL using Spring JPA

Image
Clash Royale CLAN TAG #URR8PPP How to update an object with another object value in JPQL using Spring JPA I'm facing a problem in JPQL. I have two entities like below class Employee{ private Long id; private String name; private Department department; public void setId(Long id){ this.id = id; } public void setName(String name){ this.name = name; } public void setDepartment(Department department){ this.department = department } public Long getId(){ return this.id; } public String getName(){ return this.name; } public Department getDepartment(){ return this.department; } } and... class Department{ private Long id; private String name; public void setId(Long id){ this.id = id; } public void setName(String name){ this.name = name; } public Long getId(){ return id; } public String getName(){ return name; } } Now i need to update an Employee 's department. I have tried the query below. Employee

How to enable alert in iOS Safari?

Image
Clash Royale CLAN TAG #URR8PPP How to enable alert in iOS Safari? I have some alert dialog using Javascript. I found when using Safari browser under iOS, it was disabled. I am wondering if this is the standard behavior of Safari and how to enable the alert? which version of ios, safari. Give more details. Whats your code like, is it compiled to js or is it raw js ? – WilomGfx 8 mins ago JavaScript and Java are different my dude. Check your tags – Jacob B. 7 mins ago By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privac

Calling angular 4 router with Multiple parameters from C#

Image
Clash Royale CLAN TAG #URR8PPP Calling angular 4 router with Multiple parameters from C# I want to call router with multiple parameters using C#.Here is i am making url var _email = UtilityConverter.Encrypt(Email); var _userId = UtilityConverter.Encrypt(Convert.ToString(UserId)); // this.router.navigate(['search', { term: term}]); var _subject = "Email Verification"; StringBuilder sb = new StringBuilder(); sb.Append("<html>"); sb.Append("<body>"); sb.Append("<p>Dear ,</p>"); sb.Append("<p>Please click the below link to verify your email.</p><br>"); sb.Append("<a href='http://localhost:4200/Emailverification/" + _email + "/" + _userId + "'>click here</a>"); sb.Append("<p>Sincerely,<br>-Offey</br>&l

error while generating signed apk init

Image
Clash Royale CLAN TAG #URR8PPP error while generating signed apk init Hey i am trying to generate signed apk to upload to the store and i keep getting this error: Error:FAILURE: Build failed with an exception. What went wrong: Execution failed for task ':android:lintVitalRelease'. Could not resolve all files for configuration ':android:lintClassPath'. Could not resolve com.android.tools.external.com-intellij:intellij-core:26.1.0. Required by: project :android > com.android.tools.lint:lint-gradle:26.1.0 project :android > com.android.tools.lint:lint-gradle:26.1.0 > com.android.tools.lint:lint:26.1.0 > com.android.tools.lint:lint-checks:26.1.0 project :android > com.android.tools.lint:lint-gradle:26.1.0 > com.android.tools.lint:lint:26.1.0 > com.android.tools.lint:lint-kotlin:26.1.0 project :android > com.android.tools.lint:lint-gradle:26.1.0 > com.android.tools.lint:lint:26.1.0 > com.android.tools.lint:lint-c

json_decode foreach into table

Image
Clash Royale CLAN TAG #URR8PPP json_decode foreach into table Having Issues with nested arrays I Want to get the array title into the first cell of the table, having an issue articulated the nested foreach. $content = file_get_contents("https://whattomine.com/asic.json"); $data = json_decode($content); echo "coins"; foreach() { echo "<tr>"; echo "<th>".$coins->coinname."</th>"; echo "<th>".$coins->PoW."</th>"; echo "<th>".$coins->PoS."</th>"; echo "<th>".$coins->height."</th>"; echo "<th>".$coins->diff."</th>"; echo "<th>".$coins->supply."</th>"; echo "</tr>"; } By clicking "Post Your Answer", you acknowledge that you have read our updated terms o

Push notification is not working when app is in background (minimized) - IOS

Image
Clash Royale CLAN TAG #URR8PPP Push notification is not working when app is in background (minimized) - IOS I'm newbie to Swift, i am creating chat application, i need to send notification when app is in foreground or minimized. but i am not getting the notification when app is minimized (it works when USB is connected. func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any],fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { Messaging.messaging().appDidReceiveMessage(userInfo) let action = userInfo["action"] as! String let notification = UILocalNotification() notification.fireDate = NSDate() as Date notification.alertTitle = "test" notification.alertBody = "test" notification.alertAction = "Ok" UIApplication.shared.applicationIconBadgeNumber = 1 UIApplication.shared.scheduleLocalNotification(notification) completi

How to open Firefox about:reader?url=example.com with Intent on Android

Image
Clash Royale CLAN TAG #URR8PPP How to open Firefox about:reader?url=example.com with Intent on Android I'm a trying to open a webpage on an android application, the url sheme is a bit special it has to open an url in reader mode : about:reader?url=example.com about:reader?url=example.com I am doing it this way Uri intentUri = new Uri.Builder().encodedPath("about:reader") .appendQueryParameter("url", Uri.encode("example.com")) .build(); // Try to open in Firefox If available or use default Intent intent=new Intent(Intent.ACTION_VIEW); intent.setData(intentUri); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setPackage("org.mozilla.firefox"); try { getApplicationContext().startActivity(intent); } catch (ActivityNotFoundException ex) { intent.setPackage(null); getApplicationContext().startActivity(intent); } And i get E/AndroidRuntime: FATAL EXCEPTION: main Caused by: android.content.ActivityNotFoundException: No Acti

Python: DIvide items of a dictionary by a value that depends on the first key

Image
Clash Royale CLAN TAG #URR8PPP Python: DIvide items of a dictionary by a value that depends on the first key I believe that this questions is very similar to Divide each python dictionary by total value, however I am not able to deal with multidimentional key. So I have this first dictionary: x={'SBGL': 0.2631678018921199, 'SBAR': 0.00017329658914466182, 'SBKP': 0.05787906885949929, 'SBRJ': 0.01686853063415596, 'SBFZ': 0.002151268003175112, 'SBCH': 0.0, 'SBRF': 0.0010995369794006128, 'SBFI': 0.0, 'SBGR': 0.3555667545433087, 'SBCT': 0.12645173241811486, 'SBFL': 0.0020536641771051302, 'SBSP': 0.12206752790423671, 'SBSV': 0.002883296698699977, 'SBMG': 0.0, 'SBCA': 0.0, 'SBPA': 0.024485612897250063, 'SBPS': 0.0006125138064595806, 'SBCF': 0.005023609170377438, 'SBMO': 0.0020686035382382908, 'SBBR': 0.01744718188871371, 'SBJV'

Why is an if statement working but not a switch statement

Image
Clash Royale CLAN TAG #URR8PPP Why is an if statement working but not a switch statement Title is terrible, but I wasn't too sure what to put. I'm trying to create Switch Statement using the char index of a string and an Enum using this wrapper to get the value of the selected enum from a Description, it pretty much allows you to store a string to an enum value. Here is my if statement Switch Statement if statement if (msgComingFromFoo[1] == Convert.ToChar(Message.Code.FOO_TRIGGER_SIGNAL.EnumDescriptionToString())) { //foo } and here is my Switch statement Switch statement switch (msgComingFromFoo[1]) { case Convert.ToChar(Message.Code.FOO_TRIGGER_SIGNAL.EnumDescriptionToString()): break; } Why is it accepting the if statement and not the switch statement ? I tried converting it to a char since I'm selected an index from a string, but unfortunately i didn't work. if statement switch statement Update: Here is the Message.Code Enum Message.Code public

Downloading excel data using Axios from Laravel backend is not working

Image
Clash Royale CLAN TAG #URR8PPP Downloading excel data using Axios from Laravel backend is not working I am developing a Web application using React JS for the front-end and Laravel for the back-end API. Now, what I am trying to do is I am trying to fetch the excel data from the backend using axios and then download the file. This is my laravel API controller action method. function downloadExcel(Request $request) { //other code goes here return Excel::create($left_photo->id . "-" . $right_photo->id, function($excel) use ($excel_data) { // Set the spreadsheet title, creator, and description $excel->setTitle('Mapping points'); $excel->setCreator('Laravel')->setCompany('Memento'); $excel->setDescription('Mapping points file'); // Build the spreadsheet, passing in the payments array $excel->sheet('sheet1', function($sheet) use ($exce