Posts

Showing posts from June, 2010

Clearing The Pipeline Cache With Gitlab CI

Answer : It's not a perfect solution, but we ended up creating a cleanup job at the end of our .gitlab-ci.yaml file that deletes the cache directory from the filesystem. This way, each pipeline gets its own unique cache, without cluttering up the file system over time. cleanup_job: stage: cleanup script: - echo "Cleaning up" - rm -rf "%CACHE_PATH%/%CI_PIPELINE_ID%" when: always where CACHE_PATH: "C:/gitlab-runner/cache/group/project/repo/"

Adb Kill-server Not Responding?

Answer : I also came across the same error when I was trying to install one app in emulator. You need not restart PC to overcome this. Just kill the server. if 'adb kill-server' is also not working, kill the process (adb.exe) through task manager. There you go!! Task Manager -> Process -> adb.exe -> End process That worked for me. If zombie adb process is not the issue i.e. there's no adb.exe in the task-manager list, the problem is usually adb ports e.g. 5555, 5554, 5037 etc., being taken by other applications. Solutions: On all Windows : find the process taking one of those ports using netstat -bn and kill it from task-manager Ctrl+Shift+Esc is the shortcut. On Windows 7 and 8 : there's this new tool called Resource Monitor . It'll also allow you to find out the blocked port and blocking process under the network tab. On Linux : the similar is done with netstat -pn . Feel free to use your grep foo as needed and kill the blocking pr

Analogread Arduino Example

Example: arduino code analogwrite analogWrite(Pin number here,0 - 255 value here);

Adding A Column To An Existing Table In A Rails Migration

Answer : If you have already run your original migration (before editing it), then you need to generate a new migration ( rails generate migration add_email_to_users email:string will do the trick). It will create a migration file containing line: add_column :users, email, string Then do a rake db:migrate and it'll run the new migration, creating the new column. If you have not yet run the original migration you can just edit it, like you're trying to do. Your migration code is almost perfect: you just need to remove the add_column line completely (that code is trying to add a column to a table, before the table has been created, and your table creation code has already been updated to include a t.string :email anyway). Use this command at rails console rails generate migration add_fieldname_to_tablename fieldname:string and rake db:migrate to run this migration Sometimes rails generate migration add_email_to_users email:string produces a migration like th

Change Date Terminal Mac El Capitan 2015 Version Code Example

Example: bypass this copy of the install os x el capitan installer -pkg /Volumes/Mac \ OS \ X \ Install \ DVD/Packages/OSInstall.mpkg -target /Volumes/Macintosh \ HD

Border Height On CSS

