Posts

Showing posts from August, 2006

101 Rx Examples

Image
Answer : I actually had similar thoughts a couple days ago. We started our own "101 Rx Samples" as a post in the Rx MSDN forum, but we have since moved it to a Wiki format. Please feel free to come over and add your own samples! 101 Rx Samples on the Rx wiki To start with - Here is a simple drawing application, so that when the user drags, we draw a red line from the initial mouse down position to the current location, and also a blue spot at the current location. This is the result of my last week's hack on Rx And here is the source code. //A draw on drag method to perform the draw void DrawOnDrag(Canvas e) { //Get the initial position and dragged points using LINQ to Events var mouseDragPoints = from md in e.GetMouseDown() let startpos=md.EventArgs.GetPosition(e) from mm in e.GetMouseMove().Until(e.GetMouseUp()) select new

Access To XMLHttpRequest At 'http://localhost:8082/api/propertieses' From Origin 'http://localhost:4200' Has Been Blocked By CORS Policy: No 'Access-Control-Allow-Origin' Header Is Present On The Requested Resource. Code Example

Example: 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

How To Determine The Length Of An Array In C Code Example

Example 1: size of an array c int a [ 20 ] ; int length ; length = sizeof ( a ) / sizeof ( int ) ; Example 2: array length c int prices [ 5 ] = { 1 , 2 , 3 , 4 , 5 } ; int size = sizeof prices / sizeof prices [ 0 ] ; printf ( "%u" , size ) ; /* 5 */

C Read Binary Stdin

Answer : What you need is freopen() . From the manpage: If filename is a null pointer, the freopen() function shall attempt to change the mode of the stream to that specified by mode, as if the name of the file currently associated with the stream had been used. In this case, the file descriptor associated with the stream need not be closed if the call to freopen() succeeds. It is implementation-defined which changes of mode are permitted (if any), and under what circumstances. Basically, the best you can really do is this: freopen(NULL, "rb", stdin); This will reopen stdin to be the same input stream, but in binary mode. In the normal mode, reading from stdin on Windows will convert \r\n (Windows newline) to the single character ASCII 10. Using the "rb" mode disables this conversion so that you can properly read in binary data. freopen() returns a filehandle, but it's the previous value (before we put it in binary mode), so don't use i

Android ADB Device Offline, Can't Issue Commands

Answer : Try running adb devices after running adb kill-server . Security question pops up after that. Worked for me. I just got the same problem today after my Nexus 7 and Galaxy Nexus were updated to Android 4.2.2. The thing that fixed it for me was to upgrade the SDK platform-tools to r16.0.1. For me, this version was not displayed in my SDK Manager, so I pulled it down from http://dl.google.com/android/repository/platform-tools_r16.0.1-windows.zip directly. You then need to rename the platform-tools directory and unzip it to android-sdk-windows/platform-tools . Using the SDK Manager, I had also updated to the latest sdk-tools before this. If your whole Eclipse and ADT are ancient, you may need to update them as well, but I didn't need to. Note: you may need to run SDK Manager twice (once to update itself) before you will see the latest packages. It also seems to occur frequently when you connect to the device using the Wi-Fi mode (in Android Studio or in the cons

Conda Install Downgrade Python Version

Answer : If you want to set specific version, use it like this: WARNING: This command will overwrite the default python version system-wise conda install python=3.6 To create environment with a specific version, you can do: conda create -n $PYTHON36_ENV_NAME python=3.6 anaconda # set custom env name The anaconda at the end allows the env to use all anaconda packages For more information refere to Anaconda documentation You can make environments with other versions of Python using this command: conda create --name py33 python=3.3 source activate py33

Contains Array In Javascript Code Example

Example 1: javascript array contains var colors = [ "red" , "blue" , "green" ] ; var hasRed = colors . includes ( "red" ) ; //true var hasYellow = colors . includes ( "yellow" ) ; //false Example 2: js array contains let fruits = [ "Banana" , "Orange" , "Apple" , "Mango" ] ; let do_contain = fruits . includes ( "Mango" ) ; // contain: true

