Posts

Showing posts from December, 2007

Creating A New Instance Of A KClass

Answer : You can use the Java class to create new instance: MyClass::class.java.newInstance() In your case, Java reflection might be enough: you can use MyClass::class.java and create a new instance in the same way as you would with Java reflection (see @IngoKegel's answer). But in case there's more than one constructor and you really need to get the primary one (not the default no-arg one), use the primaryConstructor extension function of a KClass<T> . It is a part of Kotlin reflection, which is not shipped within kotlin-stdlib . To use it, you have to add kotlin-reflect as a dependency, e.g. a in Gradle project: dependencies { compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" } Assuming that there is ext.kotlin_version , otherwise replace $kotlin_version with the version you use. Then you will be able to use primaryConstructor , for example: fun <T : Any> construct(kClass: KClass<T>): T? { val ctor = kClass.primaryCo

Copy Data From S3 To Local With Prefix

Answer : aws s3 cp s3://my-bucket/ <local directory path> --recursive --exclude "*" --include "<prefix>*" This will copy only files with given prefix The aws s3 cp command will not accept a wildcard as part of the filename (key). Instead, you must use the --include and --exclude parameters to define filenames. From: Use of Exclude and Include Filters Currently, there is no support for the use of UNIX style wildcards in a command's path arguments. However, most commands have --exclude "<value>" and --include "<value>" parameters that can achieve the desired result. These parameters perform pattern matching to either exclude or include a particular file or object. The following pattern symbols are supported. So, you would use something like: aws s3 cp s3://my-bucket-name/ . --include "RAW_TIMESTAMP_0506*" The above answers to not work properly... for example I have many thousands of files in a directo

Crashlytics Does Not Show Crashes

Image
Answer : Checked the following terms, Make sure Crashlytics SDK line is after all other 3rd-party SDK lines. (it needs to be last one called in your appDidFinishLaunching method.) Force a crash and then relaunch the app. Xcode must be disconnected to stop it from intercepting the crash report. To disconnect Xcode, follow the instructions here. If you're using [Crashlytics sharedInstance] crash]; to test crashing, make sure it's not in the appDidFinishLaunching method. These are already mentioned in support section, Here is additional ones - Check in organization -> Your App -> Missing dSYM, Is it showing any missing dSYM file if yes, Then do the following step Right Click on your archive -> Show in Finder -> Right click on file and click on Show package contents Right click on dSYM file - > Show package contents -> Contents -> Resources -> DWARF (Open in terminal) Run command dwarfdump --uuid "file name you saw there in dwarf folder" This w

Css Initial Example

The initial CSS keyword applies the initial (or default) value of a property to an element. It can be applied to any CSS property. This includes the CSS shorthand all , with which initial can be used to restore all CSS properties to their initial state. On inherited properties, the initial value may be unexpected. You should consider using the inherit , unset , or revert keywords instead. Examples Using initial to reset color for an element HTML < p > < span > This text is red. </ span > < em > This text is in the initial color (typically black). </ em > < span > This is red again. </ span > </ p > CSS p { color : red ; } em { color : initial ; } Result Specifications Specification Status Comment CSS Cascading and Inheritance Level 4 The definition of 'initial' in that specification. Candidate Recommendation No changes from Level 3. CSS Cascading and Inheritance Level 3 The definition of &

Angular Unit Test Input Value

Answer : Inputs don't have textContent, only a value. So expect(field.textContent).toBe('someValue'); is useless. That's probably what's failing. The second expectation should pass though. Here's a complete test. @Component({ template: `<input type="text" [(ngModel)]="user.username"/>` }) class TestComponent { user = { username: 'peeskillet' }; } describe('component: TestComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ imports: [FormsModule], declarations: [ TestComponent ] }); }); it('should be ok', async(() => { let fixture = TestBed.createComponent(TestComponent); fixture.detectChanges(); fixture.whenStable().then(() => { let input = fixture.debugElement.query(By.css('input')); let el = input.nativeElement; expect(el.value).toBe('peeskillet'); el.value = 'someValue'; el.d

Git Fetch And Checkout Remote Branch Code Example

Example 1: git checkout to remote branch $ git checkout -- track origin / newsletter Branch newsletter set up to track remote branch newsletter from origin . Switched to a new branch 'newsletter' Example 2: git checkout remote branch git checkout -- track origin / < branchname > Example 3: pull down remote branch git git fetch origin git checkout -- track origin / < branch_name > Example 4: git checkout remote branch # In modern versions of Git , you can checkout the remote branch like a local branch . git checkout < remotebranch > # Older versions of Git require the creation of a new branch based on the remote . git checkout < remotebranch > origin / < remotebranch > Example 5: git get remote branch git fetch git checkout test

First Element Css Selector Code Example

Example 1: css first element p :first-child { font-size : 1.5 em ; } Example 2: select first div css #content div :first-child { /*css*/ } Example 3: css first child /*CSS First - forth child*/ :first-child { } :nth-child ( 2 ) { } :nth-child ( 3 ) { } :nth-child ( 4 ) { } Example 4: select first div css #content_id div .class_name :first-child { /*your style*/ }

Never Gonna Let You Down Rick Astley Lyrics Code Example

Example 1: never gonna give you up lyrics /* We're no strangers to love You know the rules and so do I A full commitment's what I'm thinking of You wouldn't get this from any other guy I just wanna tell you how I'm feeling Gotta make you understand Never gonna give you up Never gonna let you down Never gonna run around and desert you Never gonna make you cry Never gonna say goodbye Never gonna tell a lie and hurt you We've known each other for so long Your heart's been aching but you're too shy to say it Inside we both know what's been going on We know the game and we're gonna play it And if you ask me how I'm feeling Don't tell me you're too blind to see Never gonna give you up Never gonna let you down Never gonna run around and desert you Never gonna make you cry Never gonna say goodbye Never gonna tell a lie and hurt you Never gonna give you up Never gonna let you down Never gonna run around a

Angular Material 2 - How To Lock Mat-toolbar And Mat-tabs To The Top

Answer : Did you mean a sticky toolbar? Just add a class to the toolbar and make it sticky (using the position attribute set to sticky ): .app-toolbar { position: sticky; position: -webkit-sticky; /* For macOS/iOS Safari */ top: 0; /* Sets the sticky toolbar to be on top */ z-index: 1000; /* Ensure that your app's content doesn't overlap the toolbar */ } Note: There is no support for position: sticky on IE 11. For more info on browser support for position: sticky , view this caniuse page. You can probably achieve it by setting the style with ::ng-deep: ::ng-deep .mat-toolbar{ z-index: 998; position: fixed } ::ng-deep .mat-tab-group{ margin-top:55px !important; } ::ng-deep .mat-tab-header{ z-index: 999; width:100vw; position: fixed !important; background-color: red !important; } ::ng-deep .mat-tab-body-wrapper{ position: relative !important; margin-top:55px; } DEMO Even i was facing the same issue for my

Constraint Layout Vertical Align Center

Image
Answer : It's possible to set the center aligned view as an anchor for other views. In the example below "@+id/stat_2" centered horizontally in parent and it serves as an anchor for other views in this layout. <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:id="@+id/stat_1" android:layout_width="80dp" android:layout_height="wrap_content" android:layout_marginEnd="8dp" android:gravity="center" android:maxLines="1" android:text="10" android:textColor="#777" android:textSize="22sp" app:layout_constraintTop_toTopOf="@+id/stat_2"

Bootstrap Transparent Navbar

Answer : I just figured it out. For anyone who needs this in the future. I added a css override that was: .navbar.transparent.navbar-inverse .navbar-inner { background: rgba(0,0,0,0.4); } And my html syntax looks like: <div class="navbar transparent navbar-inverse navbar-fixed-top"> <nav class="navbar-inner"> ... </div> </div> You can even use like this .navbar-default { background: none; } or .navbar { background: none; } You'll get transparent background. For a transparent navbar, it's pretty easy. In the CSS document you can do one of three things. A. The easy way, but you don't learn too much with this method. You can literally type in the CSS document that the background of the navbar is transparent. Pretty simple: .navbar { background-color: transparent; } B. You can indirectly set the alpha channel for the RGBA background color to something in between 0 and 1. The R, G, and B

Matlab Min Function Code Example

Example: matlab min function minimum = min ( x ) if x is a 1 - dimensional array then the min returns the minimum number in the array and if x is a matrix then min returns an array which contains the minimum element from each column in the matrix

Html Endline Code Example

Example 1: new line html <!-- Code by Scratchy --> <!-- Twitter : @S_cratchy--> Line 1 of text <br> Line 2 of text Example 2: how to break the line in html <p> I'm about to break the line <br> right there </p>

Display Inline Block Bootstrap 4 Class Code Example

Example 1: bootstrap display inline block <div class= "d-inline-block" ></div> Example 2: bootstrap display block <div class= "d-block" ></div> d-block = for displaying d-none = to hide

How To Print Math.pow(2 31) In C Code Example

Example 1: pow() c int base = 3 ; int power = 5 ; pow ( double ( base ) , double ( power ) ) ; Example 2: pow() c [ Mathematics ] xy = pow ( x , y ) [ In programming ]

Amd Ryzen 5 Vs Intel I7 10th Gen Code Example

Example: ryzen 5 vs intel i5 10th gen AMD won by 1 point overall they all are dope

Css Grid Properties Cheat Sheet Code Example

Example 1: css grid layout <!DOCTYPE html > <html > <head > <style > .grid-container { display : grid ; grid-template-columns : auto auto auto ; background-color : #2196F3 ; padding : 10 px ; } .grid-item { background-color : rgba ( 255 , 255 , 255 , 0.8 ) ; border : 1 px solid rgba ( 0 , 0 , 0 , 0.8 ) ; padding : 20 px ; font-size : 30 px ; text-align : center ; } </style> </head> <body> <div class= "grid-container" > <div class= "grid-item" > 1 </div> <div class= "grid-item" > 2 </div> <div class= "grid-item" > 3 </div> <div class= "grid-item" > 4 </div> <div class= "grid-item" > 5 </div> <div class= "grid-item" > 6 </div> <div class= "grid-item" > 7 </div> <div class= "grid-item" > 8 &

Concat String In Node Js Code Example

Example 1: string concatenation in js var str1 = "Hello " ; var str2 = "world!" ; var res = str1 . concat ( str2 ) ; console . log ( res ) ; Example 2: how to concatenate strings javascript var str1 = "Hello " ; var str2 = "world!" ; var res = str1 . concat ( str2 ) ; // does not change the existing strings, but // returns a new string containing the text // of the joined strings. Example 3: js concat string const str1 = 'Hello' ; const str2 = 'World' ; console . log ( str1 . concat ( ' ' , str2 ) ) ; // expected output: "Hello World" console . log ( str2 . concat ( ', ' , str1 ) ) ; // expected output: "World, Hello" Example 4: string concat in js let string1 = "Hello" let string2 = "World" let finalString = string1 + ", " + string2 + "!" // Hello, World!

Add Timestamp To Oh-my-zsh Robbyrussell Theme

Image
Answer : According to the zshmisc man page there are several % codes for date and time, eg: %D The date in yy-mm-dd format. %T Current time of day, in 24-hour format. %t %@ Current time of day, in 12-hour, am/pm format. %* Current time of day in 24-hour format, with seconds. %w The date in day-dd format. %W The date in mm/dd/yy format. %D{strftime-format} The last one allows codes listed in the strftime(3) man page. Edit your ~/.zshrc file and add at the end a new PROMPT value, eg: PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} %D %T % %{$reset_color%}' If you want add date/time to the right, you set RPROMPT local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )" PROMPT='${ret_status} %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)' RPROMPT="[%D{%y/%m/%f}|%@]" I added this %D{%m/%f/%y}|%D{%L:%M:%S} to the main theme to disp

Boruto Naruto Next Generations Anime Code Example

Example: boruto It is good.. you should try it

20 Second Timer 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.

Css Display: Table-cell Code Example

Example: a div within table behave like table element #container { display: table; } #row { display: table-row; } #left, #right, #middle { display: table-cell; }