Posts

Showing posts from May, 2018

"Client Network Socket Disconnected Before Secure TLS Connection Was Established", Node 10

Answer : In case, someone else faces this same problem, a possible solution (if you are using windows OS), is to follow the process below: Press the Windows Key Search For Internet Options Click on "Internet Options" Click On "Connection" Go to LAN Settings Uncheck "Use Proxy Server for LAN ...." It should work but the permanent solution is to make sure you turn all software that might be automatically setting up proxy for you.

Whatsapp Web Url Link Code Example

Example: link whatsapp to website < ! -- link the following URL to the desired icon or button in your code : https : //wa.me/PhoneNumber (see the example below) remember to include the country code -- > < a href = 'https://wa.me/27722840005' target = '_blank' > < i class = "fa fa-whatsapp" > < / i > < / a >

Changing Transparency In Paint.net

Answer : I have come up with these proposed methods, I don't know if there are better ones. Increase transparency of selected area Select the area Cut Paste as new layer Select Layer properties and drag the Opacity slider Merge Layer Down Decrease transparency of selected area Select the area Copy Paste as new layer Choose an appropriate color and use the Fill tool to fill the section completely Select Layer properties and drag the Opacity slider Merge Layer Down My use case is simpler, I want to set all but an outlined object to transparent. Copy/move object to another layer. List item Select outside of object - Tool > Magic Wand works great for me. Delete Select inside of object - Magic Wand again Delete A variant of this is to use the "paint-bucket" fill tool (in Paint.Net) Select a primary or secondary color: F8 to open the color tool More >> to see Opacity - Alpha (lower right corner) Set opacity to 0 for transpar

All The Whitespace Characters? Is It Language Independent?

Answer : Whether a particular character is categorized as a whitespace character or not should depend on the character set being used. That said, it is not impossible that a programming language can make its own definition of what constitutes whitespace. Most modern languages use the Unicode Character set, which does have a definition for space separator characters . Any character in the Zs category is a space separator . You can see the complete list here. In addition you can grep for ;Zs; in the official Unicode Character Database to see those characters. Note that the number of characters in this category may grow as new Unicode versions come into existence, so I will not say how many such characters exist, nor even attempt to list them. In addition to the Zs Unicode category , Unicode also defines character properties . Among the properties defined by Unicode is a Whitespace property. As of Unicode 7.0, characters with this property include all of the characters wi

A Umlaut Latex Code Example

Example: o umlaut latex Some accented characters {\"a} {\^e} {\`i} {\.I} {\o} {\'u} {\aa} {\c c} {\u g} {\l} {\~n} {\H o} {\v r} {\ss} {\r u}

Bootstrap 4 Centralizar Div Code Example

Example 1: centralize div bootstrap This will be centered vertically and horizontally Example 2: bootstrap div vertical center I am centered vertically

Android Vibrate Is Deprecated. How To Use VibrationEffect In Android>= API 26?

Answer : Amplitude is an int value. Its The strength of the vibration. This must be a value between 1 and 255, or DEFAULT_AMPLITUDE which is -1. You can use it as VibrationEffect.DEFAULT_AMPLITUDE More details here with kotlin private fun vibrate(){ val vibrator = context.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { vibrator.vibrate(VibrationEffect.createOneShot(200, VibrationEffect.DEFAULT_AMPLITUDE)) } else { vibrator.vibrate(200) } } You can use this for haptic feedback (vibration): view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); There are other constants available in HapticFeedbackConstants like VIRTUAL_KEY , KEYBOARD_TAP ...

Class Attributes Python Code Example

Example 1: declare class python # To create a simple class : class Shape : def __init__ ( ) : print ( "A new shape has been created!" ) pass def get_area ( self ) : pass # To create a class that uses inheritance and polymorphism # from another class : class Rectangle ( Shape ) : def __init__ ( self , height , width ) : # The constructor super . __init__ ( ) self . height = height self . width = width def get_area ( self ) : return self . height * self . width Example 2: class python class MyClass ( object ) : def __init__ ( self , x ) : self . x = x Example 3: python object with attributes class Object ( object ) : pass a = Object ( ) a . somefield = somevalue Example 4: python class class Dog ( object ) : def __init__ ( self , name , age ) : self . name = name self . age = age def speak ( self ) : print ( "Hi I'm &qu

