Posts

Showing posts from September, 2010

Ant Design Responsive NavBar

Image
Answer : I was looking at this question in a decision to pick Ant design for a project. Responsive navbar is common scenario, but I was wondering why there is no such thing in Ant Design? Then I searched for issues in the repo and found the Ant Design Mobile as a comment to an issue. They have a separate package for mobile devices. Inside Ant Design Mobile there is separate section for web components. In that section you can find a Menu component which is suitable for mobile devices hamburger icon. Hope this will be helpful for future readers. I was looking for such functionality not long ago as well and in order to make Ant Menu responsive, I have written a simple React Component. This Component accepts Ant Menu markup as a prop and conditionally renders the Menu based on the viewport width, either as is (for desktop), or in a Popover component which will wrap passed menu markup (for mobile). I'm including screenshots of how it may look once the viewport is narrow en

Absolute Value Matlab Code Example

Example: absolute value of a matix The absolute value sign in a matrix means the determinant (ad-bc)

20 Minutes Alarm Code Example

Example 1: 20 minute timer for good eyesight every 20 minutes look out the window at something 20 feet away for 20 seconds Example 2: 20 minute timer For the 20/20/20 rule you can also close your eyes for 20 seconds and get the same results because it relaxes the mucles in your eyes.

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

Async Arrow Function Example

Example 1: async arrow function const foo = async ( ) => { // do something } Example 2: javascript async await arrow function Async arrow functions look like this : const foo = async ( ) => { // do something } Async arrow functions look like this for a single argument passed to it : const foo = async evt => { // do something with evt } Async arrow functions look like this for multiple arguments passed to it : const foo = async ( evt , callback ) => { // do something with evt // return response with callback } The anonymous form works as well : const foo = async function ( ) { // do something } An async function declaration looks like this : async function foo ( ) { // do something } Using async function in a callback : const foo = event . onCall ( async ( ) => { // do something } ) Example 3: async await arrow function YourAsyncFunctionName = async ( value )

Arduino Uno Pinout Code Example

Example: arduino pinMode pinMode(Pin_number, State); ex: pinMode(2, HIGH);

Add Semantic Ui Cdn To React Code Example

Example: semantic-ui cdn < link rel = " stylesheet " href = " https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.css " >

Bootstrap Font Awesome Info Icon Code Example

Example 1: fa fa-info-circle < i class = " fa fa-info-circle " > </ i > Example 2: font awsome circle info icon fa-info-circle

Autohotkey How To Loop Code Example

Example: loop autohotkey Loop, 4 { ;this loops 4 times MsgBox, This is a messagebox ;shows a messagebox } ;closes the loop

Check First Radio Button With JQuery

Answer : If your buttons are grouped by their name attribute, try: $("input:radio[name=groupName][disabled=false]:first").attr('checked', true); If they are grouped by a parent container, then: $("#parentId input:radio[disabled=false]:first").attr('checked', true); $("input:radio[name=groupX]:not(:disabled):first") This should give you the first non-disabled radio-button from a group... The below does what you want: $(document).ready( function(){ $('input:radio:first-child').attr('checked',true); } ); Demo at: JS Bin.

CircleCI - Different Value To Environment Variable According To The Branch

Answer : The question is almost 2 years now but recently I was looking for similar solution and I found it. It refers to CircleCI's feature called Contexts (https://circleci.com/docs/2.0/contexts/). Thanks to Contexts you can create multiple sets of environment variables which are available within entire organisation. Then you can dynamically load one of the sets depending of workflows' filters property. Let me demonstrate it with following example: Imagine you have two branches and you want each of them to be deployed into different server. What you have to do is: create two contexts (e.g. prod-ctx and dev-ctx ) and define SERVER_URL environment variable in each of them. You need to log into CircleCI dashboard and go to "Settings" -> "Contexts". in your .circleci/config.yml define job's template and call it deploy : deploy: &deploy steps: - ... define workflows: workflows: version: 2 deploy: jobs: - dep

Access Auth In Blade Laravel Code Example

Example 1: laravel auth composer require laravel / ui php artisan ui vue -- auth npm install && npm run dev Example 2: get user auth in laravel Auth :: user ( ) ; Example 3: laravel auth composer require laravel / ui : ^ 2.4 php artisan ui vue -- auth

Addforce Unity 2d Code Example

Example: how to make rb.addforce 2d public Rigidbody rb ; //make reference in Unity Inspector public float SpeedX = 0.1f ; public float SpeedY = 0.5f ; rb . AddForce ( new Vector2 ( SpeedX , SpeedY ) ) ;

Circular Header Linked List Stores The Address Of The Header Node In The Next Field Of The Last Node Code Example

Example 1: circular linked list in c # include <stdio.h> # include <string.h> # include <stdlib.h> # include <stdbool.h> struct node { int data ; int key ; struct node * next ; } ; struct node * head = NULL ; struct node * current = NULL ; bool isEmpty ( ) { return head == NULL ; } int length ( ) { int length = 0 ; //if list is empty if ( head == NULL ) { return 0 ; } current = head -> next ; while ( current != head ) { length ++ ; current = current -> next ; } return length ; } //insert link at the first location void insertFirst ( int key , int data ) { //create a link struct node * link = ( struct node * ) malloc ( sizeof ( struct node ) ) ; link -> key = key ; link -> data = data ; if ( isEmpty ( ) ) { head = link ; head -> next = head ; } else {

Change Format Datetime In Php Code Example

Example: php change date format To convert the date-time format PHP provides strtotime() and date() function. We change the date format from one format to another. Change YYYY-MM-DD to DD-MM-YYYY <? php . $currDate = "2020-04-18" ; $changeDate = date ( "d-m-Y" , strtotime ( $currDate ) ) ; echo "Changed date format is: " . $changeDate . " (MM-DD-YYYY)" ; ?>