Posts

Showing posts from September, 2016

Download Youtube Video As A Mp3 Code Example

Example: youtube download mp3 I use https : //github.com/ytdl-org/youtube-dl/ as a Python CLI tool to download videos

Apply On Tailwind Cs Code Example

Example: tailwind css < link href = "https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel = "stylesheet" >

C Strstr Example

Defined in header <string.h> char * strstr ( const char * str , const char * substr ) ; Finds the first occurrence of the null-terminated byte string pointed to by substr in the null-terminated byte string pointed to by str . The terminating null characters are not compared. The behavior is undefined if either str or substr is not a pointer to a null-terminated byte string. Parameters str - pointer to the null-terminated byte string to examine substr - pointer to the null-terminated byte string to search for Return value Pointer to the first character of the found substring in str , or NULL if no such substring is found. If substr points to an empty string, str is returned. Example # include <string.h> # include <stdio.h> void find_str ( char const * str , char const * substr ) { char * pos = strstr ( str , substr ) ; if ( pos ) { printf ( "found the string '%s

Automatic Slideshow Html Code Example

Example 1: html auto slideshow < html > < head > < style > #slider { width : 100 % ; height : 100 % ; margin : 0 auto ; border : 10 px solid transparent ; padding : 0 px ; z-index : 100 ; overflow : hidden ; white-space : nowrap ; box-sizing : border-box ; } #slider > li { width : 100 % ; height : 100 % ; position : relative ; display : inline-block ; overflow : hidden ; font-size : 15 px ; font-size : initial ; line-height : normal ; transition : all 0.5 s cubic-bezier ( 0.4 , 1.3 , 0.65 , 1 ) ; /* Slide css animation */ background-size : cover ; vertical-align : top ; box-sizing : border-box ; white-space : normal ; } </ style > </ head > < body > < ul id =

Adam Ide Code Example

Example 1: atom atom uses js , c + + , c , etc . it is a great ide . ( help they kidnaped my family and made me say this . ) joke : D Example 2: Atom Atom is a hackable text editor for the 21st century , built on Electron , and based on everything we love about our favorite editors . We designed it to be deeply customizable , but still approachable using the default configuration .

Angular (5) Httpclient Observe And ResponseType: 'blob'

