Posts

Showing posts from August, 2008

Get Text Component Of Input Field Unity Code Example

Example: how to use input field unity public string theName ; public GameObject inputField ; public GameObject textDisplay ; public void StoreName ( ) { theName = inputField . GetComponent < Text > ( ) . text ; textDisplay . GetComponent < Text > ( ) . text = theName ; }

Css Hide Number Input Arrows Code Example

Example 1: remove arrows from input type number /* Chrome, Safari, Edge, Opera */ input ::-webkit-outer-spin-button , input ::-webkit-inner-spin-button { -webkit-appearance : none ; margin : 0 ; } /* Firefox */ input [ type = number ] { -moz-appearance : textfield ; } Example 2: get rid of arrows number input input [ type = number ] ::-webkit-inner-spin-button , input [ type = number ] ::-webkit-outer-spin-button { -webkit-appearance : none ; margin : 0 ; } Example 3: html css number input field don't show arrows input ::-webkit-outer-spin-button , input ::-webkit-inner-spin-button { -webkit-appearance : none ; margin : 0 ; } input [ type = number ] { -moz-appearance : textfield ; }

Ajax Jquery Post Done Code Example

Example 1: jquery ajax post $ . ajax ( { type : "POST" , url : url , data : data , success : success , dataType : dataType } ) ; Example 2: jquery post $ . post ( "test.php" , { name : "John" , time : "2pm" } ) ;

Can You Get DB Username, Pw, Database Name In Rails?

Answer : From within rails you can create a configuration object and obtain the necessary information from it: config = Rails.configuration.database_configuration host = config[Rails.env]["host"] database = config[Rails.env]["database"] username = config[Rails.env]["username"] password = config[Rails.env]["password"] See the documentation for Rails::Configuration for details. This just uses YAML::load to load the configuration from the database configuration file ( database.yml ) which you can use yourself to get the information from outside the rails environment: require 'YAML' info = YAML::load(IO.read("database.yml")) print info["production"]["host"] print info["production"]["database"] ... Bryan's answer in the comment above deserves a little more exposure: >> Rails.configuration.database_configuration[Rails.env] => {"encoding"=>"unico

Cross Product Using Math.Net Numerics With C#

Answer : Sample method to do the cross-product of a 3 element vector. using DLA = MathNet.Numerics.LinearAlgebra.Double; public static DLA.Vector Cross(DLA.Vector left, DLA.Vector right) { if ((left.Count != 3 || right.Count != 3)) { string message = "Vectors must have a length of 3."; throw new Exception(message); } DLA.Vector result = new DLA.DenseVector(3); result[0] = left[1] * right[2] - left[2] * right[1]; result[1] = -left[0] * right[2] + left[2] * right[0]; result[2] = left[0] * right[1] - left[1] * right[0]; return result; } You are accessing the API documentation for Math.NET Iridium , which is a discontinued project. The intention was that the Iridium code base should be integrated into Math.NET Numerics , but it seems that the CrossProduct functionality has not been transferred yet, as can be seen in these two discussion threads on the Math.NET Numerics Co

Stod C++ Example

Example: how to convert a string to a double c++ double new = std :: stod ( string ) ;

Composer Memory Limit Code Example

Example 1: composer allowed memory size COMPOSER_MEMORY_LIMIT=-1 composer require owen-it/laravel-auditing Example 2: composer memory limit php -d memory_limit=512M /usr/local/bin/composer update Example 3: composer update withou memory limit php -d memory_limit=-1 path_to_composer.phar_that_threw_the_error update Example 4: composer allowed memory size export COMPOSER_MEMORY_LIMIT=-1

C# String.isnullorempty Vs String.isnullorwhitespace Code Example

Example: string isnullorempty vs isnullorwhitespace /* IsNullOrWhiteSpace is a convenience method that is similar to the following code, except that it offers superior performance: */ return String . IsNullOrEmpty ( value ) || value . Trim ( ) . Length == 0 ; /* White-space characters are defined by the Unicode standard. The IsNullOrWhiteSpace method interprets any character that returns a value of true when it is passed to the Char.IsWhiteSpace method as a white-space character. */

How To Print Float In C Code Example

