Posts

Can Spring Hibernate interecpt queries?

Image
Clash Royale CLAN TAG #URR8PPP Can Spring Hibernate interecpt queries? I am developing an application where i need to intercept all sql queries made, and add something like "WHERE customer_id=id" after every query so don't have to add the clause every time i use a query. Is there a way to filter every query before it's sent to the database? 1 Answer 1 Yes, hibernate provide class EmptyInterceptor, We have to extend this class and overrides all methods. Before going to this step we have to register our interceptor to hibernate session. // Logging Interceptor.. public class LoggingInterceptor extends EmptyInterceptor { private static final long serialVersionUID = 1L; // Define a static logger private static Logger logger = LogManager.getLogger(LoggingInterceptor.class); // 1) save @Override public boolean onSave(Object entity, Serializable id, Object state, String propertyNames, Type types) logger.info("onSave method is called."); System.out...

CSS print content overflow footer. How to resolve?

Image
Clash Royale CLAN TAG #URR8PPP CSS print content overflow footer. How to resolve? First upon code is working properly. It displaying the footer on every page. But I want that when content is overflowing to footer then break current page and add a new page. content must not overflow footer. How can I achieve this? Your help is appreciated and sorry for any grammatical mistake. Please edit the question if you found any mistake. @media print body visibility:hidden; page[size="A4"] > * visibility:visible; #footer visibility:visible; display: block !important; position:fixed; bottom:0px; left:0px; width:100%; color:#000; padding:8px; page background: #fff; display: block; margin: 0 auto; margin-bottom: 0.5cm; box-shadow: 0 0 0.5cm rgba(0,0,0,0.5); position: relative; page[size="A4"] width:21cm; min-height: 29.7cm; page[size="A4"][layout="portrait"] width: 29.7cm; min-height: 21cm; tr.border_bottom td border-bo...

How to display Partial view Model errors when partial view is in the view?

Image
Clash Royale CLAN TAG #URR8PPP How to display Partial view Model errors when partial view is in the view? I am working on the Asp.net Core 2.0 project and have a partial view that is shown in the index view. This partial view have a Model with some validation errors. partial view index partial view You can continue to see my Model,Partial view,controller and ... LoginViewModel public class LoginViewModel [Display(Name = "UserName")] [Required(AllowEmptyStrings = false, ErrorMessage = "Please Enter UserName")] public string UserName get; set; [Display(Name = "Password")] [Required(AllowEmptyStrings = false, ErrorMessage = "Please Enter Password")] [DataType(DataType.Password)] public string Password get; set; [Display(Name = "Remember Me")] public bool RememberMe get; set; I have used LoginViewModel as model in _loginpartialView . also there are asp-validation-for to show validation error after each input LoginViewMod...

arcLength function (without OpenCv)

Image
Clash Royale CLAN TAG #URR8PPP arcLength function (without OpenCv) I'm trying to avoid CV2 for work porpuses. I'm using skimage.measure.find_contours. But I couldn't find the CV2 arcLength function equivalent anywhere. How could I calculate a contour perimeter or a curve length without that CV2 function. It's my code, just in case: from skimage import measure hresh = get_threshold(image, 127) contours = measure.find_contours(thresh, 0.8) for contour in contours: approx = aproximate_curve(contour, 0.1 * my_unknown_arc_length_function(contour)) # I have no idea about arc_length_function implementation Thanks in advance and sorry about my English. 1 Answer 1 In OpenCV the arcLength() function is used to find the perimeter of a contour/shape object. It can be found here arcLength() In scikit image the same function can be found in the measure module named perimeter . measure perimeter Usage: #--- importing the module --- from skimage.measure import perimeter ...

Unable to get a specific Cell value from a Table

Image
Clash Royale CLAN TAG #URR8PPP Unable to get a specific Cell value from a Table I need to port some VBA code to a VB.Net addon, but I can't get a particular cell value from my Table. VBA VB.Net I am able to change Range(2,2) to "Test" but table.Range(2, 2).ToString gives System.__ComObject as Value. Range(2,2) "Test" table.Range(2, 2).ToString System.__ComObject Private Sub Button1_Click(sender As Object, e As RibbonControlEventArgs) _ Handles Button1.Click Dim table As Excel.ListObject table = Globals.wsTables.ListObjects("vehicleDefinations") table.Range(2, 2) = "Test" Dim file As New System.IO.StreamWriter _ ("C:UsersRyzen2600xDownloadsDebug.txt", False) file.WriteLine(table.Range(2, 2).ToString) file.Close() End Sub Try changing the code to file.WriteLine(table.Range(2, 2).Value2) – Rawrplus Aug 10 at 8:37 file.WriteLine(table.Range(2, 2).Value2) 3 Answers 3 Don't use .Range to retrieve the value...

