Posts

Showing posts from March, 2005

Can I Recover Unstaged Changes After Reset Hard In Git ? Code Example

Example 1: what to do with unstaged changes after reset git reset --hard Example 2: what to do with unstaged changes after reset git rm --cached -r .

Floating Animation Code Example

Example: floating object animation css .floating { animation-name : floating ; animation-duration : 3 s ; animation-iteration-count : infinite ; animation-timing-function : ease-in-out ; margin-left : 30 px ; margin-top : 5 px ; background : #7F00FF ; /* fallback for old browsers */ background : -webkit-linear-gradient ( to right , #E100FF , #7F00FF ) ; background : linear-gradient ( to right , #E100FF , #7F00FF ) ; color : white ; } @keyframes floating { 0% { transform : translate ( 0 , 0 px ) ; } 50% { transform : translate ( 0 , 15 px ) ; } 100% { transform : translate ( 0 , -0 px ) ; } }

Android Studio - Get Firebase Token From GetIdToken

Answer : Your second approach is close, you just need to use <GetTokenResult> instead of <UploadTask.TaskSnapshot> as that is for uploading images using Firebase Storage. Try this: user.getIdToken(true).addOnSuccessListener(new OnSuccessListener<GetTokenResult>() { @Override public void onSuccess(GetTokenResult result) { String idToken = result.getToken(); //Do whatever Log.d(TAG, "GetTokenResult result = " + idToken); } });

Abstract Constants In PHP - Force A Child Class To Define A Constant

Answer : This may be a bit of a ‘hack’, but does the job with very little effort, but just with a different error message if the constant is not declared in the child class. A self-referential constant declaration is syntactically correct and parses without problem, only throwing an error if that declaration is actually executed at runtime, so a self-referential declaration in the abstract class must be overridden in a child class else there will be fatal error: Cannot declare self-referencing constant . In this example, the abstract, parent class Foo forces all its children to declare the variable NAME . This code runs fine, outputting Donald . However, if the child class Fooling did not declare the variable, the fatal error would be triggered. <?php abstract class Foo { // Self-referential 'abstract' declaration const NAME = self::NAME; } class Fooling extends Foo { // Overrides definition from parent class // Without this declaration, an

Layered Box Shadow Css Generator Code Example

Example: multilayer shadow in css /* Default box-shadow */ .box { box-shadow : 0 3 px 3 px rgba ( 0 , 0 , 0 , 0.2 ) ; } /* Create smoother box-shadows by layering multiple * shadows with gradually increasing radius and offset */ .shadow-5 { box-shadow : 0 1 px 1 px rgba ( 0 , 0 , 0 , 0.12 ) , 0 2 px 2 px rgba ( 0 , 0 , 0 , 0.12 ) , 0 4 px 4 px rgba ( 0 , 0 , 0 , 0.12 ) , 0 8 px 8 px rgba ( 0 , 0 , 0 , 0.12 ) , 0 16 px 16 px rgba ( 0 , 0 , 0 , 0.12 ) ; }

Can You Unlock Steam Achievements In Stardew Valley Multiplayer?

Answer : I can personally say that i've got steam achievements whilst in a multiplayer session I wasn't hosting. I don't believe they are tracked between all players though. I got the achievement for catching a certain number of types of fish.

Can I Create A New Session In Another Tab Or Window In Google Chrome?

Answer : Currently, this is not possible. You can use multiple profiles in Google Chrome, though. Read the instructions here. Enable multiple accounts: https://www.google.com/accounts/MultipleSessions Then, create a bookmark(let) or a keyboard shortcut for each mailbox: https://mail.google.com/mail/u/0/#inbox https://mail.google.com/mail/u/1/#inbox Source: http://lifehacker.com/5733636/switch-between-multiple-gmail-accounts-with-a-url-hack MultiLogin is down from the google webstore, but there is an alternative (SessionBox) https://chrome.google.com/webstore/detail/sessionbox-beta/megbklhjamjbcafknkgmokldgolkdfig

Convert Gpt To Mbr Windows 10 Code Example

Example: convert mbr to gpt cmd Step 1. Open an elevated Command Prompt: press Win+R on your keyboard to open Run dialogue, in which type cmd and hit on Enter. Step 2. In the elevated Command Prompt window, type diskpart and press Enter to launch DiskPart Windows. And execute following commands in sequence. list disk (display all the online disks) select disk n (n represents the number of the target MBR disk) clean (remove all partitions on the target disk if there are) convert gpt

Contains Js Array 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: javascript array contains var fruits = [ "Banana" , "Orange" , "Apple" , "Mango" ] ; var n = fruits . includes ( "Mango" ) ; Example 3: js array includes [ 1 , 2 , 3 ] . includes ( 2 ) ; // true [ 1 , 2 , 3 ] . includes ( 4 ) ; // false [ 1 , 2 , 3 ] . includes ( 3 , 3 ) ; // false [ 1 , 2 , 3 ] . includes ( 3 , - 1 ) ; // true [ 1 , 2 , NaN ] . includes ( NaN ) ; // true Example 4: js array contains let fruits = [ "Banana" , "Orange" , "Apple" , "Mango" ] ; let do_contain = fruits . includes ( "Mango" ) ; // contain: true Example 5: see if array contains array javascript const found = ar

Bootstrap Table W3school Code Example

Example: bootstrap 3 table Bootstrap Basic Table A basic Bootstrap table has a light padding and only horizontal dividers. The .table class adds basic styling to a table ------------------------------------------------------------ Striped Rows The .table-striped class adds zebra-stripes to a table Bordered Table The .table-bordered class adds borders on all sides of the table and cells ------------------------------------------------------------ Hover Rows The .table-hover class adds a hover effect ( grey background color ) on table rows ------------------------------------------------------------ Condensed Table The .table-condensed class makes a table more compact by cutting cell padding in half ------------------------------------------------------------ Contextual Classes Contextual classes can be used to color table rows ( <tr> ) or table cells ( <td> ) The contextual classes that can be used are : Class Description .active Applies the hover color to

Android: Glide Not Showing Large Image From URL

Answer : I have found a solution that worked for my requirement. The override() method does the trick. Setting higher numbers for the target resolution seems to be the final workaround, but the bigger the numbers, the longer the time it would take to display the image(s), so it would be wise to implement a preloader/progressbar. Glide.with(getContext()) .asBitMap() //[for new glide versions] .load(url) //.asBitmap()[for older glide versions] //.placeholder(R.drawable.default_placeholder) .override(1600, 1600) // Can be 2000, 2000 .into(new BitmapImageViewTarget(imageViewPreview) { @Override public void onResourceReady(Bitmap drawable, GlideAnimation anim) { super.onResourceReady(drawable, anim); progressBar.setVisibility(View.GONE); } }); Custom centered preloader/progressbar placeholder indicator on relativeLayout xml: <ProgressBar android:id="@+id/progressBar" android:layout_wid

Converting Xml To Dictionary Using ElementTree

Answer : The following XML-to-Python-dict snippet parses entities as well as attributes following this XML-to-JSON "specification": from collections import defaultdict def etree_to_dict(t): d = {t.tag: {} if t.attrib else None} children = list(t) if children: dd = defaultdict(list) for dc in map(etree_to_dict, children): for k, v in dc.items(): dd[k].append(v) d = {t.tag: {k: v[0] if len(v) == 1 else v for k, v in dd.items()}} if t.attrib: d[t.tag].update(('@' + k, v) for k, v in t.attrib.items()) if t.text: text = t.text.strip() if children or t.attrib: if text: d[t.tag]['#text'] = text else: d[t.tag] = text return d It is used: from xml.etree import cElementTree as ET e = ET.XML(''' <root> <e /> <e>text</e> <e name="va

Git Clone Unclone Code Example

Example: clone and remove existing git repository git rm -rf git

Css Display Table-row Code Example

Example: css block layout /******************* BASIC BLOCK DISPLAY **********************/ /**************** Block display Elements *********************/ /*Elements that block any other elements from being in the same line. You can change the width from being the maximum width of the page, but you can´t put elements side by side */ tag_name { display : block ; } /*Exemple of default block display elements:*/ < h1 > ... < / h1 > < p > ... < / p > /**************** Inline display Elements *********************/ /*They are the type of blocks that only take up the minimum space required (both in width and height). You can place these types of blocks side by side (on the same line) but you cannot change their dimensions */ tag_name { display : inline ; } /*Exemple of default inline display elements:*/ < spans > ... < / spans > < img > ... < / img > < a > ... < / a > /************* Inline-block display Elem

Css Spinner Code Example

Example 1: css loading spinner . loader { border : 16px solid #f3f3f3; /* Light grey */ border - top : 16px solid #3498db; /* Blue */ border - radius : 50 % ; width : 120px ; height : 120px ; animation : spin 2s linear infinite ; } @keyframes spin { 0 % { transform : rotate ( 0deg ) ; } 100 % { transform : rotate ( 360deg ) ; } } < div class = "loader" > < / div > Example 2: css loading spinner with text . centered { text - align : center ; } . spinner . loading { display : none ; padding : 50px ; text - align : center ; } . loading - text { width : 90px ; position : absolute ; top : calc ( 50 % - 15px ) ; left : calc ( 50 % - 45px ) ; text - align : center ; } . spinner . loading : before { content : "" ; height : 90px ; width : 90px ; margin : - 15px auto auto - 15px ; position : absolute ; top : calc ( 50 % - 45px ) ; left : calc ( 50 % - 45px ) ; border - widt

Substr C Example

Example 1: c substring //where we want the word "test" and we know its position in the string char * buff = "this is a test string" ; printf ( "%.*s" , 4 , buff + 10 ) ; Example 2: c substring char subbuff [ 5 ] ; memcpy ( subbuff , & buff [ 10 ] , 4 ) ; subbuff [ 4 ] = '\0' ;

Godot Programming Languages Code Example

Example 1: what language is godot written in Surprisingly not using magic Example 2: what language is godot written in Well , godot is made of C ++ as you can see down . . .

Facebook Masthead Code Example

Example 1: facebook Why you browsing Facebook ! ! ! ! Back to work , Code Monkey . Example 2: facebook Procrastinating again aren't we ?

Connect Sdcard To Arduino Code Example

Example: arduino sd card module #include < SPI.h > #include < SD.h > File myFile;void setup() {// Open serial communications and wait for port to open:Serial.begin(9600);while (!Serial) {; // wait for serial port to connect. Needed for native USB port only}Serial.print("Initializing SD card...");if (!SD.begin(10)) {Serial.println("initialization failed!");while (1);}Serial.println("initialization done.");// open the file. note that only one file can be open at a time,// so you have to close this one before opening another.myFile = SD.open("test.txt", FILE_WRITE);// if the file opened okay, write to it:if (myFile) {Serial.print("Writing to test.txt...");myFile.println("This is a test file :)");myFile.println("testing 1, 2, 3.");for (int i = 0; i < 20; i++) {myFile.println(i);}// close the file:myFile.close();Serial.println("done.");} else {// if the file didn't open, print an error:Seri

Css Cut Text 3 Dots Code Example

Example 1: overflow dottet .cut-text { text-overflow : ellipsis ; overflow : hidden ; white-space : nowrap ; } Example 2: overflow dots css .overflow-information { overflow : hidden ; display : inline-block ; text-overflow : ellipsis ; white-space : nowrap ; width : 150 px ; //change based on when you want the dots to appear }