Posts

Showing posts from November, 2010

Vs Code For C Programming Code Example

Example: how to run c program from visual studio terminal Fire up the terminal from VS code Use the command "gcc filename.c" to compile the program Use the command ".\a.exe" to run the program from the terminal P . S . Remove "" before exceuting

Background Color None In Css Code Example

Example 1: background color none element { background-color : transparent ; } Example 2: css background color body { background-color : green ; } Example 3: background color using css /* To apply color to background you have to use 'background-color' property and value of property is color name. */ html , body { background-color : blue ; } Example 4: css coor background body { background-color : coral ; }

Can I Use Array_push On A SESSION Array In Php?

Answer : Yes, you can. But First argument should be an array. So, you must do it this way $_SESSION['names'] = array(); array_push($_SESSION['names'],$name); Personally I never use array_push as I see no sense in this function. And I just use $_SESSION['names'][] = $name; Try with if (!isset($_SESSION['names'])) { $_SESSION['names'] = array(); } array_push($_SESSION['names'],$name);

How To Get Array Length In Python Code Example

Example 1: size array python size = len ( myList ) Example 2: python get array length # To get the length of a Python array , use 'len()' a = arr . array ( ‘d’ , [ 1.1 , 2.1 , 3.1 ] ) len ( a ) # Output : 3 Example 3: find array length python array = [ 1 , 2 , 3 , 4 , 5 ] print ( len ( arr ) )

Bootstrap Template For Cards Code Example

Example 1: boostrap card < div class = " card " style = " width : 18 rem ; " > < div class = " card-body " > < h5 class = " card-title " > Card title </ h5 > < h6 class = " card-subtitle mb-2 text-muted " > Card subtitle </ h6 > < p class = " card-text " > Some quick example text to build on the card title and make up the bulk of the card's content. </ p > < a href = " # " class = " card-link " > Card link </ a > < a href = " # " class = " card-link " > Another link </ a > </ div > </ div > Example 2: .card class < style > .card { border : 1 px solid #ccc ; background-color : #f4f4f4 ; padding : 20 px ; margin-bottom : 10 px ; } </ style >

Android Apk Metasploit Windows Code Example

Example: download metasploit curl https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb > msfinstall && \ chmod 755 msfinstall && \ ./msfinstall

Avl Tree Geeks For Geeks Code Example

Example: avl tree c implementation # include <stdio.h> # include "avltree.h" /* remove all nodes of an AVL tree */ void dispose ( node * t ) { if ( t != NULL ) { dispose ( t -> left ) ; dispose ( t -> right ) ; free ( t ) ; } } /* find a specific node's key in the tree */ node * find ( int e , node * t ) { if ( t == NULL ) return NULL ; if ( e < t -> data ) return find ( e , t -> left ) ; else if ( e > t -> data ) return find ( e , t -> right ) ; else return t ; } /* find minimum node's key */ node * find_min ( node * t ) { if ( t == NULL ) return NULL ; else if ( t -> left == NULL ) return t ; else return find_min ( t -> left ) ; } /* find maximum node's key */ node * find_max ( node * t ) { if (

Check Python String Format?

Answer : try with regular expresion: import re r = re.compile('.*/.*/.*:.*') if r.match('x/x/xxxx xx:xx') is not None: print 'matches' you can tweak the expression to match your needs Use time.strptime to parse from string to time struct. If the string doesn't match the format it raises ValueError . If you use regular expressions with match you must also account for the end being too long. Without testing the length in this code it is possible to slip any non-newline character at the end. Here is code modified from other answers. import re r = re.compile('././.{4} .{2}:.{2}') s = 'x/x/xxxx xx:xx' if len(s) == 14: if r.match(s): print 'matches'

Case Function Equivalent In Excel

Answer : Sounds like a job for VLOOKUP! You can put your 32 -> 1420 type mappings in a couple of columns somewhere, then use the VLOOKUP function to perform the lookup. Without reference to the original problem (which I suspect is long since solved), I very recently discovered a neat trick that makes the Choose function work exactly like a select case statement without any need to modify data. There's only one catch: only one of your choose conditions can be true at any one time. The syntax is as follows: CHOOSE( (1 * (CONDITION_1)) + (2 * (CONDITION_2)) + ... + (N * (CONDITION_N)), RESULT_1, RESULT_2, ... , RESULT_N ) On the assumption that only one of the conditions 1 to N will be true, everything else is 0, meaning the numeric value will correspond to the appropriate result. If you are not 100% certain that all conditions are mutually exclusive, you might prefer something like: CHOOSE( (1 * TEST1) + (2 * TEST2) + (4 * TEST3) + (8 * TEST4) ... (2^

Bootstrap Table Responsive Example

Example 1: bootstrap table < table class = " table " > < thead > < tr > < th scope = " col " > # </ th > < th scope = " col " > First </ th > < th scope = " col " > Last </ th > < th scope = " col " > Handle </ th > </ tr > </ thead > < tbody > < tr > < th scope = " row " > 1 </ th > < td > Mark </ td > < td > Otto </ td > < td > @mdo </ td > </ tr > < tr > < th scope = " row " > 2 </ th > < td > Jacob </ td > < td > Thornton </ td > < td > @fat </ td > </ tr > < tr > < th scope = " row " > 3 </ th > < td > Larry </ td >

Android - Can I Disable MTP Mode And Just Have A Regular USB Connection?

