Posts

Showing posts from February, 2004

Call Ghostscript In Windows By Its Invocation Name?

Answer : There are several possibilities. To list the two most frequent ones: c:\full\path\to\gswin32c.exe should always work. For 64bit systems, use c:\full\path\to\gswin64c.exe . After a fresh installation using a standard windows installer, you may need to reboot before the updated %path% environment variable is used. Open a cmd window and (assuming your Ghostscript installation ended up in c:\path\to\gs ...) then type set path=c:\path\to\gs\gs9.02\bin;%path% . From this same cmd window you can now simply use gswin32c to start Ghostscript (use gswin64c on 64 bit Windows)...

Axios Post Request With Headers And Body Example

Example 1: pass header in axios const headers = { 'Content-Type': 'application/json', 'Authorization': 'JWT fefege...' } axios.post(Helper.getUserAPI(), data, { headers: headers }) .then((response) => { dispatch({ type: FOUND_USER, data: response.data[0] }) }) .catch((error) => { dispatch({ type: ERROR_FINDING_USER }) }) Example 2: axios post with header // Send a POST request axios({ method: 'post', url: '/user/12345', data: { firstName: 'Fred', lastName: 'Flintstone' }, headers: {'Authorization': 'Bearer ...'} }); Example 3: how to send header in axios const username = '' const password = '' const token = Buffer.from(`${username}:${password}`, 'utf8').toString('base64') const url = 'https://...' axios.post(url, { headers: { 'Authorization': `Basic ${token}` } })

C: How To Free Nodes In The Linked List?