Example 1: format specifier fro float in printf printf ( "%0k.yf" float_variable_name ) Here k is the total number of characters you want to get printed . k = x + 1 + y ( + 1 for the dot ) and float_variable_name is the float variable that you want to get printed . Suppose you want to print x digits before the decimal point and y digits after it . Now , if the number of digits before float_variable_name is less than x , then it will automatically prepend that many zeroes before it . Example 2: printf c float printf ( "%.6f" , myFloat ) ; Example 3: c printf float value I want to print a float value which has 2 integer digits and 6 decimal digits after the comma . If I just use printf ( "%f" , myFloat ) I'm getting a truncated value . I don 't know if this always happens in C, or it' s just because I'm using C for microcontrollers ( CCS to be exact ) , but at the reference it tells that % f get just th

Cannot Connect MySQL Workbench To MySQL Server

Answer : You have installed MySQLWorkbench as a Snap package. You want to store the database password(s) in the Gnome Passwords & Keys facility. However, a Snap package is sandboxed ; it is not by default allowed to access this service. When you choose "Store in keychain" MySQLWorkbench is blocked by AppArmor. You need to enter a command to allow this package to access the service. The command is: sudo snap connect mysql-workbench-community:password-manager-service :password-manager-service I got this from the discussion at this site. Go to app store . Search for mysql-workbench . Click on permission . Enable Read, add, change, or remove saved password̀s

Alterning Cumn In Sql Code Example

Example 1: sql add column ALTER TABLE Customers ADD Email varchar ( 255 ) ; Example 2: alter table add column ALTER TABLE table_name ADD column_name datatype ;

How To Convert Char To Int In C Code Example

Example 1: char to int c++ int x = ( int ) character - 48 ; Example 2: turn a char into an int in c int x = character - '0' ; Example 3: c convert char to int int i = ( int ) ( c - '0' ) ; Example 4: converting char to integer c++ int x = '9' - 48 ; // x now equals 9 as an integer Example 5: char to int in c strcpy ( str , "98993489" ) ; val = atoi ( str ) ; printf ( "String value = %s, Int value = %d\n" , str , val ) ;

Cp: Silence "omitting Directory" Warning

Answer : The solution that works for me is the following: find -maxdepth 1 -type f -exec cp {} backup_1364935268/ \; It copies all (including these starting with a dot) files from the current directory, does not touch directories and does not complain about it. Probably you want to use cp -r in that script. That would copy the source recursively including directories. Directories will get copied and the messages will disappear. If you don't want to copy directories you can do the following: redirect stderr to stdout using 2>&1 pipe the output to grep -v script 2>&1 | grep -v 'omitting directory' quote from grep man page: -v, --invert-match Invert the sense of matching, to select non-matching lines.

Highlight Text In Html Code Example

Example 1: html highlight text For HTML5: ( with 'mark' tag ) <p > Do not forget to buy <mark > milk</mark > today.</p > In CSS file: ( To customize highlight ) mark { background-color : yellow ; color : black ; } Example 2: how to highlight text in html <mark>text</mark> Example 3: mark tag in html mark { display : inline-block ; line-height : 0 em ; padding-bottom : 0.5 em ; } Example 4: how to highlight text in css <body> <p>The Math test is on <mark>Friday</mark>.</p> </body>

Filter Css Colorize Code Example

Example: fliter css /* URL to SVG filter */ filter : url ( "filters.svg#filter-id" ) ; /* <filter-function> values */ filter : blur ( 5 px ) ; filter : brightness ( 0.4 ) ; filter : contrast ( 200 % ) ; filter : drop-shadow ( 16 px 16 px 20 px blue ) ; filter : grayscale ( 50 % ) ; filter : hue-rotate ( 90 deg ) ; filter : invert ( 75 % ) ; filter : opacity ( 25 % ) ; filter : saturate ( 30 % ) ; filter : sepia ( 60 % ) ; /* Multiple filters */ filter : contrast ( 175 % ) brightness ( 3 % ) ; /* Use no filter */ filter : none ; /* Global values */ filter : inherit ; filter : initial ; filter : unset ;

1/2inch = Cm Code Example

Example: inch to cm 1 inch = 2.54 cm

Css Verdana Font Code Example

Example: css font families p { font-family : "Times New Roman" , Times , serif ; }

Can't Install Wine From Winehq.org On Ubuntu (actually Lubuntu) 18.04 LTS

Answer : Analysis The WineHQ repository misses the dependencies for wine-stable package. I have reported a bug 48513 to WineHQ bugzilla. The main problem here is bad documentation, which is written in non-reproducible way. The Rosanne DiMesio's main idea is "People who don't bother to read the directions are always going to have problems.". So we need to write our own documentation until WineHQ-officials become smarter. The problem with dependencies was caused by the FAudio dependency, which is not contained in Debian/Ubuntu and WineHQ repositories. We can determine the exact package name by using command below and analyzing of their output: $ sudo apt-get install wine-stable-amd64 Reading package lists... Done Building dependency tree Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not y

