Posts

Showing posts from March, 2019

Cristiano Ronaldo Movie Code Example

Example: cristiano ronaldo CR7 is the GOAT

Android - Can I Restart Bluetooth From The Terminal?

Answer : The following terminal command should enable Bluetooth via adb shell or Terminal Emulator app: su am start -a android.bluetooth.adapter.action.REQUEST_ENABLE On most versions of Android, this command will present a pop-up window to the user asking to confirm request to enable BT. I believe this was done for security purposes whenever an app that is not system is toggling BT. I haven't found a way to disable BT via a shell command unfortunately. With WiFi it's a lot easier, and does not prompt user for permission: su svc wifi enable will turn it on, and su svc wifi disable will turn it off. in android.bluetooth.IBluetoothManager, there some parameters TRANSACTION_registerAdapter = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0); TRANSACTION_unregisterAdapter = (android.os.IBinder.FIRST_CALL_TRANSACTION + 1); TRANSACTION_registerStateChangeCallback = (android.os.IBinder.FIRST_CALL_TRANSACTION + 2); TRANSACTION_unregisterStateChangeCallback

Convertisseur Mp4 Youtube Code Example

Example 1: youtube to mp4 ytmp3.cc is the best by far Example 2: youtube to mp4 flvto.biz is great for it

How To Fix Control Reaches End Of Non-void Function Code Example

Example: control reaches end of non-void function return result_of_calling_function ; //I need to write this, otherwise I will get an error.

C Power Operator Code Example

Example: c power operator result = ( int ) pow ( ( double ) a , i ) ;

3 15 Inch En Cm Code Example

Example: inch to cm 1 inch = 2.54 cm

Convert Pandas Series To DateTime In A DataFrame

Answer : You can't: DataFrame columns are Series , by definition. That said, if you make the dtype (the type of all the elements) datetime-like, then you can access the quantities you want via the .dt accessor (docs): >>> df["TimeReviewed"] = pd.to_datetime(df["TimeReviewed"]) >>> df["TimeReviewed"] 205 76032930 2015-01-24 00:05:27.513000 232 76032930 2015-01-24 00:06:46.703000 233 76032930 2015-01-24 00:06:56.707000 413 76032930 2015-01-24 00:14:24.957000 565 76032930 2015-01-24 00:23:07.220000 Name: TimeReviewed, dtype: datetime64[ns] >>> df["TimeReviewed"].dt <pandas.tseries.common.DatetimeProperties object at 0xb10da60c> >>> df["TimeReviewed"].dt.year 205 76032930 2015 232 76032930 2015 233 76032930 2015 413 76032930 2015 565 76032930 2015 dtype: int64 >>> df["TimeReviewed"].dt.month 205 76032930 1 232 76032930 1 233 7

Angular Service Worker SwUpdate.available Not Triggered