Force a specific pattern into a textbox

Image
Clash Royale CLAN TAG #URR8PPP Force a specific pattern into a textbox I have a web page with a text box on it. Currently through some javascript the text box only allows you to type numbers or a minus sign or dash - . My question is that I would like a way to further force the input to be in the form of 3 numbers followed by a '-' then followed by 2 more numbers and that's it. So it looks like ###-## every time its entered. I've tried lots of ways so far like this code. <input type="text" name="Item1" id = "Item1" value="" type="number" pattern="(0)3-(0)2" onkeypress="return isNumberKey(event)"/></input> But the pattern didn't work. Any suggestions to where I should start some research or sample code would be great. I was hoping it might be achievable in CSS but javascript will do. AFAIK, pattern won't work with type="number" . FYI, you have multiple type attrib...

how to “regex” all options in select menu

Image
Clash Royale CLAN TAG #URR8PPP how to “regex” all options in select menu The sample data is this: <select name="ctl00$ContentPlaceHolder1$UrunListesi$ctrl0$StokBoyut" id="ctl00_ContentPlaceHolder1_UrunListesi_ctrl0_StokBoyut"> <option value="900061_50x80">50x80 Stok:0</option> <option value="900067_60x110">60x110 Stok:0</option> <option value="900037_70x140">70x140 Stok:0</option> <option value="356593_80 T.Yolluk">80 T.Yolluk Stok:2</option> <option value="356552_80x150">80x150 Stok:23</option> </select> With the following code I can capture only one data: $regex_select = '/<select name="ctl00$ContentPlaceHolder1$UrunListesi$ctrl([0-9]1,2)$StokBoyut" id="ctl00_ContentPlaceHolder1_UrunListesi_ctrl([0-9]1,2)_StokBoyut">(.*?)/msi'; preg_match_all($regex_select, $get, $d); How can I capture all data to "S...

Java regular expressions using replaceAll?

Image
Clash Royale CLAN TAG #URR8PPP Java regular expressions using replaceAll? I have the following problem which states "Replace all characters in a string with + symbol except instances of the given string in the method" so for example if the string given was abc123efg and they want me to replace every character except every instance of "123" then it would become +++123+++. I figured a regular expression is probably the best for this and I came up with this. str.replaceAll("[^str]","+") where str is a variable, but its not letting me use the method without putting it in quotations. If I just want to replace the variable string str how can I do that? I ran it with the string manually typed and it worked on the method, but can I just input a variable? as of right now I believe its looking for the string "str" and not the variable string. Here is the output its right for so many cases except for two :( try var.replaceAll("[^...

python: How to check that returned value is exception or not

Image
Clash Royale CLAN TAG #URR8PPP python: How to check that returned value is exception or not I have two functions. function "main" is calling to function "submain". "submain" function contains try-catch block and return some value. If "submain" executes successfully then it returns some value which i will display to end user directly. If i get an exception then i have to prepare one user friendly message and print that. But to do that i need to know whether returned value is exception or not. How can i check that returned value in exception or valid result? Here is my pseudo code: def submain(): try: result = call to external API return result excepion, e: _logger(e) def main(value): for x in value: submain() # if return is exception then break loop and give msg to end user. Would you please put your code? – mark keven 40 mins ago Take a look at the section Best Practices: except clause in this answer. You can catch an exce...

Is it possible to run qc test set from outside the qc app?

Image
Clash Royale CLAN TAG #URR8PPP Is it possible to run qc test set from outside the qc app? Our organization tries to make thing more "automatics". One of things, we are trying is to run "Tests Set" each night automatically. Is there a way, to run the "Test Set" by command prompt or to write a small c sharp app that will run the "Set"? I read about OTA library (also, i didn't understand if the library is only for c# or also for visual basic script)? Unfortunately, i didn't find a way how to do it. Each assistance will be appreciated. If you want to automate tests from Quality Center , you should look into the use of UFT as it's the automated test tool designed to work with it, from the same software company. – Dave Apr 16 at 8:45 Quality Center UFT 1 Answer 1 Yes Its quite feasible, we have have done same thing for our automation. For automated tests you will require to allocate UFT/QTP host to the test case or test suite...

How to get the event when clicking the microsoft ad in uwp