Answer : I'm not 100% sure. But IIRC, the problem with normal USB storage is Android has to partition your phone for internal storage and USB storage. Your computer can then umount the USB storage from phone and mount it in your computer. So in many phones without MTP, even though the internal storage had capacity like 16GB, only 1 or 2 GB was available for app installation. While some phone gave up to 8GB for app, that space was wasted for people who didn't need that much for app but needed space for music and photos. With MTP mode, there isn't separate partition but a whole single partition. So if you have 16GB internal storage in your phone, you can use whole 16GB for apps, music and photos. MTP mode is available from Honeycomb and I don't think it's an optional component. I mean I don't think you can say I don't want MTP mode, I want USB storage mode.

Android - SetOnClickListener Vs OnClickListener Vs View.OnClickListener

Answer : Imagine that we have 3 buttons for example public class MainActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Capture our button from layout Button button = (Button)findViewById(R.id.corky); Button button2 = (Button)findViewById(R.id.corky2); Button button3 = (Button)findViewById(R.id.corky3); // Register the onClick listener with the implementation above button.setOnClickListener(mCorkyListener); button2.setOnClickListener(mCorkyListener); button3.setOnClickListener(mCorkyListener); } // Create an anonymous implementation of OnClickListener private View.OnClickListener mCorkyListener = new View.OnClickListener() { public void onClick(View v) { // do something when the button is clicked // Yes we will handle

Android GetResources().getDrawable() Deprecated API 22

Answer : You have some options to handle this deprecation the right (and future proof ) way, depending on which kind of drawable you are loading: A) drawables with theme attributes ContextCompat.getDrawable(getActivity(), R.drawable.name); You'll obtain a styled Drawable as your Activity theme instructs. This is probably what you need. B) drawables without theme attributes ResourcesCompat.getDrawable(getResources(), R.drawable.name, null); You'll get your unstyled drawable the old way. Please note: ResourcesCompat.getDrawable() is not deprecated! EXTRA) drawables with theme attributes from another theme ResourcesCompat.getDrawable(getResources(), R.drawable.name, anotherTheme); Edit: see my blog post on the subject for a more complete explanation You should use the following code from the support library instead: ContextCompat.getDrawable(context, R.drawable.***) Using this method is equivalent to calling: if (Build.VERSION.SDK_INT &

Code=H14 Desc="No Web Processes Running" Method=GET Path="/" Code Example

Example: heroku no web processes running spring boot Create Procfile with just web: java -Dspring.profiles.active=default -Dserver.port=$PORT -jar target/*.jar then on the heroku CLI : heroku ps:scale web=1

Callout Limits For Future Methods And Queueable Apex

Image
Answer : I quickly wrote a class with future method to test this behaviour. public class FutureClassLimitsTest { @future(callout=true) public static void docallouts(){ for(Integer i=0;i<200;i++){ Http http=new Http(); HttpRequest hr=new HttpRequest(); hr.setMethod('POST'); hr.setEndpoint('https://google.com'); http.send(hr); } } } This is the error I get. First error: Too many callouts: 101. So I believe this is uniform for the whole platform irrespective of the transaction(Sync or Async). Is there a workaround? Well unless there is a strong business requirement it is kinda bad doing so many callous in a transaction. We can call a Queauble Method from Queueable method,.. and you can chain them infinitely. Thus using proper implementation you can have 100+ callouts. Batch is another way to tackle this. You have to write /modify data model add a some queue cus

Can An Optical Mouse Be Used To Measure Distance Down To 1-10μm?

Answer : I have tried this before, using an Avago sensor harvested from an optical mouse. It doesn't work. The resolution is excellent but the accuracy is terrible. And the calibration varies with distance from material to the sensor. I arranged a test with a 3" diameter wheel and the sensor reading the outside "tread" of the wheel. I also put a flag on the wheel, passing through an optical interrupter sensor. The number of counts read per revolution varied by a few tenths of a percent, nowhere near good enough repeatability for machining. I guess you could use the optical mouse sensor in combination with an accurate but low-resolution sensor to fill in the in-between points. But really, I think other sensor technologies are more appropriate for this. Neat idea. I considered using a hacked Livescribe pen with special dot rails for the same purpose, then an absolute location would be provided, rather than the relative location a basic optical mouse wou

Apple - Bootcamp: The Startup Disk Does Not Have Enough Space To Be Partitioned

Image
Answer : Okay, the solution is that I did not disable Time Machine and remove all backup drives first. Doing that solved the issue. So the full solution is: Disable "Backup Up Automatically" in Time Machine System Preferences, and remove all backup drives, such that it looks like this: Then run sudo tmutil thinlocalsnapshots / 999999999999 And try again. Optionally restart the computer and try again. In Mojave, what I had to do was turn off Time Machine and then run this command to force clean out the local snapshots: tmutil thinlocalsnapshots / 1000000000 1 where 1000000000 is the size of your drive and the "1" means urgent. This has to be done a few times since it only cleans up a few local snapshots each time. After that, you should be able to see sufficient space available with this command: diskutil apfs resizecontainer disk0s2 limits Open activity monitor and force quit backupd , then click continue in the bootcamp assistant.

Bootstrap Modal: Close Current, Open New

Answer : I know this is a late answer, but it might be useful. Here's a proper and clean way to get this done, as @karima's mentioned above. You can actually fire two functions at once; trigger and dismiss the modal. HTML Markup; <!-- Button trigger modal --> <ANY data-toggle="modal" data-target="TARGET">...</ANY> <div class="modal fade" id="SELECTOR" tabindex="-1"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-body"> ... </div> <div class="modal-footer"> <!-- ↓ --> <!-- ↓ --> <ANY data-toggle="modal" data-target="TARGET-2" data-dismiss="modal">...</ANY> </div> </div> </div> </div> Demo Without seeing specific code, it's difficult to give you a precise answer. Howev