Answer : When using observe:response , don't type the call ( post<Blob>(...) ), as the returned Observable will be of HttpResponse. So this should work: this.httpclient.post('MyBackendUrl', params, {observe: 'response', responseType: 'blob'} ); Why this happens, is there's two versions of the post method, one with a generic type, one without: /** * Construct a POST request which interprets the body as JSON and returns the full event stream. * * @return an `Observable` of all `HttpEvent`s for the request, with a body type of `T`. */ post<T>(url: string, body: any | null, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: 'events'; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: 'json'; withCredentials?: boolean

Start Mongodb Service Ubuntu Code Example

Example 1: mongodb install in ubuntu sudo apt update sudo apt install - y mongodb //checking service and db sudo systemctl status mongodb or service mongodb status //start service sudo systemctl start mongod or service mongodb start //stop service sudo systemctl stop mongod or service mongodb stop Example 2: start mongodb service ubuntu sudo systemctl start mongod sudo systemctl stop mongod Example 3: how to start mongodb server in ubuntu sudo systemctl start mongodb # it will starts mongodb server Example 4: ubuntu start mongodb sudo mongod -- fork -- config / etc / mongod . conf

Change Color Of PNG Image Via CSS?

Answer : You can use filters with -webkit-filter and filter : Filters are relatively new to browsers but supported in over 90% of browsers according to the following CanIUse table: https://caniuse.com/#feat=css-filters You can change an image to grayscale, sepia and lot more (look at the example). So you can now change the color of a PNG file with filters. body { background-color:#03030a; min-width: 800px; min-height: 400px } img { width:20%; float:left; margin:0; } /*Filter styles*/ .saturate { filter: saturate(3); } .grayscale { filter: grayscale(100%); } .contrast { filter: contrast(160%); } .brightness { filter: brightness(0.25); } .blur { filter: blur(3px); } .invert { filter: invert(100%); } .sepia { filter: sepia(100%); } .huerotate { filter: hue-rotate(180deg); } .rss.opacity { filter: opacity(50%); } <!--- img src http://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/500px-M

AndAlso/OrElse In VBA

Answer : The only short circuiting (of a sort) is within Case expression evaluation, so the following ungainly statement does what I think you're asking; Select Case True Case (myObject Is Nothing), Not myObject.test() MsgBox "no instance or test == false" Case Else MsgBox "got instance & test == true" End Select End Sub This is an old question, but this issue is still alive and well. One workaround I've used: Dim success As Boolean ' False by default. If myObj Is Nothing Then ' Object is nothing, success = False already, do nothing. ElseIf Not myObj.test() Then ' Test failed, success = False already, do nothing. Else: success = True ' Object is not nothing and test passed. End If If success Then ' Do stuff... Else ' Do other stuff... End If This basically inverts the logic in the original question, but you get the same result. I think it's a cleaner solution t

AttributeError: Module 'tensorflow' Has No Attribute 'contrib' Site:stackoverflow.com Code Example

Example: AttributeError: module 'tensorflow' has no attribute 'variable' site:stackoverflow.com AttributeError: module 'tensorflow' has no attribute 'variable' use variable as Capital 'V' tf.Variable

Clear Cache Extension Chrome Code Example

Example 1: chrome clear cache for one site chrome://settings/siteData Example 2: chrome refresh cache CTRL+F5 : to refresh the page by clearing GG chrome cache. Example 3: how to clear cache chrome ChromeDriver chromeDriver = new ChromeDriver(); chromeDriver.manage().deleteAllCookies(); chromeDriver.get("chrome://settings/clearBrowserData"); chromeDriver.findElementByXPath("//settings-ui").sendKeys(Keys.ENTER); return chromeDriver;

Code Formatter Visual Studio Code Example

Example 1: indent code in vs code The code formatting is available in Visual Studio Code through the following shortcuts : On Windows : Shift + Alt + F On Mac : Shift + Option + F On Linux : Ctrl + Shift + I Example 2: format code in vs code On Windows Shift + Alt + F . On Mac Shift + Option + F . Example 3: format in visual studio code Ctrl + K Ctrl + F

Can \cref Be Made To Ignore Spaces?

Image
Answer : Normalization with removal of spaces before and after label names and removing of empty entries. The following example uses the comma parser of package kvsetkeys for parsing the label name list of the referencing commands of package cleveref . The internal \@cref with the list in its second argument is redefined for this: \documentclass{article} \usepackage{cleveref} \usepackage{kvsetkeys} \makeatletter \let\org@@cref\@cref \renewcommand*{\@cref}[2]{% \begingroup \toks@={}% \comma@parse{#2}\add@cref@item \edef\process@me{\endgroup \noexpand\org@@cref{#1}{\the\toks@}% }\process@me } \newcommand*{\add@cref@item}[1]{% \expandafter\ifx\expandafter\\\the\toks@\\% \toks@{#1}% \else \toks@\expandafter{\the\toks@,#1}% \fi } \makeatother \begin{document} \noindent We can use \cref{1,2}, and now \cref{1, 2},\\ and even with a leading or trailing comma: \Cref{ , 1 , 2 ,}. \section{Section 1} \label{1} \section{Section

Apple - APFS/High Sierra - `tmutil Deletelocalsnapshots` Not Deleting Snapshots

Answer : I think the least-recent time machine snapshots was corrupted - potentially from some system crashes caused by APFS bugs. I tried running DIsk Utility's first aid, but that froze my computer for over 3 hours (maybe it ran out of space to work with?) - I ended up having to force-restart. I solved the problem by running first aid booted from an external hard drive install of High Sierra. It removed some old snapshots. I then was able to boot from my normal drive and run tmutil deletelocalsnapshots... which successfully deleted the snapshots and freed up space Great solution detecting that the filesystem was corrupt when the normal commands were note working. Also note, you can avoid iterating on the list of snapshots and just direct the system to reclaim space up to and surpassing the limit you choose: tmutil thinlocalsnapshots / $(echo "5 * 1000000000" | bc) 2 The above command asks for 5 GB of cleaning. I chose the echo math to make it easy to dial u

Baby Yoda Ascii Code Example

Example: yoda text art .-. |_:_| /(_Y_)\ . ( \/M\/ ) '. _.'-/'-'\-'._ ': _/.--'[[[[]'--.\_ ': /_' : |::"| : '.\ ': // ./ |oUU| \.' :\ ': _:'..' \_|___|_/ : :| ':. .' |_[___]_| :.':\ [::\ | : | | : ; : \ '-' \/'.| |.' \ .;.' | |\_ \ '-' : | | \ \ .: : | | | \ | '. : \ | / \ :. .; | / | | :__/ : \\ | | | \: | \ | || / \ : : |: / |__| /| snd | : : :_/_| /'._\ '--|_\ /___.-/_|-' \ \ '-'

Call Function With SetInterval In JQuery?

Answer : To write the best code, you "should" use the latter approach, with a function reference: var refreshId = setInterval(function() {}, 5000); or function test() {} var refreshId = setInterval(test, 5000); but your approach of function test() {} var refreshId = setInterval("test()", 5000); is basically valid, too (as long as test() is global). Note that there is no such thing really as "in jQuery". You're still writing the Javascript language; you're just using some pre-made functions that are the jQuery library. First of all: Yes you can mix jQuery with common JS :) Best way to build up an intervall call of a function is to use setTimeout methode: For example, if you have a function called test() and want to repeat it all 5 seconds, you could build it up like this: function test(){ console.log('test called'); setTimeout(test, 5000); } Finally you have to trigger the function once: $(document).re

Append Data To HDF5 File With Pandas, Python

Answer : pandas.HDFStore.put() has parameter append (which defaults to False ) - that instructs Pandas to overwrite instead of appending. So try this: store = pd.HDFStore('test.h5') store.append('name_of_frame', ohlcv_candle, format='t', data_columns=True) we can also use store.put(..., append=True) , but this file should also be created in a table format: store.put('name_of_frame', ohlcv_candle, format='t', append=True, data_columns=True) NOTE: appending works only for the table ( format='t' - is an alias for format='table' ) format. tohlcv_candle.to_hdf('test.h5',key='this_is_a_key', append=True, mode='r+', format='t') You need to pass another argument append=True to specify that the data is to be appended to existing data if found under that key, instead of over-writing it. Without this, the default is False and if it encounters an existing table under 'this_is_a_key

Any Way (or Shortcut) To Auto Import The Classes In IntelliJ IDEA Like In Eclipse?

Image
Answer : IntelliJ IDEA does not have an action to add imports. Rather it has the ability to do such as you type. If you enable the "Add unambiguous imports on the fly" in Settings > Editor > General > Auto Import , IntelliJ IDEA will add them as you type without the need for any shortcuts. You can also add classes and packages to exclude from auto importing to make a class you use heavily, that clashes with other classes of the same name, unambiguous. For classes that are ambiguous (or is you prefer to have the "Add unambiguous imports on the fly" option turned off), just type the name of the class (just the name is OK, no need to fully qualify). Use code completion and select the particular class you want: Notice the fully qualified names to the right. When I select the one I want and hit enter, IDEA will automatically add the import statement. This works the same if I was typing the name of a constructor. For static methods, you can even just ke

Bash Shebang For Dummies?

Answer : If a script /path/to/foo begins with #!/bin/bash , then executing /path/to/foo arg1 arg2 is equivalent to executing /bin/bash /path/too/foo arg1 arg2 . If the shebang line is #!/bin/bash -ex , it is equivalent to executing /bin/bash -ex /path/too/foo arg1 arg2 . This feature is managed by the kernel. Note that you can portably have only one argument on the shebang line: some unices (such as Linux) only accept one argument, so that #!/bin/bash -e -x would lead to bash receiving the single five-character argument -e -x (a syntax error) rather than two arguments -e and -x . For the Bourne shell sh and derived shells such as POSIX sh, bash, ksh, and zsh: -e means that if any command fails (which it indicates by returning a nonzero status), the script will terminate immediately. -x causes the shell to print an execution trace. Other programs may understand these options but with different meanings. They are options passed to bash see help set for more info,

Bootstrap Navbar Font Color Code Example

Example: changing navbar color bootstrap $bgDefault : #e74c3c ; $bgHighlight : #c0392b ; $colDefault : #ecf0f1 ; $colHighlight : #ffbbbc ; . navbar - default { background - color : $bgDefault ; border - color : $bgHighlight ; . navbar - brand { color : $colDefault ; & : hover , & : focus { color : $colHighlight ; } } . navbar - text { color : $colDefault ; } . navbar - nav { > li { > a { color : $colDefault ; & : hover , & : focus { color : $colHighlight ; } } } > . active { > a , > a : hover , > a : focus { color : $colHighlight ; background - color : $bgHighlight ; } } > . open { > a , > a : hover , > a : focus { color : $colHighlight ; background - color : $bgHighlight ; } } } . navbar - toggle { border - color : $bgHighlight ; & : ho

Can A Row Be Inside A Container In Bootstrap? Code Example

Example: how will it look when there is a container inside a a row bootstrap <div class= "container" > <div class= "row" > <div class= "col align-self-start" > One of three columns </div> <div class= "col align-self-center" > One of three columns </div> <div class= "col align-self-end" > One of three columns </div> </div> </div>

How To Fix From Origin 'http://localhost:4200' Has Been Blocked By CORS Policy: The 'Access-Control-Allow-Origin' Header Has A Code Example

Example 1: origin 'http://localhost:4200' has been blocked by CORS policy 'Content-Type' : 'application/json' , 'Access-Control-Allow-Origin' : '*' , 'Access-Control-Allow-Headers' : 'Content-Type' , 'Access-Control-Allow-Methods' : 'GET,POST,OPTIONS,DELETE,PUT' , 'Authorization' : 'Bearer key' , Example 2: ccess to XMLHttpRequest at 'http://127.0.0.1:5000/ has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. @app . route ( 'your route' , methods = [ 'GET' ] ) def yourMethod ( params ) : response = flask . jsonify ( { 'some' : 'data' } ) response . headers . add ( 'Access-Control-Allow-Origin' , '*' ) return response

Can We Have Multiple CNAMES For A Single Name?

Answer : Solution 1: Multiple CNAME records for the same fully-qualified domain name is a violation of the specs for DNS. Some versions of BIND would allow you to do this (some only if you specified the multiple-cnames yes option) and would round-robin load-balance between then but it's not technically legal. There are not supposed to be resource records (RRs) with the same name as a CNAME and, to pick nits, that would include multiple identical CNAMEs. Quoth RFC 1034, Section 3.6.2: If a CNAME RR is present at a node, no other data should be present; this ensures that the data for a canonical name and its aliases cannot be different. This rule also insures that a cached CNAME can be used without checking with an authoritative server for other RR types. The letter-of-the RFC method to handle what you're doing would be with a single CNAME referring to a load-balanced "A" record. Solution 2: You cannot. A CNAME makes one record another name for a

Changing Border Color In Mat-form-field

Answer : I think this will cover everything. // mat-icon-stepper selected color change ::ng-deep .mat-step-header .mat-step-icon-selected, .mat-step-header .mat-step-icon-state-done, .mat-step-header .mat-step-icon-state-edit { background-color: red!important; } //input outline color ::ng-deep .mat-form-field-appearance-outline .mat-form-field-outline { color: red!important; // opacity: 1!important; } //mat-input focused color ::ng-deep .mat-form-field-appearance-outline.mat-focused .mat-form-field-outline-thick { color: red!important; } // mat-input error outline color ::ng-deep .mat-form-field-appearance-outline.mat-form-field-invalid.mat-form-field-invalid .mat-form-field-outline-thick{ color: red!important; opacity: 0.8!important; } // mat-input carent color ::ng-deep .mat-input-element { caret-color: red!important; } // mat-input error carent color ::ng-deep .mat-form-field-invalid .mat-input-element, .mat-warn .mat-input-element { caret-

Vim Go To Last Line Code Example

Example 1: how to go to top of file in vim Type "gg" in command mode . This brings the cursor to the first line NOTE : in linux terminal , open a file with vim like below . vim file . c In command mode ( press Esc if you are not sure ) you can use . type "gg" , then cursor will point to the first line first character in file . c file Example 2: vim move to the last line you edited # Basic syntax : ` . Example 3: vijm jump to end of file Move cursor to end of file in vim In short press the Esc key and then press Shift + G to move cursor to end of file in vi or vim text editor under Linux and Unix - like systems

Choosing A Windows Automation Scripting Language. AutoIt Vs Autohotkey

Answer : I think AutoHotkey's GUI implementation is easier to use like many of its commands. AutoHotkey (no longer maintained) has 3 forks : AutoHotkey v1.1.* (previously known as AutoHotkey_L) has COM, Unicode support, object-oriented -like syntax, arrays, and more. AutoHotkeyCE works on Windows mobile PDA's and smartphones (unfinished, no longer maintained). IronAHK, a .NET version of AutoHotkey (unfinished, no longer maintained). AutoHotkey includes a DLL file that you can call from other programming languages (so does AutoIt). AutoHotkey is open source, AutoIt is not. You have to search the AutoHotkey site to put all tools together. AutoIt does better at packaging all in its initial download. My vote is for AutoHotkey (AHK). I've used both very much. AutoHotKey is very good at managing hotkeys and basic GUI automation. It's syntax is horrible and it's not meant for bigger applications. AutoIt has almost every feature AutoHotKey has and much