Posts

Showing posts from July 26, 2018

How relation between one record on a table and several records on onother table

Image
Clash Royale CLAN TAG #URR8PPP How relation between one record on a table and several records on onother table My project is a program like movie collection. Main table is for storing movie data with fields like name,director,release year and ... But each record must have another attribute named genre (genres). Each movie may be categorized by one or several genres (Comedy, Horror, History, Romance,...) Genre table contain two fields.ID:integer and Genre:vchar For each movie, some of genre fields can be selected. How I can do this? thank you you have to use sql join for that, but before this you have to set relationship of primary key table and foreign key table – ershoaib 7 mins ago sql join Possible duplicate of How to implement one-to-one, one-to-many and many-to-many relationships while designing tables? Yo...

Set a scrollable background image

Image
Clash Royale CLAN TAG #URR8PPP Set a scrollable background image I currently have this fiddle : https://jsfiddle.net/0g3u8452/1/ I have a 1920x4000 image, and I would like it to take the full width of the screen just like the background-size: cover but since the image has an important height, I'd like to be able to scroll down to keep seeing it I made a picture of the result i'm trying to get : Thank you in advance for any help :) Hi @GopalGarva, with this property, I'm not able to scroll at the bottom of my picture :( – saperlipopette 23 mins ago 3 Answers 3 Try using <img> with position: absolute as a background instead? <img> position: absolute .container { position: relative; } .container img.background-img { position: ...

What is the best approch to send data to its descendant in REACT

Image
Clash Royale CLAN TAG #URR8PPP What is the best approch to send data to its descendant in REACT FOr example I have one parent component ( i'll call it animal) and several child components (dog, cat, horse) and child's child components (Collie, English Foxhound, Fox Terrier, German Shepherd Dog). If i wanna send a function from animal to Collie, i have to send this function to Dog component and from Dog to Collie and only after 2 props i will be able to use this function in Collie component. Is there any better approch to send a function from animal directly to Collie ? 2 Answers 2 Use the Context API. Read more at the official docs : https://reactjs.org/docs/context.html Basically, you define a context value and pass it with a Provider, which can be accessed by any node within the child tree. Do note that the Context API is different for different versions of React and may change in future. ...

Creating Custom log levels in Logback logging framework

Image
Clash Royale CLAN TAG #URR8PPP Creating Custom log levels in Logback logging framework Can I add custom log levels like fine,finer and finest to the existing supported logback log levels. Apart from the existing ones I need to include additional log Levels.This addition should not effect the underlying code. Thanks in advance...Any help appreciated 1 Answer 1 I don’t know if this will help you but you can write logs with the java.io an nio package by writing what you want in a file using a filewriter File f=new File("name"); BufferedWriter writer=new BufferedWriter(new FileWriter(f)); 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.

how to add to different field values and store it in another field in elastic search python (elastic search field operation)

Image
Clash Royale CLAN TAG #URR8PPP how to add to different field values and store it in another field in elastic search python (elastic search field operation) I have written this elastic search query: es.search(index=['ind1'],doc_type=['doc']) I am getting following result: {'_shards': {'failed': 0, 'skipped': 0, 'successful': 5, 'total': 5}, 'hits': {'hits': [{'_id': '1327', '_index': 'ind1', '_score': 1.0, '_source': {'val1': 1, 'val2': None, 'value1': 1327, 'value2': 1531, 'new_values': {'nv1': 1, 'nv2': 0}, {'_id': '1349', '_index': 'ind1', '_score': 1.0, '_source': {'val1': 2, 'val2': 3, 'value1': 1328, 'value2': 1539, 'new_values': {'nv1': 1, 'nv2': 3}},....... I want all the add val1, value1 and...

Каретка для смены изображения (своеобразная галерея HTML5 CSS3) [on hold]

Image
Clash Royale CLAN TAG #URR8PPP Каретка для смены изображения (своеобразная галерея HTML5 CSS3) [on hold] Доброе время суток. Нашел интересную галерею, где у каждого элемента 2 фотографии, наложенные друг на друга. И они разделены кареткой, которую можно двигать влево и вправо. (получается на подобии ДО и ПОСЛЕ) Как это выглядит (тык) Можно ли как-то такую сверстать (с минимальным кол-вом блоков), если да то как? Или есть какой-то плагин (типа fancybox, lightbox) позволяющие сделать такое Спасибо. I'm voting to close this question as off-topic because it doesn't seem to be in English – Denys Séguret 2 mins ago Nope... Here, English please – Jeremy Thille 1 min ago ...

