Posts

Showing posts from December, 2004

Chrome Web Inspector: Find And Replace

Answer : Nothing built in natively. There is a Search and Replace plugin that might help if you want to change text in the input fields . Alternatively if you want to search and replace in the HTML you could Right Click → Edit as HTML the <body> in the DevTools Elements Panel select all the text with Ctrl + a , paste into your favourite editor, make the change there and paste it back. ***Taken from this page at labnol.org**** While you are on the web page, press Ctrl+Shift+J on Windows or Cmd+Opt+J on Mac to open the Console window inside Chrome Developer tools. Now enter the following commands to replace all occurrences of the word ABC with XYZ. document.body.innerHTML = document.body.innerHTML.replace(/ABC/g, "XYZ") document.head.innerHTML = document.head.innerHTML.replace(/ABC/g, "XYZ")

Ansible Command Module Says That '|' Is Illegal Character

Answer : From the doc: command - Executes a command on a remote node The command module takes the command name followed by a list of space-delimited arguments. The given command will be executed on all selected nodes. It will not be processed through the shell, so variables like $HOME and operations like "<", ">", "|", and "&" will not work (use the shell module if you need these features). shell - Executes a commands in nodes The shell module takes the command name followed by a list of space-delimited arguments. It is almost exactly like the command module but runs the command through a shell (/bin/sh) on the remote node. Therefore you have to use shell: dpkg -l | grep python-apt . read about the command module in the Ansible documentation: It will not be processed through the shell, so .. operations like "<", ">", "|", and "&" will not work As it recommends, use t

AngularJS - Convert Dates In Controller

Answer : item.date = $filter('date')(item.date, "dd/MM/yyyy"); // for conversion to string http://docs.angularjs.org/api/ng.filter:date But if you are using HTML5 type="date" then the ISO format yyyy-MM-dd MUST be used. item.dateAsString = $filter('date')(item.date, "yyyy-MM-dd"); // for type="date" binding <input type="date" ng-model="item.dateAsString" value="{{ item.dateAsString }}" pattern="dd/MM/YYYY"/> http://www.w3.org/TR/html-markup/input.date.html NOTE: use of pattern="" with type="date" looks non-standard, but it appears to work in the expected way in Chrome 31. create a filter.js and you can make this as reusable angular.module('yourmodule').filter('date', function($filter) { return function(input) { if(input == null){ return ""; } var _date = $filter('date')(new Date(input), 

Axio Npm Code Example

Example 1: axios npm $ npm install axios Example 2: install axios npm install axios Example 3: axios get const axios = require('axios'); // Make a request for a user with a given ID axios.get('/user?ID=12345') .then(function (response) { // handle success console.log(response); }) .catch(function (error) { // handle error console.log(error); }) .then(function () { // always executed }); // Optionally the request above could also be done as axios.get('/user', { params: { ID: 12345 } }) .then(function (response) { console.log(response); }) .catch(function (error) { console.log(error); }) .then(function () { // always executed }); // Want to use async/await? Add the `async` keyword to your outer function/method. async function getUser() { try { const response = await axios.get('/user?ID=12345'); console.log(response); } catch (error) { console.error(error);

Button Animation CSS Code Example

