Posts

Showing posts from November, 2021

Ahk Print Key Code Example

Example: autohotkey hotkeys #^!s:: ;This occurs when pressed Windows Button+Control+Alt+s Send Sincerely,{enter}John Smith ; This line sends keystrokes to the active (foremost) window. return

Add Column In Table In Postgresql Code Example

Example 1: postgresql add column with constraint ALTER TABLE customers ADD COLUMN contact_name VARCHAR NOT NULL; Example 2: postgresql insert column ALTER TABLE table_name ADD COLUMN new_column_name data_type constraint; Example 3: postgres how to add field created at CREATE TABLE my_table ( id serial NOT NULL, user_name text, created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP //here ) Example 4: alter table add column postgres Alter Postgres Table

Choosing The Correct Upper And Lower HSV Boundaries For Color Detection With`cv::inRange` (OpenCV)

Image
Answer : Problem 1 : Different applications use different scales for HSV. For example gimp uses H = 0-360, S = 0-100 and V = 0-100 . But OpenCV uses H: 0-179, S: 0-255, V: 0-255 . Here i got a hue value of 22 in gimp. So I took half of it, 11, and defined range for that. ie (5,50,50) - (15,255,255) . Problem 2: And also, OpenCV uses BGR format, not RGB. So change your code which converts RGB to HSV as follows: cv.CvtColor(frame, frameHSV, cv.CV_BGR2HSV) Now run it. I got an output as follows: Hope that is what you wanted. There are some false detections, but they are small, so you can choose biggest contour which is your lid. EDIT: As Karl Philip told in his comment, it would be good to add new code. But there is change of only a single line. So, I would like to add the same code implemented in new cv2 module, so users can compare the easiness and flexibility of new cv2 module. import cv2 import numpy as np img = cv2.imread('sof.jpg') ORANGE_MIN = np.

Bootstrap 4 Datepicker

Answer : You can too override default datepicker classes like the following: the default bootstrap font size is 1rem or 16px so update .datepicker class font-size: 0.875em; or/and update the cell width and height: .datepicker td, .datepicker th { width: 1.5em; height: 1.5em; } <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.7.1/css/bootstrap-datepicker.min.css" rel="stylesheet"/> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"></head> <body> <main class="cont

Can I Share MySql Database Files With Windows On Dual Boot?

Answer : Yes, it works but with some quirks. MySQL uses the same fileformats across platforms so all you need is to share the data directory. One problem is that the data directory need to have mysql as owner and group in ubuntu. And Windows is case-insensitive and Linux is case-sensitive so keep all names uniform: either the whole name lowercase or uppercase but do not mix them. From start to finish; if you already have things set up this might need some tweaking to fit your setup: Install and setup MySQL on both systems. Stop the mysql server if it is running. Make a new NTFS partition. Mark the device name (let's call it sdXN for now). Move the mysql data directory from Ubuntu to the new partition. mkdir /{mountpoint}/mysql_data sudo mv /var/lib/mysql /{mountpoint/mysql_data using mv saves permissions. Make a new mysql directory sudo mkdir /var/lib/mysql Mount the NTFS partition at /var/lib/mysql . Change the devicename to what it got when you created the NT

Check Internet Permission Android Code Example

Example 1: android internet permission //Add this to app manifest < uses-permission android: name = " android.permission.INTERNET " /> Example 2: android internet permission < uses-permission android: name = " android.permission.INTERNET " /> Example 3: Android check internet /** * @author Pratik Butani */ public class InternetConnection { /** * CHECK WHETHER INTERNET CONNECTION IS AVAILABLE OR NOT */ public static boolean checkConnection(Context context) { final ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); if (connMgr != null) { NetworkInfo activeNetworkInfo = connMgr.getActiveNetworkInfo(); if (activeNetworkInfo != null) { // connected to the internet // connected to the mobile provider's data plan if (activeNetworkInfo.getType() == ConnectivityManager.TYPE_WIFI) {

Angular 1.6.0: "Possibly Unhandled Rejection" Error

Answer : Try adding this code to your config. I had a similar issue once, and this workaround did the trick. app.config(['$qProvider', function ($qProvider) { $qProvider.errorOnUnhandledRejections(false); }]); The code you show will handle a rejection that occurs before the call to .then . In such situation, the 2nd callback you pass to .then will be called, and the rejection will be handled. However , when the promise on which you call .then is successful, it calls the 1st callback. If this callback throws an exception or returns a rejected promise, this resulting rejection will not be handled , because the 2nd callback does not handle rejections in cause by the 1st. This is just how promise implementations compliant with the Promises/A+ specification work, and Angular promises are compliant. You can illustrate this with the following code: function handle(p) { p.then( () => { // This is never caught. throw new Error(&q

Bootstrap Text Bold Code Example

Example 1: text-bold bootstrap < p class = " font-weight-bold " > Bold text. </ p > Example 2: font weight bootstrap class < p class = " font-weight-bold " > Bold text. </ p > < p class = " font-weight-normal " > Normal weight text. </ p > < p class = " font-weight-light " > Light weight text. </ p > < p class = " font-italic " > Italic text. </ p > Example 3: bootstrap italic < p class = " font-italic " > Italic text. </ p > Example 4: bootstrap 4 font bold font-weight-bold Example 5: bootstrap alignemnt paragraph < p class = " text-justify " > Ambitioni dedisse scripsisse iudicaretur. Cras mattis iudicium purus sit amet fermentum. Donec sed odio operae, eu vulputate felis rhoncus. Praeterea iter est quasdam res quas ex communi. At nos hinc posthac, sitientis piros Afros. Petierunt uti sibi concilium totius Galliae i

Bullet Point Symbol Code Example

Example: latex bullet points \begin{itemize} \item One entry in the list \item Another entry in the list \end{itemize}

Bootstrap Borders Example

Use border utilities to quickly style the border and border-radius of an element. Great for images, buttons, or any other element. Border Use border utilities to add or remove an element’s borders. Choose from all borders or one at a time. Additive < span class = " border " > </ span > < span class = " border-top " > </ span > < span class = " border-end " > </ span > < span class = " border-bottom " > </ span > < span class = " border-start " > </ span > Subtractive < span class = " border-0 " > </ span > < span class = " border-top-0 " > </ span > < span class = " border-end-0 " > </ span > < span class = " border-bottom-0 " > </ span > < span class = " border-start-0 " > </ span > Border color Change the border color using utilities

Check If Port Open Cmd Code Example

Example 1: how to check listening ports on a server $ sudo netstat -plnt Active Internet connections ( only servers ) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0 .0.0:3306 0.0 .0.0:* LISTEN 3686 /mysqld tcp 0 0 :::443 :::* LISTEN 2218 /httpd tcp 0 0 :::80 :::* LISTEN 2218 /httpd tcp 0 0 :::22 :::* LISTEN 1051 /sshd Example 2: how to check listening ports on a server sudo ss -tulwn | grep LISTEN

Auto Increment In MongoDB To Store Sequence Of Unique User ID

Answer : As selected answer says you can use findAndModify to generate sequential IDs. But I strongly disagree with opinion that you should not do that. It all depends on your business needs. Having 12-byte ID may be very resource consuming and cause significant scalability issues in future. I have detailed answer here . You can, but you should not https://web.archive.org/web/20151009224806/http://docs.mongodb.org/manual/tutorial/create-an-auto-incrementing-field/ Each object in mongo already has an id, and they are sortable in insertion order. What is wrong with getting collection of user objects, iterating over it and use this as incremented ID? Er go for kind of map-reduce job entirely I know this is an old question, but I shall post my answer for posterity... It depends on the system that you are building and the particular business rules in place. I am building a moderate to large scale CRM in MongoDb, C# (Backend API), and Angular (Frontend web app) and fou

Are 301 Redirects Possible Using Javascript Or JQuery?

Answer : I know this is an old question but the answers don't really address the primary issue that was presented in the question which is a 301 redirect for SEO purposes (and the answer today may very well be different than it was when the question was originally asked and answered). The answer that no, you can't 301 redirect from the client is technically correct, however (and more importantly) you don't necessarily need to. While a true 301 would be preferred, in cases like this one where it's not possible (or transitioning away from hashbang URLs back to traditional URLs for example), the question is really whether or not there's a viable alternative that accomplishes the goal. Search Engine Land did a detailed test of Google's capabilities regarding JavaScript and this is the related excerpt from that article: JavaScript Redirects We first tested common JavaScript redirects, varying how the URL was represented in different ways. Th

Android EditText Change Hint Color Code Example

Example: edittext hint color < android . support . design . widget . TextInputLayout android : layout_width = "match_parent" android : layout_height = "wrap_content" android : layout_marginTop = "@dimen/dp_10" android : textColorHint = "@color/color_black" - this line - app : hintTextAppearance = "@style/TextLabel" > < EditText android : id = "@+id/et_state" style = "@style/profile_editTextStyle" android : layout_width = "match_parent" android : layout_height = "wrap_content" android : hint = "@string/billingState" android : text = "@string/billingState" / > < / android . support . design . widget

Cdnjs Vue Code Example

Example 1: vue js cdn < script src = "https://cdn.jsdelivr.net/npm/vue@2.6.12/dist/vue.js" > < / script > Example 2: vue cdn < script type = "module" > import Vue from 'https://cdn.jsdelivr.net/npm/vue@2.6.11/dist/vue.esm.browser.js' < / script >

Chart Js 2 How To Set Bar Width

Answer : You were right : The attribute you have to edit is barPercentage . But maybe the error comes from where you edited the value. As you can see in the bar chart options : Name : barPercentage - Type : Number - Default : 0.9 - Description : Percent (0-1) of the available width each bar should be within the category percentage. 1.0 will take the whole category width and put the bars right next to each other. Read More The attribute is actually stored in scales.xAxes (" Options for xAxes " table). So you just have to edit your chart this way : var options = { scales: { xAxes: [{ barPercentage: 0.4 }] } } Here is a fully working example with a custom width ( 0.2 ) for the bar : var data = { labels: ["January", "February", "March", "April", "May", "June", "July"], datasets: [{ label: "My First dataset",

Latex Underline Code Example

Example 1: latex italic text \textit { text } Example 2: latex bold text \textbf { text } Example 3: underline in latex \underline { science } Example 4: latex italic \emph { accident } Example 5: underscore latex \documentclass { article } \begin { document } \texttt { Samp\_Dist\_Corr } \verb | Samp_Dist_Corr | \texttt { Samp\ char `_Dist\ char `_Corr } \end { document }

Android Widget Using Cordova

Answer : Yes, widgets are native Android constructions. But you CAN create your widget for your app with the help of cordova plugin called "cordova-plugin-ace". Made by Microsoft and opened to everyone. Documentation: Official site - http://microsoft.github.io/ace/ Doc for creating widget - http://microsoft.github.io/ace/docs/native-ui/#four I hope it'll be helpfully for you, me and others cordova devs. Widgets are android native constructs that extend a view on the application screen. http://developer.android.com/reference/android/widget/package-summary.html A cordova/phonegap app is an app with a webview backing. Note: webview not android native view. Until someone finds a way to construct a native widget that embeds a webview, then what you have been told so far is correct... i.e. "no". http://cordova.apache.org/docs/en/4.0.0/guide_overview_index.md.html#Overview http://cordova.apache.org/docs/en/4.0.0/guide_hybrid_webviews_index.md.html#

CodeIgniter Htaccess And URL Rewrite Issues

Answer : There are 3 steps to remove index.php . Make below changes in application/config.php file $config['base_url'] = 'http://'.$_SERVER['SERVER_NAME'].'/Your Ci folder_name'; $config['index_page'] = ''; $config['uri_protocol'] = 'AUTO'; Make .htaccess file in your root directory using below code RewriteEngine on RewriteCond $1 !^(index\.php|resources|robots\.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L,QSA] Enable the rewrite engine (if not already enabled) i. First, initiate it with the following command: a2enmod rewrite ii. Edit the file /etc/apache2/sites-enabled/000-default Change all AllowOverride None to AllowOverride All . Note: In latest version you need to change in /etc/apache2/apache2.conf file iii. Restart your server with the following command: sudo /etc/init.d/apache2 restart Your .htaccess is slightly o

Android Numberpicker For Floating Point Numbers

Answer : NumberPicker is not just for integers.. Even you can use Floats String etc. see this and read about it. for tutorials : http://gafurbabu.wordpress.com/2012/03/29/android-number-picker-dialog/ And I had used NumberPicker long ago like this and it might be some use posting here: NumberPicker np; String nums[]= {"Select Fraction","1/64","1/32","3/64","1/16","5/64","3/32","7/64","1/8","9/64","5/32","11/64","3/16","13/64","7/32","15/64","1/4","17/64","9/32","19/64","5/16","21/64","11/32","23/64","3/8","25/64","13/32","27/64","7/16","29/64"}; np = (NumberPicker) findViewById(R.id.np); np.setMaxValue(nums.length-1); np.setMin

Bee Swarm Simulator Description Code Example

Example: Bee swarm simulator description [ To celebrate the first anniversary of Bee Swarm Sim, you can use the code "AnniversaBee" for 48 hours of x2 Pollen and Conversion Rate (this weekend only)! Sorry the update wasn't finished in time - it's almost there though and I expect to release it next weekend. You can use the code to save up honey for upcoming items. ] Grow your own swarm of bees, collect pollen, and make honey in Bee Swarm Simulator! Meet friendly bears, complete their quests and get rewards! As your hive grows larger and larger, you can explore further up the mountain. Use your bees to defeat dangerous bugs and monsters. Look for treasures hidden around the map. Discover new types of bees, all with their own traits and personalities! Join Bee Swarm Simulator Club for free Honey, Treats and Codes!: https://www.roblox.com/My/Groups.aspx?gid=3982592

Bootstrap Timeline Graph Code Example

Example: bootstrap timeline To get the bootstrat timeline go to https://freefrontend.com/bootstrap-timelines/

Latex Double Space Lines Code Example

Example 1: latext double space \usepackage { setspace } \doublespacing Example 2: spacing lines latex \usepackage { setspace } \doublespacing