Posts

Showing posts from May, 2007

Java Method Return Multiple Values Code Example

Example: how to return two values from a function in java int [ ] ans = new int [ 2 ] ; ans [ 0 ] = a + b ; ans [ 1 ] = a - b ; return ans ;

Android Developer Documentation: Download?

Answer : Yes you can. Open SDK Manager (located in android_sdk_dir/SDK Manager.exe ). In the latest API (4.2) select Documentation for Android SDK . Once downloaded, you can find the documentation in android_sdk_dir/docs . Can I download the entire Android Developer documents to my machine and browse it locally? In the SDK Manager simply select "Documentation for Android SDK" for a recent API.

C Tolower Example

Defined in header <ctype.h> int tolower ( int ch ) ; Converts the given character to lowercase according to the character conversion rules defined by the currently installed C locale. In the default "C" locale, the following uppercase letters ABCDEFGHIJKLMNOPQRSTUVWXYZ are replaced with respective lowercase letters abcdefghijklmnopqrstuvwxyz . Parameters ch - character to be converted. If the value of ch is not representable as unsigned char and does not equal EOF , the behavior is undefined. Return value Lowercase version of ch or unmodified ch if no lowercase version is listed in the current C locale. Example # include <stdio.h> # include <ctype.h> # include <locale.h> # include <limits.h> int main ( void ) { /* In the default locale: */ unsigned char l ; for ( unsigned char u = 0 ; u < UCHAR_MAX ; u ++ ) { l = tolower ( u ) ; if ( l != u

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)...

Flex-direction Column In Bootstrap 4 Code Example

Example 1: bootstrap flex direction column d-flex flex-column Example 2: ustify-content: flex-end; bootstrap <div class= "d-flex justify-content-end" >...</div> Example 3: flex direction column bootstrap 4 <div class= "d-flex justify-content-start" >...</div> <div class= "d-flex justify-content-end" >...</div> <div class= "d-flex justify-content-center" >...</div> <div class= "d-flex justify-content-between" >...</div> <div class= "d-flex justify-content-around" >...</div>

Convert Byte Array To String In Python Code Example

Example 1: bytes to string python # utf-8 is used here because it is a very common encoding, but you # need to use the encoding your data is actually in. bytes = b'abcde' bytes.decode("utf-8") 'abcde' Example 2: bytearray to string python bytesliteral ::= bytesprefix(shortbytes | longbytes) bytesprefix ::= "b" | "B" | "br" | "Br" | "bR" | "BR" shortbytes ::= "'" shortbytesitem* "'" | '"' shortbytesitem* '"' longbytes ::= "'''" longbytesitem* "'''" | '"""' longbytesitem* '"""' shortbytesitem ::= shortbyteschar | bytesescapeseq longbytesitem ::= longbyteschar | bytesescapeseq shortbyteschar ::= longbyteschar ::= bytesescapeseq ::= "\"

Border Shadow In React Native Code Example

Example 1: box shadow react native shadowColor : "#000" , shadowOffset : { width : 0 , height : 2 , } , shadowOpacity : 0.25 , shadowRadius : 4.84 , elevation : 5 , Example 2: react-native shadow generator shadowColor : "#000" , shadowOffset : { width : 0 , height : 2 , } , shadowOpacity : 0.25 , shadowRadius : 3.84 , elevation : 5 , Example 3: box shadow in react native shadowColor : "#000" , shadowOffset : { width : 0 , height : 4 , } , shadowOpacity : 0 , shadowRadius : 4.65 , elevation : 8 , Example 4: shadow border react native shadowColor : "#000" , shadowOffset : { width : 0 , height : 11 , } , shadowOpacity : 0.55 , shadowRadius : 14.78 , elevation : 22 , Example 5: box shadow in react native shadowColor : "#000" , shadowOffset : { width : 0 , height : 1 , } , shadowOpacity : 0.20 , shadowRadius : 1.41 , elevation : 2 , Example 6: b

Bootstrap Small Text Highlight Code Example

Example 1: bootstrap text size h1. Bootstrap heading h2. Bootstrap heading h3. Bootstrap heading h4. Bootstrap heading h5. Bootstrap heading h6. Bootstrap heading Example 2: bootstrap blockquote Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante. Someone famous in Source Title

Alert In Html W3 School Code Example

Example: javascript alert alert ( "string" ) ;

Make Width Dynamic Css Code Example

Example: css dynamic width <div style= "width:100%;" > <div style= "width:50px; float: left;" ><img src= "myleftimage" /></div> <div style= "width:50px; float: right;" ><img src= "myrightimage" /></div> <div style= "display:block; margin-left:auto; margin-right: auto;" >Content Goes Here</div> </div>