CSS Height: 100% Vs Height: Inherit

Answer : height: 100% will match the height of the element's parent, regardless of the parent's height value. height: inherit will, as the name implies, inherit the value from it's parent. If the parent's value is height: 50% , then the child will also be 50% of the height of it's parent. If the parent's size is defined in absolute values (e.g. height: 50px ), then height: inherit and height: 100% will have the same behaviour for the child.

-94 F To C Code Example

Example: convert fahrenheit to celsius import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int far = sc . nextInt ( ) ; int cel = ( far - 32 ) * 5 / 9 ; System . out . printf ( "%d Fahrenheit is %d Celsius" , far , cel ) ; } }

Can I Transfer My Terraria Character From One PC To Another?

Image
Answer : If you are playing the Steam version with an Internet connection, you can just let Steam do all that work for you by enabling cloud saving for your character. Otherwise, your characters are stored in: Windows: %userprofile%\Documents\My Games\Terraria\Players Mac: ~/Library/Application Support/Terraria/Players Linux: ~/.local/share/Terraria/Players However, if you're using Steam cloud saves, the files will be in a different location. <Steam directory>/userdata/<Steam3 ID>/105600/remote/players To copy a character, you will need both the .plr file and the folder that are named like your character. Technically, only the file is necessary, but the folder contains your minimap data. As of version 1.3 (1.3 Patch Notes), you can save your character via the Steam Cloud service. This can be enabled when creating a character.

Add Banground Image Code Example

Example: how to make a image background how to make a image background

Online Gdb C++ Code Example

Example 1: c++ online compiler This two are good C ++ compilers : https : //www.onlinegdb.com/online_c++_compiler https : //www.programiz.com/cpp-programming/online-compiler/ Example 2: cpp online compiler Best Site With auto compile : https : //godbolt.org/z/nEo4j7

Alter Column Sql Server Code Example

Example 1: sql change column types ALTER TABLE table_name ALTER COLUMN column_name datatype; -- Example ALTER TABLE product ALTER COLUMN description VARCHAR(250); Example 2: sql add column ALTER TABLE Customers ADD Email varchar(255); Example 3: sql server alter column ALTER TABLE table_name ALTER COLUMN column_name new_data_type(size); Example 4: alter table add column ALTER TABLE table ADD COLUMN column VARCHAR (255) NOT NULL AFTER column; Example 5: sqlserver add column to table ALTER TABLE dbo.doc_exa ADD column_b VARCHAR(20) NULL, column_c INT NULL ; Example 6: alter column sql server ALTER TABLE table_name ALTER COLUMN column_name datatype;

Jquery Timer Delay Code Example