Example 1: html css good button < button style = "background-color: turquoise; border: none; border-radius: 5px; color: #333; /* Dark grey */ padding: 15px 32px" > Example button < / button > Example 2: how to add animation to a button hover . btn { background - color : #ddd ; border : none ; color : black ; padding : 16 px 32 px ; text - align : center ; font - size : 16 px ; margin : 4 px 2 px ; transition : 0.3 s ; } . btn : hover { background - color : # 3e8 e41 ; color : white ; }

Button Click Send Email Javascript Code Example

Example 1: onclick send to email javascript function sendMail ( ) { var link = "mailto:me@example.com" + "?cc=myCCaddress@example.com" + "&subject=" + encodeURIComponent ( "This is my subject" ) + "&body=" + encodeURIComponent ( document . getElementById ( 'myText' ) . value ) ; window . location . href = link ; } Example 2: onclick send to email javascript < textarea id = "myText" > Lorem ipsum ... < / textarea > < button onclick = "sendMail(); return false" > Send < / button >

C++ Code File Extension? .cc Vs .cpp

Answer : At the end of the day it doesn't matter because C++ compilers can deal with the files in either format. If it's a real issue within your team, flip a coin and move on to the actual work. GNU GCC recognises all of the following as C++ files, and will use C++ compilation regardless of whether you invoke it through gcc or g++: .C , .cc , .cpp , .CPP , .c++ , .cp , or .cxx . Note the .C - case matters in GCC, .c is a C file whereas .C is a C++ file (if you let the compiler decide what it is compiling that is). GCC also supports other suffixes to indicate special handling, for example a .ii file will be compiled as C++, but not pre-processed (intended for separately pre-processed code). All the recognised suffixes are detailed at gcc.gnu.org Great advice on which to use for the makefile and other tools, considering non-compiler tools while deciding on which extension to use is a great approach to help find an answer that works for you. I just wanted to add

Circle Button Flutter Code Example

Example 1: circular button in flutter Container ( width : 90 , height : 90 , child : RaisedButton ( onPressed : ( ) { } , color : Colors . deepOrange , textColor : Colors . white , shape : CircleBorder ( side : BorderSide . none ) , child : Text ( 'Login' , style : TextStyle ( fontSize : 20.0 ) , ) , ) , ) Example 2: circle around icon flutter CircleAvatar ( backgroundColor : Colors . white , radius : 30 , child : Icon ( Icons . add ) , ) , Example 3: flutter icon button circle ClipOval ( child : Material ( color : Colors . blue , // button color child : InkWell ( splashColor : Colors . red , // inkwell col

Bootstrap 4 Previous Next Pager Code Example

Example 1: bootstrap pagination < nav aria-label = " Page navigation example " > < ul class = " pagination " > < li class = " page-item " > < a class = " page-link " href = " # " > Previous </ a > </ li > < li class = " page-item " > < a class = " page-link " href = " # " > 1 </ a > </ li > < li class = " page-item " > < a class = " page-link " href = " # " > 2 </ a > </ li > < li class = " page-item " > < a class = " page-link " href = " # " > 3 </ a > </ li > < li class = " page-item " > < a class = " page-link " href = " # " > Next </ a > </ li > </ ul > </ nav > Example 2: bootstrap 4 pagination center Use the class .ju

Array Foreach In Jquery Code Example

Example 1: jquery loop through array var arr = [ 'one' , 'two' , 'three' , 'four' , 'five' ] ; $ . each ( arr , function ( index , value ) { console . log ( 'The value at arr[' + index + '] is: ' + value ) ; } ) ; Example 2: foreach jquery $ ( "li" ) . each ( function ( index ) { console . log ( index + ": " + $ ( this ) . text ( ) ) ; } ) ;

Lru Cache Gfg Practice Code Example

Example: lru cache gfg List < int > queue , map < int , int > mp

Casting Datareader Value To A To A Nullable Variable

Answer : Use the "IsDbNull" method on the data reader... for example: bool? result = dataReader.IsDbNull(dataReader["Bool_Flag"]) ? null : (bool)dataReader["Bool_Flag"] Edit You'd need to do something akin to: bool? nullBoolean = null; you'd have bool? result = dataReader.IsDbNull(dataReader["Bool_Flag"]) ? nullBoolean : (bool)dataReader["Bool_Flag"] Consider doing it in a function. Here's something I used in the past (you can make this an extension method in .net 4): public static T GetValueOrDefault<T>(SqlDataReader dataReader, System.Enum columnIndex) { int index = Convert.ToInt32(columnIndex); return !dataReader.IsDBNull(index) ? (T)dataReader.GetValue(index) : default(T); } Edit As an extension (not tested, but you get the idea), and using column names instead of index: public static T GetValueOrDefault<T>(this SqlDataReader dataReader, string columnName) { return !dataR

Building Dockerfile Fails When Touching A File After A Mkdir

Image
Answer : Looking at https://registry.hub.docker.com/u/library/jenkins/, it seems that /var/jenkins_home is a volume. You can only create files there while the container is running, presumably with a volume mapping like docker run ... -v /your/jenkins/home:/var/jenkins_home ... The docker build process knows nothing about shared volumes. This is currently investigated in docker/docker/issues/3639, and summarized in this comment: Okay, I did little research and it seems that volume is non-mutable between Dockerfile instruction . Here even smaller Dockerfile for testing: FROM busybox RUN mkdir /tmp/volume RUN echo "hello" > /tmp/volume/hello VOLUME ["/tmp/volume/"] RUN [[ -f /tmp/volume/hello ]] RUN rm /tmp/volume/hello RUN [[ ! -e /tmp/volume/hello ]] On each instruction we create new volume and copy content from original volume . Update April 2019: Use DOCKER_BUILDKIT=1 The new builder does not exhibit this behavior. Example

Javascript Int.parse Code Example

Example 1: how to convert string to int js let string = "1" ; let num = parseInt ( string ) ; //num will equal 1 as a int Example 2: intval js parseInt ( value ) ; let string = "321" console . log ( string ) ; // "321" <= string let number = parseInt ( string ) ; console . log ( number ) // 321 <=int Example 3: Javascript string to int var myInt = parseInt ( "10.256" ) ; //10 var myFloat = parseFloat ( "10.256" ) ; //10.256 Example 4: string to int javascript var text = '42px' ; var integer = parseInt ( text , 10 ) ; // returns 42 Example 5: string to number javascript new Number ( valeur ) ; var a = new Number ( '123' ) ; // a === 123 donnera false var b = Number ( '123' ) ; // b === 123 donnera true a instanceof Number ; // donnera true b instanceof Number ; // donnera false Example 6: javascript pareseint parseInt ( string , radix ) ; console . log ( par

Chrome Push Notification - How To Open URL Adress After Click?

Answer : I am guessing you are in a Service Worker context, because that's where Push Notifications are received. So you have the self object to add a event listener to, that will react to a click on the notification. self.addEventListener('notificationclick', function(event) { let url = 'https://example.com/some-path/'; event.notification.close(); // Android needs explicit close. event.waitUntil( clients.matchAll({type: 'window'}).then( windowClients => { // Check if there is already a window/tab open with the target URL for (var i = 0; i < windowClients.length; i++) { var client = windowClients[i]; // If so, just focus it. if (client.url === url && 'focus' in client) { return client.focus(); } } // If not, then open the target URL in a new window/tab. if (clients.open

Clear Npm-cache/_npx Code Example

Example 1: npm clear cache npm cache clean -- force Example 2: npm cache clean # To clear a cache in npm , we need to run the npm cache clean -- force command in our terminal : npm cache clean -- force # clean : It deletes the all data from your cache folder . # You can also verify the cache , by running the following command : npm cache verify

Clear Azure Redis Cache

Image
Answer : For Azure's Redis service, the Azure portal has a built-in console (which is in Preview): At this point, it's as simple as executing a flushall command: If you're running Redis in, say, a VM, you'll need to use a tool to connect remotely to the cache and run the flushall command.

ACE Editor Autocomplete - Custom Strings

Answer : you need to add a completer like this var staticWordCompleter = { getCompletions: function(editor, session, pos, prefix, callback) { var wordList = ["foo", "bar", "baz"]; callback(null, wordList.map(function(word) { return { caption: word, value: word, meta: "static" }; })); } } langTools.setCompleters([staticWordCompleter]) // or editor.completers = [staticWordCompleter] If you want to persist the old keyword list and want to append a new list var staticWordCompleter = { getCompletions: function(editor, session, pos, prefix, callback) { var wordList = ["foo", "bar", "baz"]; callback(null, [...wordList.map(function(word) { return { caption: word, value: word, meta: "static" }; }), ...ses

A Man Rows A Boat At A Speed Of 5km/hr In Still Water Code Example

Example: A boat covers a certain distance downstream in 1 hour, while it comes back in 1 hour 40 min. If the speed of the stream be 5 kmph, what is the speed of the boat in still water? A boat covers a certain distance downstream in 1 hour, while it comes back in 1 hour 40 min. If the speed of the stream be 5 kmph, what is the speed of the boat in still water?

Boku No Pico How Old Is Pico Code Example

Example 1: boku no pico I am telling you don't do it Example 2: Boku No Pico Please no..

Bootstrap 4 Hr Bold Code Example

Example 1: css thinner hr hr { border: none; height: 1px; /* Set the hr color */ color: #333; /* old IE */ background-color: #333; /* Modern Browsers */ } Example 2: make bigger in boootstrap < hr style = " height : 1 px ; border : none ; color : #333 ; background-color : #333 ; " />

Android Studio - No Target Device Found

Answer : Go to Run in the toolbar. Select Edit Configurations.. On the left panel, you'll see your application (app). On the right under Deployment Target Options choose Target as Open Select Deployment Target Dialog option. And the other option as it is. I ended up downloading the official Samsung ADB from here: http://developer.samsung.com/technical-doc/view.do?v=T000000117 And it worked great after that. Thanks everyone! On the phone Have you enabled Developer Mode? Have you enabled USB debugging within the Developer Tools menu in settings (this menu doesn't appear unless you've enabled Developer Mode) Do you have a good and securely connected USB cable? In Android Studio In Edit Run/Debug Configurations, do you have "Target: USB Device"? It seems to help me to press the "Attach debugger to Android process" icon (a tall rectangle with a green beetle) and cancelling before pressing the "Debug app" icon In Windows