Convert OVA To VHD For Usage In Hyper-V

Answer : Quite easy actually, install VirtualBox that comes with the program VBoxManage.exe. It can be used with clonehd to specify the new format of the disk. You specify the original disk file, in this case the .vmdk, and then give a location and name to output the .vhd. Open a cmd prompt, CD to C:\Program Files\Oracle\VirtualBox or Virtualbox install directory and then run: VBoxManage.exe clonehd --format vhd "C:\temp\VM\disk1.vmdk" "C:\temp\VM\disk1.vhd" Documentation for VirtualBox: https://www.virtualbox.org/manual/ch08.html#vboxmanage-clonevdi Then I created a new virtual machine from Hyper-V Manager and selected "Use an existing virtual hard disk". Worked perfectly. Use this guide for internet access: https://superuser.com/a/472854/405096 I can't comment yet, but this is a followup to the comment of Ogglas If you get the message: 'VBoxManage.exe' is not recognized as an internal or external command, operable program or batch f

Angry Ip Scanner Download Code Example

Example: Angry IP Scanner It's an IP Scanner to find open ports in the server and vulnerabelities

Can One Change A Group To A Subgroup In GitLab?

Answer : For more current information, this feature has now been added to gitlab and you can transfer an existing group to become a subgroup of a different existing group. The linked issue in @Zeta 's answer was closed and this issue (https://gitlab.com/gitlab-org/gitlab-ce/issues/31885) became the primary issue on this topic. At the time of writing this, the method to change a group to a subgroup is as follows: go to the group you want to turn into a subgroup. Go to the general settings of that group. Expand "Path, transfer, remove". Under this is a "Transfer group" box where you select your desired parent group that you manage. After specifying the desired parent group, hit transfer group and it should be moved to the appropriate path. Gitlab Notes (taken from gitlab web interface): Be careful. Changing a group's parent can have unintended side effects. You can only transfer the group to a group you manage. You will still need to upda

Contactor Vs Relay

Image
Answer : Wikipedia's Contactor article explains it pretty well. Unlike general-purpose relays, contactors are designed to be directly connected to high-current load devices . Relays tend to be of lower capacity and are usually designed for both normally closed and normally open applications. Devices switching more than 15 amperes or in circuits rated more than a few kilowatts are usually called contactors. Apart from optional auxiliary low current contacts, contactors are almost exclusively fitted with normally open ("form A") contacts . Unlike relays, contactors are designed with features to control and suppress the arc produced when interrupting heavy motor currents . [Emphasis mine.] Further down the same article ... Differences between a relay and a contactor: Contactors generally are spring loaded to prevent contact welding. Arc-suppression relays usually have NC contacts; contactors usually do not (when de-energerzied, there is no connection). Ma

Angular Read Text File From Local Path Code Example

Example 1: read file javascript // As with JSON, use the Fetch API & ES6 fetch('something.txt') .then(response => response.text()) .then(data => { // Do something with your data console.log(data); }); Example 2: html get text from file < embed src = " file.txt " > // This will show the text contained in file.txt in the page

Mp3 Yt Converter Code Example

Example 1: youtube mp3 converter You can use WebTools , it's an addon that gather the most useful and basic tools such as a synonym dictionary , a dictionary , a translator , a youtube convertor , a speedtest and many others ( there are ten of them ) . You can access them in two clics , without having to open a new tab and without having to search for them ! - Chrome Link : https : //chrome.google.com/webstore/detail/webtools/ejnboneedfadhjddmbckhflmpnlcomge/ Firefox link : https : //addons.mozilla.org/fr/firefox/addon/webtools/ Example 2: yt to mp3 Youtube - DL works great . Download from https : //youtube-dl.org/. To use, type youtube-dl <url> --audio-format mp3

Can Redux Be Seen As A Pub/sub Or Observer Pattern?

Answer : Redux is not supposed to "replace the initial idea of react.js", think of it more like a library to managed shared state between components and to coordinate state mutations. Redux does use a pub/sub pattern indeed, see the store methods here: http://redux.js.org/docs/api/Store.html#store-methods You'll find a subscribe method that is used by components to subscribe to changes in the state tree. Normally you don't use store.subscribe directly, as the Redux-React bindings (Redux connect basically) do that for you. You can check out the actual implementation here, it's not that complicated to follow (in fact to me that's the main benefit of Redux over other Flux implementations): https://github.com/reduxjs/react-redux/blob/4.x/src/components/connect.js#L199 That code, apart from subscribing to the changes emitted by the store, also perform some optimisations, such as passing new props to the component (and hence triggering a re-render) only when