Example 1: jquery delay $ ( "#foo" ) . slideUp ( 300 ) . delay ( 800 ) . fadeIn ( 400 ) ; Example 2: jquery delay to call function $ ( this ) .delay ( 1000 ) .queue ( function ( ) { // your Code | Function here $ ( this ) . dequeue ( ) ; } ) ;

Convert PHP Date Into Javascript Date Format

Answer : You should probably just use a timestamp $newticket['DateCreated'] = strtotime('now'); Then convert it to a Javascript date // make sure to convert from unix timestamp var now = new Date(dateFromPHP * 1000); Javascript Date class supports ISO 8601 date format so I would recommend: <?php date('c', $yourDateTime); // or for objects $dateTimeObject->format('c'); ?> documentation says that: format character 'c' is ISO 8601 date (added in PHP 5) example: 2004-02-12T15:19:21+00:00 for more information: http://php.net/manual/en/function.date.php It is pretty simple. PHP code: $formatted_date = $newticket['DateCreated'] = date('Y/m/d H:i:s'); Javascript code: var javascript_date = new Date("<?php echo $formatted_date; ?>");

Convert An Array To String Php Code Example

Example 1: php Array to string conversion Using implode() function in Php ----------------------- Syntax implode(separator,array); Example <?php //assigning value to the array $dummyArr = array ( "Hello" , "Greppers," , "Ankur" , "here !" ) ; echo implode ( " " , $dummyArr ) ; // Use of implode function ?> Output: Hello Greppers, Ankur here ! Example 2: array to string conversion in php $person = [ 'name' => 'Jon' , 'age' => 26 , 'status' => null , 'friends' => [ 'Matt' , 'Kaci' , 'Jess' ] ] ; echo json_encode ( $person ) ; // {"name":"Jon","age":26,"status":null,"friends":["Matt","Kaci","Jess"]} Example 3: php array to string // for one-dimentional arrays $str = implode ( '|' , $arr ) ; // "v1|v2|v3"... //

Css Text Size Responsive Code Example

Example 1: responsive font-size /* please refer to https://developer.mozilla.org/fr/docs/Web/CSS/clamp() */ font-size : clamp ( 40 px , 10 vw , 70 px ) ; /* clamp(MIN, VAL, MAX) */ Example 2: how to make fonts respnsive h1 { font-size : clamp ( 16 px , 5 vw , 34 px ) ; } Example 3: responsive text css /* Uses vh and vm with calc */ @media screen and ( min-width : 25 em ) { html { font-size : calc ( 16 px + ( 24 - 16 ) * ( 100 vw - 400 px ) / ( 800 - 400 ) ) ; } } /* Safari <8 and IE <11 */ @media screen and ( min-width : 25 em ) { html { font-size : calc ( 16 px + ( 24 - 16 ) * ( 100 vw - 400 px ) / ( 800 - 400 ) ) ; } } @media screen and ( min-width : 50 em ) { html { font-size : calc ( 16 px + ( 24 - 16 ) * ( 100 vw - 400 px ) / ( 800 - 400 ) ) ; } } Example 4: responsive text body { font-size : calc ( [minimum size] + ( [maximum size] - [minimum size] ) * ( ( 100 vw - [minimum viewport wi

Bs4 Python Example

Example 1: use beautifulsoup #start from bs4 import BeautifulSoup import requests req = requests.get ( 'https://www.slickcharts.com/sp500' ) soup = BeautifulSoup ( req.text, 'html.parser' ) Example 2: beautiful soup 4 from bs4 import BeautifulSoup with open ( "index.html" ) as fp: soup = BeautifulSoup ( fp ) soup = BeautifulSoup ( "<html>a web page</html>" )

Can Shadow Pokémon Be Shiny In Pokémon Go?

Image
Answer : At the time of writing, shiny shadow Pokémon do not exist within Pokémon Go. This is confirmed by multiple threads and discussions on reddit. When shadow Pokémon first came out, there was a post going around about a shiny shadow Bulbasaur. However, the post ended up being a fake. With the introduction of Team GO Rocket Leaders, Shadow Pokemon have a chance to be Shiny. According to Niantic Support's article on Team GO Rocket Leaders: Defeating a Leader also allows you to encounter one of their rare Shadow Pokémon, which also has a chance to be a Shiny Pokémon. Shiny Shadow Pokemon are mentioned specifically from Leaders, not Grunts, which makes sense for the rarity of Shiny Pokemon This post is old, but I caught this from classic team rocket.

Pi In C++ Cmath Code Example

Example 1: pi in c++ # define _USE_MATH_DEFINES // must include this! # include <cmath> # include <iostream> int main ( ) { // M_PI = 3.14159265358979323846; std :: cout << M_PI << " " << M_E << " " << M_SQRT2 << endl ; return 0 ; } Example 2: c++ pi float const float pi = 2 * acos ( 0.0f ) ;

Latex Underline Code Example

Example 1: latex italic text \textit { text } Example 2: latex bold text \textbf { text } Example 3: underline in latex \underline { science } Example 4: latex italic \emph { accident } Example 5: underscore latex \documentclass { article } \begin { document } \texttt { Samp\_Dist\_Corr } \verb | Samp_Dist_Corr | \texttt { Samp\ char `_Dist\ char `_Corr } \end { document }

Convert Hex Color Value ( #ffffff ) To Integer Value

Answer : The real answer is to use: Color.parseColor(myPassedColor) in Android, myPassedColor being the hex value like #000 or #000000 or #00000000 . However, this function does not support shorthand hex values such as #000 . Answer is really simple guys, in android if you want to convert hex color in to int, just use android Color class, example shown as below this is for light gray color Color.parseColor("#a8a8a8"); Thats it and you will get your result. Integer.parseInt(myString.replaceFirst("#", ""), 16)

Alt-Gr Key Is Not Working In Ubuntu 13.10

Image
Answer : This answer has screenshots for Gnome-Shell (Ubuntu Gnome 13.10). I suppose it will be similar for standard Unity, but if not, please chime in. First of all (and this is the most common problem), to have AltGr working you need a keyboard layout which uses it . For example, this is my keyboard layout (Settings -> Region and Language): English (US, international with dead keys) has AltGr. English (US) has NO AltGr. English (international AltGr dead keys) has AltGr. (My preferred layout is the third one, really). If the layout does not map AltGr+Key to anything, like for example the default "English (US)", AltGr will not work even if it's activated in the Keyboard -> Shortcuts panel. This is normally sufficient. To change the position of the AltGr you go to Settings -> Keyboard and set the "Alternative Characters Key": For example, my keyboard has no physical AltGr key, so I mapped it to the Right Alt key. Now with the t

Aligning 3 Columns In LaTeX Eqnarray

Image
Answer : You should avoid eqnarray . See \eqnarray vs \align. I'd recommend using align or alignat from amsmath package: Both align and alignat provide pairs of rl alignment columns. So, I used a && before the \Leftrightarrow assuming that the next column was to be r ight aligned. Code: \documentclass{article} \usepackage{amsmath} \begin{document}\noindent Using \verb|align|: \begin{align} \int ( D \frac{d^2 P(x)}{dx^2}-\frac{d}{dx}[u(x)P(x)] ) &= \int 0 &&\Leftrightarrow \\ D \frac{d}{dx} P(x) - u(x)P(x) &= C &&\Leftrightarrow \\ D \frac{d}{dx} P(x) - K_0P(x) - \frac{K_1}{x}P(x) &= C &&\Leftrightarrow \\ \frac{dP(x)}{dx} - k_0P(x) - \frac{k_1}{x} P(x) &= C, \end{align} Using \verb|alignat|: \begin{alignat}{4} \int ( D \frac{d^2 P(x)}{dx^2}-\frac{d}{dx}[u(x)P(x)] ) &= \int 0 &&\Leftrightarrow \\ D \frac{d}{dx} P(x) - u(x)P(x)

Composer Create-project Symfony/website-skeleton Version Code Example

Example 1: symfony install website skeleton # run this if you are building a traditional web application composer create-project symfony/website-skeleton my_project_name Example 2: symfony new project # use the most recent LTS version $ symfony new my_project_name --version=lts # use the 'next' Symfony version to be released (still in development) $ symfony new my_project_name --version=next # you can also select an exact specific Symfony version $ symfony new my_project_name --version=4.4 # The --full option installs all the packages that you usually need to build web applications.

Add Create Prefab At Position Unity Code Example

Example 1: Unity C# instantiate prefab Instantiate ( myPrefab , new Vector3 ( 0 , 0 , 0 ) , Quaternion . identity ) ; Example 2: unity instantiate prefab Instantiate ( cube , Vector3 ( x , y , 0 ) , Quaternion . identity ) ;

Angular Ngfor Sort By Key Code Example

Example: angular 6 key value pair getvalue example @Component({ selector: 'app-myview', template: ` < div *ngFor = " let key of objectKeys(items) " > {{key + ' : ' + items[key]}} </ div > ` }) export class MyComponent { objectKeys = Object.keys; items = { keyOne: 'value 1', keyTwo: 'value 2', keyThree: 'value 3' }; constructor(){} }