How to abbrev “|” char?

Image
Clash Royale CLAN TAG #URR8PPP How to abbrev “|” char? In my vimrc, I am making a few iabbrev-s. All others like >=, == work well, except || and |||. Using || or ||| directly in .vimrc gives me errors. Escaping them to "|" or "" did not work. Please help. 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.

how to separate files for mocha-webpack

Image
Clash Royale CLAN TAG #URR8PPP how to separate files for mocha-webpack What's happening is that when I run my tests, my coverage only shows bundle.js which isn't that helpful. bundle.js I have the following webpack file setup and wanted to know what I should change to make it so that each file is covered individually webpack.config-test.js var nodeExternals = require("webpack-node-externals") const path = require("path") module.exports = { context: path.resolve(__dirname), resolve: { extensions: [".js"], alias: { "@": path.join(__dirname, "../../src/server"), } }, output: { path: "./", filename: "[name].js", }, target: "node", // webpack should compile node compatible code externals: [nodeExternals()], // in order to ignore all modules in node_modules folder } running the command via npm: nyc mocha-webpack --webpack-...

How do you style an image in an tag?

Image
Clash Royale CLAN TAG #URR8PPP How do you style an image in an <a> tag? Here's some code that contains a tags, one which contains an image. a <div class="container"> <a href="#">Not styled</a> <a href="#"><img src="image.png"></a> </div> If I only want to style the image, how would I do it (without creating a class or something similar)? For example, if I want to style all the a tags, I could use the following CSS: a .container a { /* styles here */ } If I want to style all the img tags, I could use this: img .container img { /* styles here */ } Is there a way to apply this same logic to an img in an a tag? img a Edit: Here are the styles I'm applying. For some reason, when I use .container a img it adds extra padding/margins. .container a img .container a { padding: 9px 10px 5px 10px; } Edit 2: I think the problem lies elsewhere. Whenever I try any of the suggested...

Failed to exec start script - EventEmitter. (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:279:16)

Image
Clash Royale CLAN TAG #URR8PPP Failed to exec start script - EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:279:16) I have installed node 8.10 and downgrade to npm 4 because i have error message with npm 5. ******************************************************************************* ERROR: npm 5 is not supported yet Then I use the command to downgrade npm npm install -g npm@4. So I create my projet $>npm install -g create-react-native-app $>create-react-native-app AwesomeProject $>cd AwesomeProject $>npm start And then I have the following error message. > AwesomeProject@0.1.0 start /private/var/root/AwesomeProject > react-native-scripts start 09:42:16: Unable to start server See https://git.io/v5vcn for more information, either install watchman or run the following snippet: sudo sysctl -w kern.maxfiles=5242880 sudo sysctl -w kern.maxfilesperproc=524288 npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! AwesomeProject...

Create generic/base form class regardless if activity or fragment

Image
Clash Royale CLAN TAG #URR8PPP Create generic/base form class regardless if activity or fragment I'm trying to create a generic/base form regardless if it is an activity or fragment . To make it simple, a Form can submit so: activity fragment Form class BaseFormActivity extends AppCompatActivity { public abstract void submitForm(); @Override public void setContentView(int layoutResID) { ConstraintLayout activityBaseForm = (ConstraintLayout) getLayoutInflater().inflate(R.layout.activity_base_form, null); FrameLayout frameBaseForm = activityBaseForm.findViewById(R.id.frame_base_form); getLayoutInflater().inflate(layoutResID, frameBaseForm, true); findViewById(R.id.btn_submit).setOnClickListener(v -> submitForm()) // for the sake of simplicity, there's a button that will trigger submitForm() method super.setContentView(activityBaseForm); } } Here, I just include some default layout for a form, and a button for submit that triggers the abstract meth...

Unable to execute include files in PHP Application in Amazon Linux

