Posts

Showing posts from September, 2012

Docker Cp Recursive Code Example

Example: copy file to docker container docker cp foo . txt mycontainer : / foo . txt

Bra Ket Latex Code Example

Example: dirac notation latex $\langle \phi | x | \psi \rangle$

Hex Finder Code Example

Example 1: hex color picker For anyone wondering , hex color is just in base 16 . So 255 ( max color ) is FF. The 6 long string of characters is just the Red Green and Blue channels ( RRGGBB ) . Which means you shouldn 't have to look it up unless you' re going for an exact color. Hex numbers : 0 1 2 3 4 5 6 7 8 9 A B C D E F 10 11 12 13 14 15 16 17 18 19 1 A 1 B 1 C 1 D 1 E 1 F 20 21 .. etc. Example 2: hex color code finder rgb ( 244 , 116 , 33 )

How Many Types Of Bastions Are There In Minecraft Code Example

Example 1: types of bastions minecraft lol no i'm a speedrunner Example 2: types of bastion minecraft hey , are you into modding or something ?

Adding A Delay Without Thread.sleep And A While Loop Doing Nothing

Answer : Something like the following should give you the delay you need without holding up the game thread: private final long PERIOD = 1000L; // Adjust to suit timing private long lastTime = System.currentTimeMillis() - PERIOD; public void onTick() {//Called every "Tick" long thisTime = System.currentTimeMillis(); if ((thisTime - lastTime) >= PERIOD) { lastTime = thisTime; if(variable) { //If my variable is true boolean = true; //Setting my boolean to true /** *Doing a bunch of things. **/ //I need a delay for about one second here. boolean = false; //Setting my boolean to false; } } } long start = new Date().getTime(); while(new Date().getTime() - start < 1000L){} is the simplest solution I can think about. Still, the heap might get polluted with a lot of unreferenced Date objects, which, depending on how often you get to create such a pseudo-dela

Css Space Code Example

Example 1: letter spacing css div{ letter-spacing: 2px; } Example 2: how to create space inbetween text css < div style = " letter-spacing : 1 em ; " > It's a wide wide word! </ div > < div style = " line-height : 1.5 ; " > < div style = " text-indent : 50 px ; " >

Css Ellipsis Example

Example 1: text overflow ellipsis css div { white-space : nowrap ; overflow : hidden ; text-overflow : ellipsis ; } Example 2: text limit in css body { margin : 20 px ; } .text { overflow : hidden ; text-overflow : ellipsis ; display : -webkit-box ; -webkit-line-clamp : 2 ; /* number of lines to show */ -webkit-box-orient : vertical ; } Example 3: text-overflow: ellipsis; 2 line display : -webkit-box ; -webkit-line-clamp : 3 ; -webkit-box-orient : vertical ; overflow : hidden ; text-overflow : ellipsis ;

Composer Install --o Cache Clear Code Example

Example 1: clear composer cache composer clearcache //Then autoload composer composer dump-autoload Example 2: composer clear cache $ composer clearcache

Android Get Real Path By Uri.getPath()

Answer : This is what I do: Uri selectedImageURI = data.getData(); imageFile = new File(getRealPathFromURI(selectedImageURI)); and: private String getRealPathFromURI(Uri contentURI) { String result; Cursor cursor = getContentResolver().query(contentURI, null, null, null, null); if (cursor == null) { // Source is Dropbox or other similar local file path result = contentURI.getPath(); } else { cursor.moveToFirst(); int idx = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA); result = cursor.getString(idx); cursor.close(); } return result; } NOTE: managedQuery() method is deprecated, so I am not using it. Last edit: Improvement. We should close cursor!! Is it really necessary for you to get a physical path? For example, ImageView.setImageURI() and ContentResolver.openInputStream() allow you to access the contents of a file without knowing its real path. @Rene Juuse - above in comments... Thanks

Convert A PEM-formatted String To A Java.security.cert.X509Certificate

Answer : Decode the Base64 to binary, with some InputStream reading it, then try CertificateFactory cf = CertificateFactory.getInstance("X.509"); Certificate cert = cf.generateCertificate(is); I have a similar problem, I'm pasting also here the java code that worked for me in case anyone neaded it : import java.util.Base64; public static X509Certificate parseCertificate(String _headerName, HttpServletRequest _request) throws CertificateException { String certStr = _request.getHeader("x-clientcert"); //before decoding we need to get rod off the prefix and suffix byte [] decoded = Base64.getDecoder().decode(certStr.replaceAll(X509Factory.BEGIN_CERT, "").replaceAll(X509Factory.END_CERT, "")); return (X509Certificate) CertificateFactory.getInstance("X.509").generateCertificate(new ByteArrayInputStream(decoded)); } The steps in conversion of PEM formatted String is opposite of how (x509 -> String) took place. Sample

90 F In 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 ) ; } }

