Posts

Showing posts from November, 2016

Add An Item In A Seq In Scala

Answer : Two things. When you use :+ , the operation is left associative , meaning the element you're calling the method on should be on the left hand side. Now, Seq (as used in your example) refers to immutable.Seq . When you append or prepend an element, it returns a new sequence containing the extra element, it doesn't add it to the existing sequence. val newSeq = customerList :+ CustomerDetail("1", "Active", "Shougat") But appending an element means traversing the entire list in order to add an item, consider prepending: val newSeq = CustomerDetail("1", "Active", "Shougat") +: customerList A simplified example: scala> val original = Seq(1,2,3,4) original: Seq[Int] = List(1, 2, 3, 4) scala> val newSeq = 0 +: original newSeq: Seq[Int] = List(0, 1, 2, 3, 4) It might be worth pointing out that while the Seq append item operator, :+ , is left associative , the prepend operator, +: , is right as

System Limit For Number Of File Watchers Reached, Watch '/home/ubuntu/seat_dashboard/public' Code Example

Example: Error: ENOSPC: System limit for number of file watchers reached echo fs.inotify.max_user_watches= 524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p # that modifies the file watch limit to max 524 , 288 which consume approx. 512 MB Ram for 64 bit . # reduce that number to consume less memory. # to see if that did it run cat /proc/sys/fs/inotify/max_user_watches # you should see fs.inotify.max_user_watches= 524288

Youtube Convertor To Mp3 Code Example

Example: yt to mp3 Youtube - DL works great . Download from https : //youtube-dl.org/. To use, type youtube-dl <url> --audio-format mp3

Adminlte 4 Download Github Code Example

Example: adminlte npm install admin-lte@^3.0 --save

Android - Emulator Takes A Long Time To Start Up

Answer : The emulator is just slow, there is not much you can do about it. See https://stackoverflow.com/questions/1554099/slow-android-emulator To maximize the accuracy between emulator and real devices, Google emulator uses ARM opcode, a kind of machine language. It must convert from ARM opcode to Intel opcode. That's why it's slow. My computer is 3GB RAM but it's still slow and lagged. The problem seems not to be RAM but CPU. Improving CPU will improve the emulator. To use emulator more effectively, this is my experience: Don't close emulator everytime you run your application. Scale the emulator screen smaller. Disable snapshot (Yes, it's useful but it takes time to close the emulator). Specify a file path for SD card image file. I use only one SD card for many AVDs. If you got any problems in adb, just reset adb, don't close emulator. Open few programs in your operating sytem. If you are using Windows, don't ever close emulator. Do it c

Among Us Hack Pc Code Example

Example: among us hacks you giant bastard fucker

Change Action Bar Color Android Studio Code Example

Example 1: how to change actionbar color in android programmatically getSherlockActivity ( ) . getSupportActionBar ( ) . setBackgroundDrawable ( new ColorDrawable ( 0xff00ACED ) ) ; mActionBar . setBackgroundDrawable ( new ColorDrawable ( 0xff00DDED ) ) ; mActionBar . setDisplayShowTitleEnabled ( false ) ; mActionBar . setDisplayShowTitleEnabled ( true ) ; Example 2: actionbar content color in android getActionBar ( ) /* or getSupportActionBar() */ . setTitle ( Html . fromHtml ( "<font color=\"red\">" + getString ( R . string . app_name ) + "</font>" ) ) ;

How To Declare Global Function In C Code Example

Example: global and local variables in c # include <stdio.h> //local parameters take precedance to global// /* global variable declaration */ int a = 20 ; int main ( ) { /* local variable declaration in main function */ int a = 10 ; int b = 20 ; int c = 0 ; printf ( "value of a in main() = %d\n" , a ) ; c = sum ( a , b ) ; printf ( "value of c in main() = %d\n" , c ) ; return 0 ; } /* function to add two integers */ int sum ( int a , int b ) { printf ( "value of a in sum() = %d\n" , a ) ; printf ( "value of b in sum() = %d\n" , b ) ; return a + b ; }

Could Not Find Com.android.tools.build:gradle:4.0.1 OR 4.0.0

Answer : this solution just work in iran go to -> File | Settings | Appearance & Behavior | System Settings | HTTP Proxy, and choose -> manual proxy configuration. set host name: fodev.org and set port number: 8118 . now you must find gradle.properties file. that must be in: Windows: C:\Users\YOURUSERNAME.gradle\gradle.properties OR for Linux: ~/.gradle/gradle.properties . if does't exist, create that yourself. and copy this : systemProp.http.proxyHost=fodev.org systemProp.http.proxyPort=8118 systemProp.http.nonProxyHosts=*.jitpack.io, *.maven.org systemProp.https.proxyHost=fodev.org systemProp.https.proxyPort=8118 systemProp.https.nonProxyHosts=*.jitpack.io, *.maven.org now you can sync project. IMPORTANT : after install build.gradle 4.0.1 (or every version), back this settings to before and remove codes

Can A Torrent With Zero Seeders Download?

Answer : DHT and Peer Exchange are not tracker related, but program related, so yes they can find people who are downloading the same file but are not connected to the tracker you are using. Those people that are found might be either seeders or leechers. From this BiTorrent FAQ: When there are zero seeds for a given torrent (and not enough peers to have a distributed copy), then eventually all the peers will get stuck with an incomplete file, if no one in the swarm has the missing pieces. When this happens, someone with a complete file (a seed) must connect to the swarm so that those missing pieces can be transferred. This is called reseeding. Usually a request for a reseed comes with an implicit promise that the requester will leave his or her client open for some time period after finishing (to add longevity to the torrent) in return for the kind soul reseeding the file. Yes, it is true in practice - but not always. With no seeders, the