1s Sleep Python Code Example

Example: delay time python import time time . sleep ( 5 ) # sleeps for 5 seconds

Animator Play Unity Code Example

Example 1: how to play animation with code in unity public GameObject ExampleNPC ; void Update ( ) { if ( Input . GetButtonDown ( "Animation" ) ) // Make sure to refrence this in Input settings { ExampleNPC . GetComponent < Animator > ( ) . Play ( "Anim name" ) ; } } Example 2: play animation through script unity animator . Play ( "StateName" ) ;

Copy Url To Clipboard Via Button Click In A Vuejs Component

Answer : If you need to use vuejs ref add it as attribute <a :href="link_url" class="text-dark" target="_blank" rel="noopener noreferrer" ref="mylink"> {{ link_name }} </a> and use it in your method in the following way: methods: { copyURL() { var Url = this.$refs.mylink; Url.innerHTML = window.location.href; console.log(Url.innerHTML) Url.select(); document.execCommand("copy"); } } However you should take a look to this link to have a better cross-browsing solution. In this case you don't need the ref attribute. This is the solution in the link adapted to your case: methods: { copyUrl() { const el = document.createElement('textarea'); el.value = this.link_url; el.setAttribute('readonly', ''); el.style.position = 'absolute';

C# Linq Select Distinct By Property Code Example

Example 1: c# distinct comparer multiple properties List distinctPeople = allPeople .GroupBy(p => new {p.PersonId, p.FavoriteColor} ) .Select(g => g.First()) .ToList(); Example 2: c# distinct comparer multiple properties public static IEnumerable DistinctBy (this IEnumerable source, Func keySelector) { HashSet seenKeys = new HashSet (); foreach (TSource element in source) { if (seenKeys.Add(keySelector(element))) { yield return element; } } }

Slick Slider Vertical Variable Height Code Example

Example: slickjs height slick-track { display : flex !important ; } .slick-slide { height : auto ; }

Crossover Cable Or Straight Through Between Multiple Hubs/switches

Answer : Most modern hardware – Ethernet switches and computer Ethernet interfaces – implements Auto-MDIX, automatically choosing the correct mode for each physical connection. (This is now a required part of Gigabit Ethernet, but also very common among 100 Mbps ports as well.) In other words, you can use the same type – regular straight-through cables – practically everywhere. Ethernet hubs, however, do not have this feature. They do not participate in link negotiation and only electrically connect all the devices. (Although your devices are probably switches mislabelled as hubs, not actual hubs.) Without this feature, two hubs or switches (just like two computers) would have needed a cross-over cable. That is, unless one switch had a dedicated 'Uplink' port, which would accept a straight-through cable instead. (Sometimes the last port had a physical toggle button for this.) I bought super cheap hubs from China so I'm honestly not even sure whether they have that

Can I Make A CSS Grid With Dynamic Number Of Rows Or Columns?

Answer : Okay, after reading the MDN reference, I found the answer! The key to dynamic rows (or columns) is the repeat property. const COLORS = [ '#FE9', '#9AF', '#F9A', "#AFA", "#FA7" ]; function addItem(container, template) { let color = COLORS[_.random(COLORS.length - 1)]; let num = _.random(10000); container.append(Mustache.render(template, { color, num })); } $(() => { const tmpl = $('#item_template').html() const container = $('#app'); for(let i=0; i<5; i++) { addItem(container, tmpl); } $('#add_el').click(() => { addItem(container, tmpl); }) container.on('click', '.del_el', (e) => { $(e.target).closest('.item').remove(); }); }); .container { width: 100%; display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(auto-fill, 120px); grid-row-gap: .5em; grid-column-gap: 1em; } .contain

Change Material Unity C# Code Example

Example 1: c# change material in code currentObject . GetComponent < Renderer > ( ) . material = materialToAssign ; Example 2: how to set material c unity Renderer rend = GetComponent < Renderer > ( ) ; if ( rend != null ) { rend . material = newMaterialRef ; } Example 3: how to change material in script unity public Material Material1 ; //in the editor this is what you would set as the object you wan't to change public Renderer Object ; void Start ( ) { Object . material = Material1 ; }

Alert Javascript Php Code Example

Example 1: alert in php echo '<script>alert("Message")</script>' ; Example 2: show alert in php echo '<script language="javascript">alert("juas");</script>' ; Example 3: alert in php // This is in the PHP file and sends a Javascript alert to the client $message = "Something" ; echo "<script type='text/javascript'>alert(' $message ');</script>" ; Example 4: alert js in php javascript : alert ( 'Email enviado com Sucesso!' ) ; javascript : window . location = 'index.php' ;