Bootstrap Button Whit Icon Code Example

Example: how to icon button in html <! DOCTYPE html > < html > < head > < meta name = " viewport " content = " width=device-width, initial-scale=1 " > <!-- Add icon library --> < link rel = " stylesheet " href = " https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css " > < style > .btn { background-color : DodgerBlue ; border : none ; color : white ; padding : 12 px 16 px ; font-size : 16 px ; cursor : pointer ; } /* Darker background on mouse-over */ .btn :hover { background-color : RoyalBlue ; } </ style > </ head > < body > < h2 > Icon Buttons </ h2 > < p > Icon buttons: </ p > < button class = " btn " > < i class = " fa fa-home " > </ i > </ button > < button class = " btn " > < i class = " fa fa-bars

C Online Compiler Programiz Code Example

Example 1: online c compiler I Personally Like https : //www.programiz.com/c-programming/online-compiler/ Example 2: online c compiler You can try https : //www.onlinegdb.com/ this as well, works really well for me. You can also save code there . Example 3: c compilers // I Like https://www.programiz.com/c-programming/online-compiler/

C# Parameterized Query MySQL With `in` Clause

Answer : This is not possible in MySQL. You can create a required number of parameters and do UPDATE ... IN (?,?,?,?). This prevents injection attacks (but still requires you to rebuild the query for each parameter count). Other way is to pass a comma-separated string and parse it. You could build up the parametrised query "on the fly" based on the (presumably) variable number of parameters, and iterate over that to pass them in. So, something like: List foo; // assuming you have a List of items, in reality, it may be a List<int> or a List<myObject> with an id property, etc. StringBuilder query = new StringBuilder( "UPDATE TABLE_1 SET STATUS = ? WHERE ID IN ( ?") for( int i = 1; i++; i < foo.Count ) { // Bit naive query.Append( ", ?" ); } query.Append( " );" ); MySqlCommand m = new MySqlCommand(query.ToString()); for( int i = 1; i++; i < foo.Count ) { m.Parameters.Add(new MySqlParameter(...)); } You cann

Android Generate Debug Keystore Again React Native Code Example

Example: download debug.keystore keytool -genkey -v -keystore ~/.android/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"

Cnoj Generator Code Example

Example: cnpj generator alguns ai: 87.736.276/0001-10 57.768.821/0001-90 84.577.905/0001-19 57.556.282/0001-25 12.872.344/0001-70

Binary Puzzle Solver

Answer : Brachylog, 34 bytes {ℕ<2}ᵐ²&≜{d?ọᵐctᵐ=&{ḅlᵐ⌉<3}ᵐ}&\↰₂& Try it online! This is pretty damn slow, so the test case on TIO is 4x4. I am currently running the 6x6 test case on my computer to see how much time it takes. This takes a list of lists as input. The unknown values should be indicated with variables, that is with all-uppercase strings (and they should all be different, as otherwise you would be indicating that some cells must have the same value) Explanation We constrain the values to be in {0,1} , then we try instantiations of the variables until one respects all 3 rules. This is why this is so slow (because it will try all of them until finding one; and because in that case Brachylog is not implemented well enough so that constraints can be imposed before trying a possible matrix). & Output = Input { }ᵐ² Map two levels on the Input (i.e. each cell): ℕ<2

Accessing EJS Variable In Javascript Logic

Answer : You could directly inject the gameState variable into javascript on the page. <% if (gameState) { %> <h2>I have a game state!</h2> <script> var clientGameState = <%= gameState %> </script> <% } %> Another option might be to make an AJAX call back to the server once the page has already loaded, return the gameState JSON, and set clientGameState to the JSON response. You may also be interested in this: How can I share code between Node.js and the browser? I had the same problem. I needed to use the data not for just rendering the page, but in my js script. Because the page is just string when rendered, you have to turn the data in a string, then parse it again in js. In my case my data was a JSON array, so: <script> var test = '<%- JSON.stringify(sampleJsonData) %>'; // test is now a valid js object </script> Single quotes are there to not be mixed with double-q

Change The 'option' Color With The Attribute 'disabled'

