To get the last characters of a string in Ruby, use the following instructions. If the string is shorter than the selected number of characters, the entire string is returned. a = ‘12345’ b = a[-3..-1] || a puts b Returns 345
Category Archives: Software Development
Permission denied message when you try to upload your new repository to GitHub from a Windows computer
If you work on a Windows computer and create a new GitHub repository, you can copy the code from the GitHub page to set the remote address and push the existing code to the GitHub server. You may get the following error message: $ git push -u origin master Permission denied (publickey). fatal: Could not …
Git configuration
If you use 2-factor authentication in GitHub, generate a 40 character Personal Access Token that you can use as a password to access GitHub repositories. Create a Personal Access Token to use it as password in the Git client Log into GitHub and in the pull down at the upper right select Settings, On the left …
Disable database triggers in Microsoft SQL databases
If you need to temporarily disable triggers in Microsoft SQL databases during database maintenance use the following script –Disable triggers on all tables DECLARE @enable BIT = 0; DECLARE @trigger SYSNAME; DECLARE @table SYSNAME; DECLARE @cmd NVARCHAR(MAX); DECLARE trigger_cursor CURSOR FOR SELECT trigger_object.name trigger_name, table_object.name table_name FROM sysobjects trigger_object JOIN sysobjects table_object ON trigger_object.parent_obj = …
Continue reading “Disable database triggers in Microsoft SQL databases”
Disable foreign key constraints in Microsoft SQL databases
Databases do not allow the deletion of rows if those are referenced in other tables with the foreign key constraint. You can turn off the validation of foreign keys in Microsoft SQL databases for the duration of the maintenance with the following script. –Disable foreign keys on all tables DECLARE @table_name SYSNAME; DECLARE @cmd NVARCHAR(MAX); …
Continue reading “Disable foreign key constraints in Microsoft SQL databases”
Display the branch structure and other important events in the Git command line interface
To set up the display of the branch structure, tags and pulls in the command line interface first create the following “alias” git config –global alias.lgb “log –graph –pretty=format:’%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset%n’ –abbrev-commit –date=relative –branches” To display the branch structure, execute the following “alias” git lgb This will execute the above defined “alias” …
Include PBD files in ClickOnce deployment to show the line numbers in the Stack Trace
If there is an error in an application, the line numbers are only included in the Stack Trace when the PBD files are also in the application directory. To include the PBD files in an application that was distributed with ClickOnce deployment you need to: Right click the main project and select Properties On the …
Branching and merging in Git
Branching and Merging are very powerful features in Git. There are may branching strategies, my favorite is well explained at http://nvie.com/posts/a-successful-git-branching-model/ Pick any model you like and stick to it for a while to better understand and evaluate it. If you do not like that try another one. In this model when we start to …
Merging in Git with four panels in Windows
Git is a great repository for small and large projects. It is easy to create and merge branches to separate code for the features you work on. To make merging easier you can use a free 4 panel merging tool, Perforce P4Merge. Download Download the Perforce P4Merge Visual Merge Tool from https://www.perforce.com/downloads/integrations Select the operating …
Continue reading “Merging in Git with four panels in Windows”
How to delete a folder from Git, but not from the local disk
I have accidentally included a folder in my Git repository, that I don’t want to include in source control. I wanted to remove it from the Git index, but not from the local hard drive. The solution is the following command git rm -r –cached myFolder If the folder name contains spaces enclose it in …
Continue reading “How to delete a folder from Git, but not from the local disk”