Answer : You will probably need to tell the service worker to check the server for updates, I usually use a service for this: export class UpdateService { constructor(public updates: SwUpdate) { if (updates.isEnabled) { interval(6 * 60 * 60).subscribe(() => updates.checkForUpdate() .then(() => console.log('checking for updates'))); } } public checkForUpdates(): void { this.updates.available.subscribe(event => this.promptUser()); } private promptUser(): void { console.log('updating to new version'); this.updates.activateUpdate().then(() => document.location.reload()); } In your app-component.ts : constructor(private sw: UpdateService) { // check the service worker for updates this.sw.checkForUpdates(); } For whatever reason, Angular sometimes does not register the service worker properly. So you can modify `main.ts` : Replace: platformBrowserDynamic().bootstrapModule(AppModule); With: p

Android Studio : How To Uninstall APK (or Execute Adb Command) Automatically Before Run Or Debug?

Answer : adb uninstall <package_name> can be used to uninstall an app via your PC. If you want this to happen automatically every time you launch your app via Android Studio, you can do this: In Android Studio, click the drop down list to the left of Run button, and select Edit configurations... Click on app under Android Application, and in General Tab, find the heading 'Before Launch' Click the + button, select Run external tool, click the + button in the popup window. Give some name (Eg adb uninstall) and description, and type adb in Program: and uninstall <your-package-name> in Parameters:. Make sure that the new item is selected when you click Ok in the popup window. Note: If you do not have adb in your PATH environment variable, give the full path to adb in Program: field (eg /home/user/android/sdk/platform-tools/adb). example adb uninstall com.my.firstapp List the packages by: adb shell su 0 pm list packages Review which package you w

Can't Connect To PPTP VPN With Ufw Enabled On Ubuntu 14.04 With Kernel 3.18

Answer : This is caused by a change for security reason in kernel 3.18 [1]. There are two ways to fix this. First approach is adding this rule to the file /etc/ufw/before.rules before the line # drop INVALID packets ... -A ufw-before-input -p 47 -j ACCEPT Second approach is manually loading the nf_conntrack_pptp module. You can do this by running sudo modprobe nf_conntrack_pptp To load this module on every boot on Ubuntu, add it to the file /etc/modules . For more recent versions of ufw a solution is instead: sudo ufw allow proto gre from [PPTP gateway IP address] sudo systemctl restart ufw Add nf_conntrack_pptp to /etc/modules-load.d/pptp.conf One liner echo nf_conntrack_pptp | sudo tee /etc/modules-load.d/pptp.conf Explanation The accepted answer works for me, especially the 2nd suggestion--loading the nf_conntrack_pptp kernel module--as opposed to modifying my iptables firewall. My laptop firewall is otherwise unmodified. sudo ufw enable without excepti

ConfigureAwait Pushes The Continuation To A Pool Thread

Answer : Why ConfigureAwait pro-actively pushes the await continuation to a pool thread here? It doesn't "push it to a thread pool thread" as much as say "don't force myself to come back to the previous SynchronizationContext ". If you don't capture the existing context, then the continuation which handles the code after that await will just run on a thread pool thread instead, since there is no context to marshal back into. Now, this is subtly different than "push to a thread pool", since there isn't a guarantee that it will run on a thread pool when you do ConfigureAwait(false) . If you call: await FooAsync().ConfigureAwait(false); It is possible that FooAsync() will execute synchronously, in which case, you will never leave the current context. In that case, ConfigureAwait(false) has no real effect, since the state machine created by the await feature will short circuit and just run directly. If you want to see this in actio

Css Transform First Letter Uppercase Code Example

Example 1: css capitalize first letter & ::first-letter { text-transform : capitalize ; } Example 2: css all uppercase to capitalize .link { text-transform : lowercase ; } .link ::first-line { text-transform : capitalize ; }

Rounded Buttons Html Css Code Example

Example 1: round button css .btn { display : block ; height : 300 px ; width : 300 px ; border-radius : 50 % ; border : 1 px solid red ; } Example 2: css rounded corners /* Use border-radius property */ .class { border-radius : 5 px ; } .circle { border-radius : 50 % ; }

Display Inherit In Css Code Example

Example: inherit css span { color : blue ; } .extra span { color : inherit ; }

Bulk Update In Pymongo Using Multiple ObjectId

Answer : Iterate through the id list using a for loop and send the bulk updates in batches of 500: bulk = db.testdata.initialize_unordered_bulk_op() counter = 0 for id in ids: # process in bulk bulk.find({ '_id': id }).update({ '$set': { 'isBad': 'N' } }) counter += 1 if (counter % 500 == 0): bulk.execute() bulk = db.testdata.initialize_ordered_bulk_op() if (counter % 500 != 0): bulk.execute() Because write commands can accept no more than 1000 operations (from the docs ), you will have to split bulk operations into multiple batches, in this case you can choose an arbitrary batch size of up to 1000. The reason for choosing 500 is to ensure that the sum of the associated document from the Bulk.find() and the update document is less than or equal to the maximum BSON document size even though there is no there is no guarantee using the default 1000 operations requests will fit under the 16MB BSON limit. Th

Add Custom View To The Right Of Toolbar

Answer : I just set layout_gravity to the right and it worked <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="0dp" android:layout_height="?android:actionBarSize" app:title="NEW REQUESTS" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="blahblah" android:layout_gravity="right" /> </android.support.v7.widget.Toolbar> You can add ViewGroups inside Toolbar <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="@dimen/toolbar_height" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

Copying Files With Scp: Connection Timed Out

Answer : After spending way too long on this, scp reports this error any time the syntax of the command line is wrong. If ssh works to the host that you are trying to reach, but scp returns this error, the scp command line is not understandable by scp. Also note that the mistake may be an invisible character. This can happen if you try to paste a long file name using ^v for example, but the character is entered into the command line instead. Retype your request and insure that you don't insert invisible characters. Check the firewall of the servers . and also check if server is reachable, check if sshserver is running

Square Root In C Code Example

Example 1: root in C # include <stdio.h> # include <math.h> int main ( ) { double num = 6 , squareRoot ; squareRoot = sqrt ( num ) ; printf ( "Square root of %lf = %lf" , num , squareRoot ) ; return 0 ; } Example 2: sqrt in c # include <math.h> double sqrt ( double arg ) ; Example 3: c sqrt double sqrt ( double arg ) ;

For Every Line In File Bash Linux Command Code Example

Example 1: bash for each line of file while read p ; do echo "$p" done < peptides . txt Example 2: for each line in file bash while read p ; do echo "$p" done < peptides . txt