Answer : It can't be both selected and disabled. option:disabled { color: red; } <select> <option selected>Choose something</option> <option disabled>1</option> <option>2</option> <option>3</option> </select> If you want to disable the select, instead of the option you need to moved disabled to the select tag select:disabled { color: red; } <select disabled> <option selected>Choose something</option> <option>1</option> <option>2</option> <option>3</option> </select> Try this: CSS: select{ color:red; } option{ color:black; } try this, hope it will work: in html: <select> <option value="">Choose something</option> <option disabled="disabled" value="" class="red">1</option> <option disabled="di

Bold Greek Letters Latex Code Example

Example: bold italic text in latex \textbf{\textit{text}}

Bootstrap 4: Responsive Sidebar Menu To Top Navbar

Image
Answer : It could be done in Bootstrap 4 using the responsive grid columns. One column for the sidebar and one for the main content. Bootstrap 4 Sidebar switch to Top Navbar on mobile <div class="container-fluid h-100"> <div class="row h-100"> <aside class="col-12 col-md-2 p-0 bg-dark"> <nav class="navbar navbar-expand navbar-dark bg-dark flex-md-column flex-row align-items-start"> <div class="collapse navbar-collapse"> <ul class="flex-md-column flex-row navbar-nav w-100 justify-content-between"> <li class="nav-item"> <a class="nav-link pl-0" href="#">Link</a> </li> .. </ul> </div> </nav> </aside&g

Button Html Href Code Example

Example 1: button verlinken html <a href= "#" > <button>Mein Button</button></a> Example 2: href on a button <button onclick= "window.location.href='/page2'" >Continue</button> Example 3: html button link <button><a href= 'https://google.com' alt= 'Broken Link' >This is a button</a></button> Example 4: buton html href <!-- if you are on Window : --> <button onclick= "window.location.href='page2.html'" > Button </button> <!-- if you are on linux or macOS : --> <button onclick= "location.href='page2.html'" > Button </button> Example 5: html button with link <a href= "https://www.google.com" > <button>Go to Google</button> </a> Example 6: href in button <input type= "button" onclick= "location.href='https://google.com';" va

10 Minutes Milliseconds Code Example

Example: 10 min to milliseconds 10 min to milliseconds -> 600000

Android Studio Custom Button Background Code Example

Example 1: button style android studio style = "@style/Widget.AppCompat.Button" style = "@style/Widget.AppCompat.Button.Colored" style = "@style/Widget.AppCompat.Button.Borderless" style = "@style/Widget.AppCompat.Button.Borderless.Colored" Example 2: design custom button in android android : src = "@drawable/twitter"

Check If Service Exists With Ansible

Answer : See the service_facts module, new in Ansible 2.5. - name: Populate service facts service_facts: - debug: msg: Docker installed! when: "'docker' in services" Of course I could also just check if the wrapper script exists in /etc/init.d. So this is what I ended up with: - name: Check if Service Exists stat: path=/etc/init.d/{{service_name}} register: service_status - name: Stop Service service: name={{service_name}} state=stopped when: service_status.stat.exists register: service_stopped It would be nice if the "service" module could handle "unrecognized service" errors. This is my approach, using the service command instead of checking for an init script: - name: check for apache shell: "service apache2 status" register: _svc_apache failed_when: > _svc_apache.rc != 0 and ("unrecognized service" not in _svc_apache.stderr) - name: disable apache service: name=

Allow Only Numbers And Dot In Script

Answer : This is a great place to use regular expressions. By using a regular expression, you can replace all that code with just one line. You can use the following regex to validate your requirements: [0-9]*\.?[0-9]* In other words: zero or more numeric characters, followed by zero or one period(s), followed by zero or more numeric characters. You can replace your code with this: function validate(s) { var rgx = /^[0-9]*\.?[0-9]*$/; return s.match(rgx); } That code can replace your entire function! Note that you have to escape the period with a backslash (otherwise it stands for 'any character'). For more reading on using regular expressions with javascript, check this out: http://www.regular-expressions.info/javascript.html You can also test the above regex here: http://www.regular-expressions.info/javascriptexample.html Explanation of the regex used above: The brackets mean " any character inside these brackets ." Y