Image
Clash Royale CLAN TAG #URR8PPP Unable to execute include files in PHP Application in Amazon Linux I'm currently having problem solving why I can't execute inlclude files in my project folder. See /var/logs/httpd/error_log below: Project folder resides at /var/www/payroll /var/www/payroll [Fri Jul 27 05:12:11.793208 2018] [:error] [pid 7904] [client xxx] PHP Warning: include_once(./Controllers/Databasecon.php): failed to open stream: No such file or directory in /var/www/payroll/Controllers/Logout.php on line 2 [Fri Jul 27 05:12:11.793238 2018] [:error] [pid 7904] [client xxx] PHP Warning: include_once(): Failed opening './Controllers/Databasecon.php' for inclusion (include_path='.:/usr/share/pear') in /var/www/payroll/Controllers/Logout.php on line 2 Configured App in VirtualHost <VirtualHost *:80> ServerName binhimefi.com DocumentRoot /var/www <Directory /var/www> DirectoryIndex index.php ...

How to convert boolean and number type Json Key value to string type

Image
Clash Royale CLAN TAG #URR8PPP How to convert boolean and number type Json Key value to string type Iam having a json object where it has different key values of string,boolean and number type.I want to convert the boolean and number type key value to string type..i.e.,eg{"rent":2000,"isPaid":false} which is a valid json .Here i want to convert rent and isPaid to string type i.e.,{"rent":"2000","isPaid":"false"} which is also valid.for this Iam using replacer,but not working exactly how i require var json={"rent":2000,"isPaid":false}; var jsonString = JSON.stringify(json, replacer); function replacer(key, value) { if (typeof value === "boolean"||typeof value === "number") { return "value"; } return value; } console.log(jsonString); Then above code is consoling as {"rent":"value","isPaid":"value"} Then I replaced return "value" w...

Insert pkcs12 to mobileconfig file

Image
Clash Royale CLAN TAG #URR8PPP Insert pkcs12 to mobileconfig file How do I insert a .p12 file in a .mobileconfig file ? .p12 .mobileconfig Apple configuration utility currently performs some unknown transformation/encoding on the .p12 file while inserting it in .mobileconfig (It is just an XML file). .mobileconfig I want to create this .mobileconfig file without using the Apple iPhone configuration utility by directly creating an XML file. Thanks 5 Answers 5 One way to accomplish this is base64 encoding the PKCS#12 file. This, for instance, works with PHP openssl_pkcs12_export( $strCertPEM, $strCertPkcs12, $resKey, $strCertPW ); $arrCertBase64 = str_split( base64_encode($strCertPkcs12), 52); $xmlUserCertPlist = plistVar('PayloadContent',$arrCertBase64,'data'); function plistVar($key,$var,$type) { //...snip... if ( $type == 'data' ) return plistData($key,$var); /...

Better method to check all objects' parameters with a single call

Image
Clash Royale CLAN TAG #URR8PPP Better method to check all objects' parameters with a single call I want to get all objects which age is less than 18. How can easily do that? Should I had to pass all objects to get_nonage to get it? class People: def __init__(self, uid, age): self.uid = uid self.age = age def get_nonage(self): # print nonage here which age<18 # expected output: {1: 11, 3: 15} pass p1 = People(1, 11) p2 = People(2, 20) p3 = People(3, 15) ... People.get_nonage() People.get_nonage() First, get_nonage should probably not be an instance method. Second, yes, you will have to pass it all of the People object if you want it to search all of the People objects. But that implies that you should be storing them in a list, instead of in a bunch of separate variables. Then you just pass the list. – abarnert 13 mins ago ...

aws billing information using aws java sdk

Image
Clash Royale CLAN TAG #URR8PPP aws billing information using aws java sdk I'm trying to get the billing information from aws for ec2 instances, s3 buckets and ebs volumes using java api. I want to create api that gives specific entity wise hourly billing reports. Is there any java api for getting the same? I couldn't find the same in aws java sdk api documentation. 5 Answers 5 There are no APIs to get AWS billing information. Instead what you can do is: For more information: See here I'm actually looking for any API that gives me usage with pricing. Is there any aws api that will provide me usage for EC2 instances, EBS volumes and S3 storage ? – bagui Dec 2 '14 at 10:35 Try getCostAndUsage in the Java SDK : doc...