Can't Import Soundfile Python

Answer : You need to install the needed library: On Linux, you need to install libsndfile using your distribution’s package manager, for example sudo apt-get install libsndfile1 . From PyPI handras answer (from 2019) is not working now (in 2020) so install libsndfile1 via ( as A.B.) sudo apt-get install libsndfile1-dev

Bash Script If Variable Is Not Empty Code Example

Example 1: bash if null or empty if [ - z "$variable" ] ; then echo "$variable is null" ; else echo "$variable is not null" ; fi Example 2: bash if variable is not empty VAR = `echo Hello world` if [ [ - n "$VAR" ] ] ; then echo "Variable is set" ; fi Example 3: bash check if variable is empty if [ - z "$var" ] # return true if $ var is unset

Android Studio Change Package Name Code Example

Example: android studio change package name In Android Studio , you can do this : For example , if you want to change com . example . app to my . awesome . game , then : In your Project pane , click on the little gear icon ( Gears icon ) Uncheck the Compact Empty Middle Packages option Compact Empty Middle Packages Your package directory will now be broken up into individual directories Individually select each directory you want to rename , and : Right - click it Select Refactor Click on Rename In the pop - up dialog , click on Rename Package instead of Rename Directory Enter the new name and hit Refactor Click Do Refactor in the bottom Allow a minute to let Android Studio update all changes Note : When renaming com in Android Studio , it might give a warning . In such case , select Rename All Enter image description here Now open your Gradle Build File ( build . gradle - Usually app or mobile

Css Initial-letter Example

The initial-letter CSS property sets styling for dropped, raised, and sunken initial letters. /* Keyword values */ initial-letter : normal ; /* Numeric values */ initial-letter : 1.5 ; /* Initial letter occupies 1.5 lines */ initial-letter : 3.0 ; /* Initial letter occupies 3 lines */ initial-letter : 3.0 2 ; /* Initial letter occupies 3 lines and sinks 2 lines */ /* Global values */ initial-letter : inherit ; initial-letter : initial ; initial-letter : unset ; Syntax The keyword value normal , or a <number> optionally followed by an <integer> . Values normal No special initial-letter effect. Text behaves as normal. <number> Defines the size of the initial letter, in terms of how many lines it occupies. Negative values are not allowed. <integer> Defines the number of lines the initial letter should sink when the size of it is given. Values must be greater than zero. If omitted, it duplicates the size value

Angular CLI Ng Command Not Found On Mac Os

Image
Answer : After days of googling and getting no help neither on here nor from @Angular github which is pretty much useless, was finally able to resolve the issue and get my angular ng command not found issue resolved following these steps: 1. Instal nvm Issue these 3 commands to install nvm. (Angular documented steps https://angular.io/guide/setup-local to setup your environment did not work for me). So I installed nvm like so: curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash export NVM_DIR="/Users/your-user-name/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" After this, make sure you restart terminal and you should be able to issue nvm --version to see version of installed nvm. 2. Install node using nvm nvm install stable nvm install node 3. Finally, install angular npm install -g @angular/cli 4. Restart terminal Restart terminal and you should be able to use ng version to s

Css Grid Autofit List Of Elements Code Example

Example 1: grid repeating auto columns /* To achieve wrapping, we can use the auto-fit or auto-fill keywords. */ grid-template-columns: repeat( auto-fit, minmax(250px, 1fr) ); Example 2: grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); grid-template-columns: repeat( 12, minmax(250px, 1fr) );

Android Studio Failed To Load JVM DLL

Answer : It is very late for my answer but still to the people who reference this in the future, I had the same issue. Mine was x64 bit OS and I was trying to open studio.exe which is x32 bit. I opened studio64.exe and it worked. As well as JAVA_HOME which should be set to the jdk directory e.g. C:\Program Files\Java\jdk1.7.0_21 you also have to add a path to the jdk bin directory e.g. C:\Program Files\Java\jdk1.7.0_21\bin . As you already know how to set the JAVA_HOME variable adding the extra directory to the path variable is just the same but you have to edit an existing variable and add the path separated by a semicolon e.g. add ;C:\Program Files\Java\jdk1.7.0_21\bin to the end of the path. And then restart your PC, to start the Android Studio. More details at: Getting Started With Android Studio It works like this: JAVA_HOME : C:\Program Files\Java\jdk1.7.0_21 and PATH : C:\Program Files\Java\jdk1.7.0_21\bin

What Is Maxint In Python Code Example

Example: max int python import sys MAX_INT = sys . maxsize - 1

Android: Start The Circular Progress Bar From Top (270°)

Image
Answer : Try specifying rotation degrees to your progress items. <?xml version="1.0" encoding="UTF-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@android:id/progress"> <rotate android:fromDegrees="270" android:toDegrees="270" android:pivotX="50%" android:pivotY="50%" > <shape android:innerRadiusRatio="2.5" android:shape="ring" android:thicknessRatio="25.0" > <gradient android:centerColor="@color/gray" android:endColor="@color/gray" android:startColor="@color/gray" android:type="sweep" /> </shape> </rotate>