Android Scale Button On Touch

Answer : Try the following: @Override public boolean onTouch(View v, MotionEvent motionEvent) { int action = motionEvent.getAction(); if (action == MotionEvent.ACTION_DOWN) { v.animate().scaleXBy(100f).setDuration(5000).start(); v.animate().scaleYBy(100f).setDuration(5000).start(); return true; } else if (action == MotionEvent.ACTION_UP) { v.animate().cancel(); v.animate().scaleX(1f).setDuration(1000).start(); v.animate().scaleY(1f).setDuration(1000).start(); return true; } return false; } This should do the trick ;)

Change Variable Of Another Script Unity Code Example

Example 1: unity variable from another script //Make Health public public class PlayerScript : MonoBehaviour { public float Health = 100.0f ; } //Access it. public class Accessor : MonoBehaviour { void Start ( ) { GameObject thePlayer = GameObject . Find ( "ThePlayer" ) ; PlayerScript playerScript = thePlayer . GetComponent < PlayerScript > ( ) ; playerScript . Health -= 10.0f ; } } Example 2: unity how to use variable from another script using System . Collections ; using System . Collections . Generic ; using UnityEngine ; public class Miner : MonoBehaviour // A class made to mine coins { private Variables variables ; // "Variables" is the class name with my variables in it, "variables" is the name of it's variable in this class void Start ( ) { variables = GameObject . Find ( "ScriptHolder" ) . GetComponent < Variables > ( ) ; // "ScriptHolder

Can I Run Two Ongoing Npm Commands In 1 Terminal

Answer : You could run one process in the background with & (one ampersand, not two) but that would require you to manage it manually, which would be rather tedious. For details see What does ampersand mean at the end of a shell script line?. For that use-case someone built concurrently , which makes it simple to run processes in parallel and keep track of their output. npm install --save-dev concurrently And your start script becomes: "start": "concurrently 'npm run webpack' 'npm run server'" If you want to make the output a little prettier you can give the processes names with -n and colours with -c , for example: "start": "concurrently -n 'webpack,server' -c 'bgBlue.bold,bgGreen.bold' 'npm run webpack' 'npm run server'"

How To Get A String Input In C Code Example

Example 1: getting string input in c # include <stdio.h> # include <conio.h> void main ( ) { chat sam [ 10 ] ; clrscr ( ) ; printf ( "ENTER STRING NAME :" ) ; gets ( s ) ; printf ( "STRING :%s" , s ) ; getch ( ) ; } Example 2: Syntax To Take Input In C Integer : Input : scanf ( "%d" , & intVariable ) ; Output : printf ( "%d" , intVariable ) ; Float : Input : scanf ( "%f" , & floatVariable ) ; Output : printf ( "%f" , floatVariable ) ; Character : Input : scanf ( "%c" , & charVariable ) ; Output : printf ( "%c" , charVariable ) ; Example 3: input output string in c # include <stdio.h> # include <string.h> # include <math.h> # include <stdlib.h> int main ( ) { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ char ch ; char s [ 100 ] ; char p [ 100 ] ; scanf (

Calculate Pandas DataFrame Time Difference Between Two Columns In Hours And Minutes

Answer : Pandas timestamp differences returns a datetime.timedelta object. This can easily be converted into hours by using the *as_type* method, like so import pandas df = pandas.DataFrame(columns=['to','fr','ans']) df.to = [pandas.Timestamp('2014-01-24 13:03:12.050000'), pandas.Timestamp('2014-01-27 11:57:18.240000'), pandas.Timestamp('2014-01-23 10:07:47.660000')] df.fr = [pandas.Timestamp('2014-01-26 23:41:21.870000'), pandas.Timestamp('2014-01-27 15:38:22.540000'), pandas.Timestamp('2014-01-23 18:50:41.420000')] (df.fr-df.to).astype('timedelta64[h]') to yield, 0 58 1 3 2 8 dtype: float64 This was driving me bonkers as the .astype() solution above didn't work for me. But I found another way. Haven't timed it or anything, but might work for others out there: t1 = pd.to_datetime('1/1/2015 01:00') t2 = pd.to_datetime('1/1/2015 03:30') print pd.Timedelta(t2