Answer : I have another possibility. This is of course a "newer" technique, but for my projects works sufficient. It only works if you need one or two borders. I've never done it with 4 borders... and to be honest, I don't know the answer for that yet. .your-item { position: relative; } .your-item:after { content: ''; height: 100%; //You can change this if you want smaller/bigger borders width: 1px; position: absolute; right: 0; top: 0; // If you want to set a smaller height and center it, change this value background-color: #000000; // The color of your border } I hope this helps you too, as for me, this is an easy workaround. No, there isn't. The border will always be as tall as the element. You can achieve the same effect by wrapping the contents of the cell in a <span> , and applying height/border styles to that. Or by drawing a short vertical line in an 1 pixel wide PNG which is the correct height, and applying it

Change $key Of Associative Array In A Foreach Loop In Php

Answer : unset it first in case it is already in the proper format, otherwise you will remove what you just defined: foreach($array as $key => $value) { unset($array[$key]); $array[ucfirst($key)] = $value; } You can't modify the keys in a foreach , so you would need to unset the old one and create a new one. Here is another way: $array = array_combine(array_map('ucfirst', array_keys($array)), $array); Get the keys using array_keys Apply ucfirst to the keys using array_map Combine the new keys with the values using array_combine The answers here are dangerous, in the event that the key isn't changed, the element is actually deleted from the array. Also, you could unknowingly overwrite an element that was already there. You'll want to do some checks first: foreach($array as $key => $value) { $newKey = ucfirst($key); // does this key already exist in the array? if(isset($array[$newKey])){ // yes, sk

Catch All Error Python Code Example

Example 1: python catch all exceptions try : raise Exception ( "Oh no! An error happened!" ) except Exception as err : print ( "An error was handled" ) finally : print ( "This runs either way." ) Example 2: catch error data with except python import sys try : S = 1 / 0 #Create Error except : # catch *all* exceptions e = sys . exc_info ( ) print ( e ) # (Exception Type, Exception Value, TraceBack) ############ # OR # ############ try : S = 1 / 0 except ZeroDivisionError as e : print ( e ) # ZeroDivisionError('division by zero')

Print Bits In C Code Example

Example: how to print int in c # include <stdio.h> int main ( ) { int number ; printf ( "Enter an integer: " ) ; scanf ( "%d" , & number ) ; printf ( "You entered: %d" , number ) ; return 0 ; }

Arry To String Php Code Example

Example 1: php array to string // for one-dimentional arrays $str = implode ( '|' , $arr ) ; // "v1|v2|v3"... // for multi-dimensional/structured arrays, or to keep hierarchy $str = json_encode ( $arr ) ; // or $str = var_export ( $arr ) ; Example 2: arry to string php implode ( "|" , $type ) ;

Can't Upgrade Ubuntu 18.04 To 20.04 Because Of "Please Install All Available Updates For Your Release Before Upgrading" Error

Answer : sequence from 18.04 to 20.04 sudo apt update sudo apt upgrade sudo apt dist-upgrade sudo apt autoremove sudo do-release-upgrade -d -f DistUpgradeViewGtk3 Follow onscreen instruction. Good luck! I was also experiencing the same issue. However, when I ran the usual upgrade commands ( sudo apt upgrade , sudo apt full-upgrade , sudo apt-get dist-upgrade ), they were all reporting that there are no packages to upgrade and no held packages : 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. In the end, I copied the file /usr/bin/do-release-upgrade to my home and modified it as follows: for pkg in upgradable: if 'Phased-Update-Percentage' in pkg.candidate.record: # P-U-P does not exist if it is fully phased continue else: install_count += 1 print(pkg) # <--- ADD THIS LINE # one upgradeable package is enough to stop the dist-upgrade # break # <--- COMMENT THIS LINE OUT This change will print the names of all

Bootstrap 4 Center Div Code Example

Example 1: align items center bootstrap < div class = "d-flex align-items-start" > . . . < / div > < div class = "d-flex align-items-end" > . . . < / div > < div class = "d-flex align-items-center" > . . . < / div > < div class = "d-flex align-items-baseline" > . . . < / div > < div class = "d-flex align-items-stretch" > . . . < / div > Example 2: bootstrap 4 center div < div class = "d-flex justify-content-start" > . . . < / div > < div class = "d-flex justify-content-end" > . . . < / div > < div class = "d-flex justify-content-center" > . . . < / div > < div class = "d-flex justify-content-between" > . . . < / div > < div class = "d-flex justify-content-around" > . . . < / div > Example 3: align eliment in center of row bootstrap < div class = "

Eslint Rc Code Example

Example: eslint npm install $ npm install eslint -- save - dev $ . / node_modules / . bin / eslint -- init

Colleague Presented Poster Of Our Shared Work At Conferences Without My Knowledge Or Express Permission

Answer : Ultimately there isn't a single valid approach here. The appropriate level of response depends on several factors, including the field in which the work is being performed, the nature of the conference, the status of the work relative to publishing practices in the field, and so on. For instance, if you're in a field where posters are peer-reviewed before a conference, then it's a much more significant issue than presenting a poster at, for instance, a Gordon Research Conference where posters are explicitly considered to be "for discussion only" and are not intended to be used for publication. As for the author order, some societies (for instance, the APS) expect that the poster (or talk) be given by the first author as listed at submission—whether or not this is fundamentally the way it would be listed in a paper. Looking at the ethical issue—has the work been published already somewhere or otherwise public? If so, your co-author may have thought

BROOKLYN NINE NINE WIKI Code Example

Example 1: brooklyn nine nine Yeah, I love this show too! Example 2: brooklyn nine nine Yeah this show seems to be great

AndroidViewModel Vs ViewModel

Answer : AndroidViewModel provides Application context If you need to use context inside your Viewmodel you should use AndroidViewModel (AVM), because it contains the application context. To retrieve the context call getApplication() , otherwise use the regular ViewModel (VM). AndroidViewModel has application context . We all know having static context instance is evil as it can cause memory leaks!! However, having static Application instance is not as bad as you might think because there is only one Application instance in the running application. Therefore, using and having Application instance in a specific class is not a problem in general. But, if an Application instance references them, it is a problem because of the reference cycle problem. See Also about Application Instance AndroidViewModel Problematic for unit tests AVM provides application context which is problematic for unit testing. Unit tests should not deal with any of the Android lifecycle, such as con

Sleep C Code Example

Example 1: sleep in c programming //sleep function provided by <unistd.h> # include <stdio.h> # include <stdlib.h> # include <unistd.h> int main ( ) { printf ( "Sleeping for 5 seconds \n" ) ; sleep ( 5 ) ; printf ( "Wake up \n" ) ; } Example 2: sleep in c++ linux # include <unistd.h> sleep ( 10 ) ; Example 3: how to sleep in c # include <stdio.h> # include <stdlib.h> # include <unistd.h> int main ( ) { printf ( "Sleeping for 5 seconds \n" ) ; sleep ( 5 ) ; printf ( "Sleep is now over \n" ) ; } Example 4: sleep function in c # include <unistd.h> unsigned sleep ( unsigned seconds ) ; Example 5: sleep in c sleep ( 5 ) ; //sleep for 5 secs

Non Pre Emptive Priority Scheduling Program In C Code Example

Example 1: c program to implement non preemptive priority scheduling algorithm # include <stdio.h> int main ( ) { int bt [ 20 ] , p [ 20 ] , wt [ 20 ] , tat [ 20 ] , pr [ 20 ] , i , j , n , total = 0 , pos , temp , avg_wt , avg_tat ; printf ( "Enter Total Number of Process:" ) ; scanf ( "%d" , & n ) ; printf ( "\nEnter Burst Time and Priority\n" ) ; for ( i = 0 ; i < n ; i ++ ) { printf ( "\nP[%d]\n" , i + 1 ) ; printf ( "Burst Time:" ) ; scanf ( "%d" , & bt [ i ] ) ; printf ( "Priority:" ) ; scanf ( "%d" , & pr [ i ] ) ; p [ i ] = i + 1 ; //contains process number } //sorting burst time, priority and process number in ascending order using selection sort for ( i = 0 ; i < n ; i ++ ) { pos = i ; for ( j = i + 1 ; j < n ; j ++ )