Angular Toastr Npm Code Example

Example 1: angular toastr npm install ngx-toastr --save npm install @angular/animations --save // angular.json "styles": [ "styles.scss", "node_modules/ngx-toastr/toastr.css" // try adding '../' if you're // using angular cli before 6 ] // app.module import { CommonModule } from '@angular/common'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { ToastrModule } from 'ngx-toastr'; imports: [ CommonModule, BrowserAnimationsModule, // required animations module ToastrModule.forRoot(), // ToastrModule added ], // component import { ToastrService } from 'ngx-toastr'; constructor(private toastr: ToastrService) {} showSuccess() { this.toastr.success('Hello world!', 'Toastr fun!'); } Example 2: how to add toaster in angular 9 npm install ngx-toastr --save

Navbar Fixed Top After Scrolling Code Example

Example 1: stick menu bar in css .navigation { /* fixed keyword is fine too */ position : sticky ; top : 0 ; z-index : 100 ; /* z-index works pretty much like a layer: the higher the z-index value, the greater it will allow the navigation tag to stay on top of other tags */ } Example 2: css sticky navigatiojn nav { position : sticky ; top : 0 ; } /*Top can be replaced with bottom, left, or right depending on what you want :) */

Elevated Button Background Color Flutter Code Example

Example 1: elevated button flutter color ElevatedButton ( style: ButtonStyle ( backgroundColor: MaterialStateProperty .resolveWith <Color > ( ( Set<MaterialState > states ) { if ( states. contains ( MaterialState.pressed ) ) return Colors. green ; return null ; // Use the component's default. } , ) , ) , ) Example 2: raised button background color doesn't changeflutter RaisedButton ( onPressed : null , child : Text ( 'Get in' ) , // change it to sign-in color : Colors. blue , disabledColor : Colors. blue , //add this to your code ) Example 3: elevated Button Theme background color in flutter style : ElevatedButton. styleFrom ( primary : Colors. purple , ) , Example 4: Flutter Elevated button color ElevatedButton ( child: Text ( 'Button' ) , onPressed: ( ) { } ,

Access Array Element Arduino Code Example

Example 1: array arduino int myArray[6]; int myArray[] = {2, 4, 8, 3, 6}; int myArray[6] = {2, 4, -8, 3, 2}; Example 2: variable array arduino var myArray[] = {d1,d2,d3,d4,d4}; var myArray[3]:

Onclick Jquery Function With Javascript Code Example

Example 1: jquery click function $ ( " #target " ) .click ( function ( ) { alert ( "Handler for .click() called." ) ; } ) ; Example 2: set onclick jquery $ ( elem ) . click ( myFunc ( ) ) ;

Error: Void Value Not Ignored As It Ought To Be| Code Example

Example: void value not ignored as it ought to be you ' re trying to capture the return value of a function for which the return type is void .

10 Min Timer Code Example

Example: 20 minute timer for good eyesight every 20 minutes look out the window at something 20 feet away for 20 seconds

How To Get Length Of Array In Java Code Example

Example 1: .length array java /** * An Example to get the Array Length is Java */ public class ArrayLengthJava { public static void main ( String [ ] args ) { String [ ] myArray = { "I" , "Love" , "Music" } ; int arrayLength = myArray . length ; //array length attribute System . out . println ( "The length of the array is: " + arrayLength ) ; } } Example 2: find length of array java Int [ ] array = { 1 , 2 , 3 } ; int lengthOfArray = array . length ; /** Finding the length of the array and storing it */ System . out . println ( String . valueOf ( lengthOfArray ) ) ; /** Should print out 3, String.value Of() is optional as printLn does this automatically. */ Example 3: how to find length of array in java let coolCars = [ 'ford' , 'chevy' ] ; //to find length, use the array's built in method let length = coolCars . length ; //length == 2. Example 4: length of array in java arr . leng

Calloc Vs Malloc Vs Realloc Code Example

Example: difference between malloc and calloc and realloc if ( ! ( int * ptr = malloc ( sizeof ( int ) * NUM_ELEM ) ) ) { // ERROR CONDITION HERE}

3w School Convert Number To String Code Example

Example 1: tostring js var num = 15; var n = num.toString(); /* now */ "15" Example 2: int to string javascript var number = 12; return numner.toString();