Posts

Showing posts from October, 2008

Closing Excel Application Using VBA

Answer : I think your problem is that it's closing the document that calls the macro before sending the command to quit the application. Your solution in that case is to not send a command to close the workbook. Instead, you could set the "Saved" state of the workbook to true, which would circumvent any messages about closing an unsaved book. Note: this does not save the workbook; it just makes it look like it's saved. ThisWorkbook.Saved = True and then, right after Application.Quit To avoid the Save prompt message, you have to insert those lines Application.DisplayAlerts = False ThisWorkbook.Save Application.DisplayAlerts = True After saving your work, you need to use this line to quit the Excel application Application.Quit Don't just simply put those line in Private Sub Workbook_Open() unless you got do a correct condition checking, else you may spoil your excel file. For safety purpose, please create a module to run it. The following are t

Android Command Line Tools Sdkmanager Always Shows: Warning: Could Not Create Settings

Answer : Instead of passing the argument --sdk_root for each single command execution, let's deep dive into the real cause. Starting from Android SDK Command-line Tools 1.0.0 (6200805) , in contrast to Android SDK 26.1.1 (4333796) , the tools directory hierarchy has been changed. Previously it was placed right inside ANDROID_HOME (which is deprecated, we will use the term ANDROID_SDK_ROOT for the rest of the paragraph), now it's still named as tools (the only thing you'll get after unpacking the downloaded commandlinetools zip file), but differently, you have to place it inside a directory called cmdline-tools on your own. The name cmdline-tools comes from its package name, where you can get from listing packages command sdkmanager --list , whose outputs include cmdline-tools;1.0 | 1.0 | Android SDK Command-line Tools . Wrapping tools directory inside cmdline-tools directory would make it work, and help you get rid of the annoying --sdk_root argument. But

Bootstrap Delete Button Code Example

Example 1: bootstarp btn colors < button type = "button" class = "btn btn-primary" > Blue < /button > < button type = "button" class = "btn btn-secondary" > Grey < /button > < button type = "button" class = "btn btn-success" > Green < /button > < button type = "button" class = "btn btn-danger" > Red < /button > < button type = "button" class = "btn btn-warning" > Yellow < /button > < button type = "button" class = "btn btn-info" > Ligth blue < /button > < button type = "button" class = "btn btn-light" > White < /button > < button type = "button" class = "btn btn-dark" > Black < /button > < button type = "button" class = "btn btn-link" > White with blue text < /button > Example 2:

Avatar 2 The Last Airbender Full Movie Code Example

Example 1: avatar the last airbender The best tv show! Example 2: avatar the last airbender what innocent ibex said

Cannot Install Cocoapods - No Podfile Found In The Project Directory

Answer : Steps to add CocoaPods to manage dependencies in your project: sudo gem install cocoapods -> This installs CocoaPods as a piece of software on your machine. Go to the root of your project directory and execute pod init -> This will add a base Podfile to your project. Add the external dependencies that you have to this Podfile by editing it. Run pod install which will fetch all the external dependencies mentioned by you, and associate it with a .xcworkspace file of your project. This .xcworkspace file will be generated for you if you already do not have one. From here on, you should use .xcworkspace file instead of .xcproject / .xcodeproj . Example Podfile Syntax: target 'MyApp' do pod 'AFNetworking', '~> 3.0' end Where AFNetworking is the pod and 3.0 is the specific version that I want to install. Documentation: Using CocoaPods If you want to add a library from GitHub to your own project, after installing gems,

Bootstrap Colors Button Code Example

Example 1: bootstarp btn colors <button type= "button" class= "btn btn-primary" > Blue </button> <button type= "button" class= "btn btn-secondary" > Grey </button> <button type= "button" class= "btn btn-success" > Green </button> <button type= "button" class= "btn btn-danger" > Red </button> <button type= "button" class= "btn btn-warning" > Yellow </button> <button type= "button" class= "btn btn-info" >Ligth blue </button> <button type= "button" class= "btn btn-light" > White </button> <button type= "button" class= "btn btn-dark" > Black </button> <button type= "button" class= "btn btn-link" > White with blue text</button> Example 2: bootstrap 4 button <button type= "button&quo

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 . . .

Android NDK With Google Test

Answer : If you choose cmake to drive your externalNativeBuild (and this is the preferred option, according to Android Developers NDK guide), then you can simply add the following lines to your CMakeLists.txt : set(GOOGLETEST_ROOT ${ANDROID_NDK}/sources/third_party/googletest/googletest) add_library(gtest STATIC ${GOOGLETEST_ROOT}/src/gtest_main.cc ${GOOGLETEST_ROOT}/src/gtest-all.cc) target_include_directories(gtest PRIVATE ${GOOGLETEST_ROOT}) target_include_directories(gtest PUBLIC ${GOOGLETEST_ROOT}/include) add_executable(footest src/main/jni/foo_unittest.cc) target_link_libraries(footest gtest) If your build succeeds, you will find app/.externalNativeBuild/cmake/debug/x86/footest . From here, you can follow the instructions in README.NDK to run it on emulator or device. Notes : make sure that the ABI matches the target you use (the guide is not very clear about this). the list of ABI's that are built is controlled by abiFilters in build.gradle . In Android

Can You Completely Permute The Elements Of A Matrix By Applying Permutation Matrices?

Answer : It is not generally possible to do so. For a concrete example, we know that there can exist no permutation matrices P , Q P,Q P , Q such that P\pmatrix{1&2\\2&1}Q = \pmatrix{2&1\\2&1} If such a P P P and Q Q Q existed, then both matrices would necessarily have the same rank. Let me add one more argument: For n ≥ 2 n \ge 2 n ≥ 2 : Suppose the entries in the n × n n \times n n × n matrix A A A are all distinct. Then there are ( n 2 ) ! (n^2)! ( n 2 )! distinct permutations of A A A . There are n ! n! n ! row-permutations of A A A (generated by premultiplication by various permutation matrices), and n ! n! n ! col-permutations of A A A (generated by post-multiplication by permutation matrices). If we consider all expressions of the form R A C RAC R A C where R R R and C C C each range independently over all n ! n! n ! permutation matrices, we get at most ( n ! ) 2 (n!)^2 ( n ! ) 2 possible results. But for n > 1 n > 1 n > 1

C++ Prin Vectori Of Vecotrs Code Example

Example 1: get values from a vector of vectors c++ #include < iostream > #include < vector > using namespace std ; int main ( ) { vector < vector < int > > buff ; for ( int i = 0 ; i < 10 ; i ++ ) { vector < int > temp ; // create an array, don't work directly on buff yet. for ( int j = 0 ; j < 10 ; j ++ ) temp . push_back ( i ) ; buff . push_back ( temp ) ; // Store the array in the buffer } for ( int i = 0 ; i < buff . size ( ) ; ++ i ) { for ( int j = 0 ; j < buff [ i ] . size ( ) ; ++ j ) cout << buff [ i ] [ j ] ; cout << endl ; } return 0 ; } Example 2: how to create a vector from elements of an existing vector in cpp // Initializing vector with values vector < int > vect1 { 1 , 2 , 3 , 4 } ; // Declaring another vector vector < int >

Can You Get The Timestamp From A Firebase Realtime Database Key?

Answer : As I said in my comment, you should not rely on decoding the timestamp from the generated id. Instead of that, you should simply store it in a property in your Firebase. That said, it turns out to be fairly easy to get the timestamp back: // DO NOT USE THIS CODE IN PRODUCTION AS IT DEPENDS ON AN INTERNAL // IMPLEMENTATION DETAIL OF FIREBASE var PUSH_CHARS = "-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz"; function decode(id) { id = id.substring(0,8); var timestamp = 0; for (var i=0; i < id.length; i++) { var c = id.charAt(i); timestamp = timestamp * 64 + PUSH_CHARS.indexOf(c); } return timestamp; } var key = prompt("Enter Firebase push ID"); if (key) { var timestamp = decode(key); console.log(timestamp+"\n"+new Date(timestamp)); alert(timestamp+"\n"+new Date(timestamp)); } I'll repeat my comment, just in case somebody thinks it is a good idea to use this code for anything e

Factoring Calculator With Steps Code Example

Example: calculate factorial int factorial ( int n ) { int res = 1 , i ; for ( i = 2 ; i <= n ; i ++ ) res *= i ; return res ; }

Align Right Inside Flex Column Code Example

Example 1: flexbox align right and left .primary-nav { display : -webkit-flex ; display : flex ; list-style-type : none ; padding : 0 ; justify-content : flex-end ; } .left { margin-right : auto ; } Example 2: flex align children to side flex-direction : column ; align-items : flex-start ; //left align-items : center ; //center align-items : flex-end ; //right

Android MediaPlayer Stop And Play

Answer : You should use only one mediaplayer object public class PlayaudioActivity extends Activity { private MediaPlayer mp; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button b = (Button) findViewById(R.id.button1); Button b2 = (Button) findViewById(R.id.button2); final TextView t = (TextView) findViewById(R.id.textView1); b.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { stopPlaying(); mp = MediaPlayer.create(PlayaudioActivity.this, R.raw.far); mp.start(); } }); b2.setOnClickListener(new View.OnClickListener() { @Override public void

Body-parser Npm Code Example

Example 1: body-parser npm $ npm install body-parser Example 2: body-parser node // Express/Connect top-level generic // This example demonstrates adding a generic JSON and URL-encoded parser as a top-level middleware, which will parse the bodies of all incoming requests. // This is the simplest setup. var express = require('express') var bodyParser = require('body-parser') var app = express() // parse application/x-www-form-urlencoded app.use(bodyParser.urlencoded({ extended: false })) // parse application/json app.use(bodyParser.json()) app.use(function (req, res) { res.setHeader('Content-Type', 'text/plain') res.write('you posted:\n') res.end(JSON.stringify(req.body, null, 2))}) Example 3: bodyparser purpose //body-parser helps parse json files //you can use body-parser anytime you need to use a form to post //data to a request var bodyParser = require("body-parser"); app.use(bodyParser.urlencoded({extended:

Auto Increment A Value In Firebase With Javascript

Answer : Firebase has no auto-incrementing keys, since those don't work well in massively multi-user systems where clients can be offline for prolonged periods. Instead, Firebase has its own type of auto-generated keys called push IDs. These push IDs have the same important properties of sequences in many relational databases: they are ordered and sequential. But in addition, they can be calculated client-side, even when the client is not connected to the Firebase servers. See the Firebase documentation on saving data in lists, this legacy blog post on why arrays don't work well in Firebase and this post on how push ids work. Firebase recommends using distributed counters: https://firebase.google.com/docs/firestore/solutions/counters For the document that requires the counter, you'd initialize a subcollection of, say, 10 documents and run transaction increments on a random shard whenever you need a counter incremented. Then you'd query the collection of shar

Android Studio Is Using This JDK Location ... Which Is Different To What Gradle Uses By Default

Answer : Update For macOS only happens on macOS Mojave 10.14.6 . On macOS Catalina 10.15.3 , you only need to set JAVA_HOME in your shell. This answer deals with macOS cases. It doesn't imply Linux or Windows solutions. TLDR On macOS , Android Studio doesn't receive your environment variables defined in your .bash_profile when launched from Finder.app . You must define your environment variables in launchctl : launchctl setenv JAVA_HOME /path/to/my/project/specific/jdk or, if you want to use your system-defined JDK: launchctl setenv JAVA_HOME `/usr/libexec/java_home` But this only works for the current session of your machine. Next, you have to create a ~/Library/LaunchAgents/environment.plist file: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label<

Bulk Insertion In Laravel Using Eloquent ORM

Answer : You can just use Eloquent::insert() . For example: $data = array( array('name'=>'Coder 1', 'rep'=>'4096'), array('name'=>'Coder 2', 'rep'=>'2048'), //... ); Coder::insert($data); We can update GTF answer to update timestamps easily $data = array( array( 'name'=>'Coder 1', 'rep'=>'4096', 'created_at'=>date('Y-m-d H:i:s'), 'modified_at'=> date('Y-m-d H:i:s') ), array( 'name'=>'Coder 2', 'rep'=>'2048', 'created_at'=>date('Y-m-d H:i:s'), 'modified_at'=> date('Y-m-d H:i:s') ), //... ); Coder::insert($data); Update: to simplify the date we can use carbon as @Pedro Moreira suggested $now = Carbon::now('utc')->toDateTimeString(); $data = array(