Image
Clash Royale CLAN TAG #URR8PPP How to get the event when clicking the microsoft ad in uwp I'm using Microsoft Advertising SDK for xaml. And my app can show the ad now. But I want to know the event when user click the ad. None of the following event worked. <ads:AdControl x:Name="adAd" Grid.Row="3" ApplicationId="" AdUnitId="" Width="300" Height="250" AdRefreshed="OnAdRefreshed" ErrorOccurred="OnErrorOccurred" Tapped="OnAdTapped" OnPointerDown="OnAdPointerDown" PointerPressed="OnAdPointerPressed"/> AdControl.IsEngagedChanged should work. And I can't see why the 3 events in your code sample "not worked". – kennyzx Jul 20 at 5:51 Not work is mean when I click the ad, the event Tapped, OnPointerDown, PointerPressed does not fire. And IsEngagedChanged also not fire. – Vincent Jul 20 at 6:58 hi @Vincent I have edited answer please che...

How can I create ChatBot which fetch data from Azure SQL Database, Using .NET

Image
Clash Royale CLAN TAG #URR8PPP How can I create ChatBot which fetch data from Azure SQL Database, Using .NET My overall idea is I have to develop a chatBot for checking Employee Leave. For ex. Employee can enter them ID or Employee Email ID - according to email ID I want to get data from database like that particular employee Annual Leaves and Personal Leave. And gives results to User in ChatBot Prompt. For this I have tried to connect my .NET BotAPP with Azure SQL database but I couldn't get through it. can anyone help me to solve this question? Here I am going to Add code of all different files Web.Config <appSettings> <!-- update these with your Microsoft App Id and your Microsoft App Password--> <add key="BotId" value="MY BOT ID" /> <add key="MicrosoftAppId" value="My APP ID" /> <add key="MicrosoftAppPassword" value="My APP PWD" /> <add key="StorageConnectionString" va...

Error pasting a worksheet from one excel workbook to another workbook

Image
Clash Royale CLAN TAG #URR8PPP Error pasting a worksheet from one excel workbook to another workbook From a VBA project in Excel, I want to open another workbook, copy the contents of a worksheet and paste it into a worksheet where my project is running. I am basically trying to create a restore feature. I created the following macro to do the job which worked. Sub CopyandPaste() ' ' CopyandPaste Macro ' ' Workbooks.Open Filename:= _ "C: Backup-File.xlsm" Cells.Select Selection.Copy Windows("Current_File.xlsm").Activate Cells.Select Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _ SkipBlanks:=False, Transpose:=False End Sub I then added the code to my VBA project. I am getting a “Run-time error 1004 – PasteSpecial method of class failed” on the line: Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _ SkipBlanks:=False, Transpose:=False If I use “ActiveSheet.Paste”, the data is pasted in to the Curren...

Cannot get SourceDataLine from stream info

Image
Clash Royale CLAN TAG #URR8PPP Cannot get SourceDataLine from stream info I developed a service to play MP3 files using MP3 SPI, even though it works well on my local machine, it throws an exception after I published my service on the server. Here's the Exception catched by logger: No line matching interface SourceDataLine supporting format PCM_SIGNED 16000.0 Hz, 16 bit, mono, 2 bytes/frame, little-endian, and buffers of -2 to -2 bytes is supported. Here's the code snippet that cause the error: String url = "http://MusicURL.mp3" AudioInputStream stream = null; AudioInputStream dstream = null; try URL urlFile = new URL(url); stream = AudioSystem.getAudioInputStream(urlFile); catch (UnsupportedAudioFileException e) logger.error("...", e); catch (IOException e) logger.error("...", e); if (stream!=null){ try { AudioFormat baseFormat = stream.getFormat(); AudioFormat decodedFormat = new AudioFormat( AudioFormat.Encoding.PCM_SIGNED, baseFor...

Semantic-UI-react fixed sidebar

Image
Clash Royale CLAN TAG #URR8PPP Semantic-UI-react fixed sidebar Have Googled, searched within semantic ui's docs and issues page, and searched within stackoverflow. Couldn't find the answer. Within Semantic-ui-react, how do I make a sidebar whose content is fixed to the screen? What I currently have is this: <Sidebar.Pushable as=Segment> <Sidebar id="sidebar" as=Menu animation="overlay" direction="right" visible=this.state.visible vertical inverted > this.getMenuItems() </Sidebar> <Sidebar.Pusher> <Route path="/" component=Filler /> </Sidebar.Pusher> </Sidebar.Pushable> There doesn't seem to be any word in it in the semantic-ui-react documentation, and making Sidebar.Pushable, Sidebar, or any of the Menu Items position:fixed; doesn't seem to work either. 5 Answers 5 You can use Sticky component from the docs. Thanks, bennygenel. Wrapping the Sidebar component itsel...