Answer : An iterative function to free your list: void freeList(struct node* head) { struct node* tmp; while (head != NULL) { tmp = head; head = head->next; free(tmp); } } What the function is doing is the follow: check if head is NULL, if yes the list is empty and we just return Save the head in a tmp variable, and make head point to the next node on your list (this is done in head = head->next Now we can safely free(tmp) variable, and head just points to the rest of the list, go back to step 1 Simply by iterating over the list: struct node *n = head; while(n){ struct node *n1 = n; n = n->next; free(n1); }

Code For A Simple JavaScript Countdown Timer?

Answer : var count=30; var counter=setInterval(timer, 1000); //1000 will run it every 1 second function timer() { count=count-1; if (count <= 0) { clearInterval(counter); //counter ended, do something here return; } //Do code for showing the number of seconds here } To make the code for the timer appear in a paragraph (or anywhere else on the page), just put the line: <span id="timer"></span> where you want the seconds to appear. Then insert the following line in your timer() function, so it looks like this: function timer() { count=count-1; if (count <= 0) { clearInterval(counter); return; } document.getElementById("timer").innerHTML=count + " secs"; // watch for spelling } I wrote this script some time ago: Usage: var myCounter = new Countdown({ seconds:5, // number of seconds to count down onUpdateStatus: function(sec){console.log(sec);}, // callback for each

Share Link Whatsapp Link Code Example

Example: whatsapp share link for website < a href = "https://api.whatsapp.com/send?text=www.google.com" data - action = "share/whatsapp/share" > Share via Whatsapp web < / a >

Change Margins Latex Code Example

Example: latex page margin \usepackage{geometry} \geometry{ a4paper, total={170mm,257mm}, left=20mm, top=20mm, }

Assertequals Python 3 Code Example

Example: python unittest setUpClass class MyUnitTest(unittest.TestCase): @classmethod def setUpClass(cls): do_something_expensive_for_all_sets_of_tests() class MyFirstSetOfTests(MyUnitTest): @classmethod def setUpClass(cls): super(MyFirstSetOfTests, cls).setUpClass() do_something_expensive_for_just_these_first_tests()

Activate Venv Windows 10 Code Example

Example 1: how to activate a venv in windows \env\Scripts\activate.bat Example 2: windows activate venv venv\Scripts\activate Example 3: activate virtual environment python windows 10 cd C: Path to virtual environment> .\activate

C++ Requesting MSVCP110D.dll Even Though Staticly Linked

Answer : weird , asking for the debug version Tells you what you did wrong, you accidentally copied the Debug build of the DLL instead of the Release build. Since you only changed the setting for the Release build, it still requires msvcp110d.dll. It is in general wise to change such a setting for all configurations and all platforms. Tedious, so it often gets skipped. I copied the requested library manually in the release path and still wont work Right, that cannot work since you injected the DLL. A different process. So when it is loaded, the install directory for the game is searched for the file, not the directory where your utility is installed. Your friend needs the Visual-C++ Redistributables in order to properly run your injector, and for the DLL to be loaded. However After Injection, the dll is trying to LoadLibrary (if GetModuleHandle fails) the CRT dlls. There are a lot of them! You have some options: Include the required DLLs inside your I

Youtube-dl Get Mp3 Code Example

Example 1: youtube-dl mp3 only youtube - dl - x -- audio - format mp3 < youtube - link > Example 2: linux download youtube mp3 youtube - dl -- extract - audio -- audio - format mp3 < video URL >

Any Way To Make JQuery.inArray() Case Insensitive?

Answer : In case anyone wanted a more integrated approach using jquery: (function($){ $.extend({ // Case insensative $.inArray (http://api.jquery.com/jquery.inarray/) // $.inArrayIn(value, array [, fromIndex]) // value (type: String) // The value to search for // array (type: Array) // An array through which to search. // fromIndex (type: Number) // The index of the array at which to begin the search. // The default is 0, which will search the whole array. inArrayIn: function(elem, arr, i){ // not looking for a string anyways, use default method if (typeof elem !== 'string'){ return $.inArray.apply(this, arguments); } // confirm array is populated if (arr){ var len = arr.length; i = i ? (i < 0 ? Math.max(0, len + i) : i) : 0; elem = elem.toLowerCa

Horizontal Space Latex Code Example

Example 1: give space in latex Horizontal \hspace { 1 cm } spaces can be inserted manually . Useful to control the fine - tuning in the layout of pictures . Left Side \hfill Right Side Example 2: spacing lines latex \usepackage { setspace } \doublespacing

How To Compare Char * And Strings In C Code Example

Example: statement o compare two strings in c # include <stdio.h> # include <string.h> int main ( ) { char str1 [ ] = "abcd" , str2 [ ] = "abCd" , str3 [ ] = "abcd" ; int result ; // comparing strings str1 and str2 result = strcmp ( str1 , str2 ) ; printf ( "strcmp(str1, str2) = %d\n" , result ) ; // comparing strings str1 and str3 result = strcmp ( str1 , str3 ) ; printf ( "strcmp(str1, str3) = %d\n" , result ) ; return 0 ; }

Apple - Can I Use Apple's Thunderbolt 3 (USB-C) To Thunderbolt 2 Adapter For Target Display Mode On An IMac?

Answer : Yes, I'm successfully running a setup with a 2017 13" MacBook Pro and a 2011 iMac. The original Apple USB-C to Thunderbolt 2 Adapter works fine for Target Display Mode.

Auto Package Download For TeXLive

Answer : While in MiKTeX an installation process is automatically triggered if you have, say, \usepackage{beamer} in a document preamble without the corresponding package installed, there is no such feature on TeX Live. The last statement is not true actually, as pointed out by wasteofspace in the comments there is the texliveonfly package that implements the on demand installation in TeX Live 2010 and later. I never tested it and don't know if it has drawbacks. However, if you install the full (or almost full) TeX Live collection of packages (~2400) you will not need to add new packages, a periodic tlmgr update -all will take care of everything, including the installation of packages added to the TeX Live collection after you first full installation. This feature is explained in the tlmgr manual. Analogously, if a package has been added to a collection on the server that is also installed locally, it will be added to the local installation. This is called auto-

SUBSTR In Oracle Code Example

Example 1: plsql left() function SUBSTR ( "20190601" , 0 , 6 ) Example 2: oracle substring -- ORACLE substr ( string , start , [ , length ] ) SELECT substr ( 'Hello World' , 4 , 5 ) FROM DUAL ; -- lo Wo SELECT substr ( 'Hello World' , 4 ) FROM DUAL ; -- lo World SELECT substr ( 'Hello World' , - 3 ) FROM DUAL ; -- rld Example 3: plsql substr SUBSTR ( string , start_position [ , length ] ) Example 4: oracle leftmost characters -- For Oracle only -- syntax SUBSTR ( < main - string > , 1 , < number - of - characters > ) -- example SUBSTR ( 'Useless stuff' , 1 , 10 ) -- OUTPUT : Useless st -- practical example SELECT SUBSTR ( 'Useless stuff' , 1 , 10 ) FROM DUAL ; Example 5: ORACLE SQL SUBSTR SUBSTR ( string , : START_POS , : SUBSTR_LENGTH ) ; SELECT SUBSTR ( 'ABCDEFG' , 3 , 4 ) FROM DUAL ; -- OUTPUT : CDEF Example 6: Subtr Oracle ? /*Usi

Can Spring Security Use @PreAuthorize On Spring Controllers Methods?

Answer : Yes, it works fine. You need <security:global-method-security pre-post-annotations="enabled" /> in ...-servlet.xml . It also requires CGLIB proxies, so either your controllers shouldn't have interfaces, or you should use proxy-target-class = true . See Spring Security FAQ (emphasis mine). In a Spring web application, the application context which holds the Spring MVC beans for the dispatcher servlet is often separate from the main application context. It is often defined in a file called myapp-servlet.xml, where “myapp” is the name assigned to the Spring DispatcherServlet in web.xml. An application can have multiple DispatcherServlets, each with its own isolated application context. The beans in these “child” contexts are not visible to the rest of the application. The “parent” application context is loaded by the ContextLoaderListener you define in your web.xml and is visible to all the child contexts. This parent context is u

Underline Markdown Github Code Example

Example 1: how to add link to github readme [ I ' m an inline - style link ] ( https : //www.google.com) [ I 'm an inline-style link with title](https://www.google.com "Google' s Homepage" ) [ I ' m a reference - style link ] [ Arbitrary case - insensitive reference text ] [ I ' m a relative reference to a repository file ] ( . . / blob / master / LICENSE ) [ You can use numbers for reference - style link definitions ] [ 1 ] Or leave it empty and use the [ link text itself ] . URLs and URLs in angle brackets will automatically get turned into links . http : //www.example.com or <http://www.example.com> and sometimes example . com ( but not on Github , for example ) . Some text to show that the reference links can follow later . [ arbitrary case - insensitive reference text ] : https : //www.mozilla.org [ 1 ] : http : //slashdot.org [ link text itself ] : http : //www.reddit.com Example 2: md strikethrough ~ ~ Thi