Friday, November 10, 2017

Install Packages with Homebrew for OS X

homebrew and homebrew cask header
Homebrew is the most popular package manager for Mac OS X. Homebrew Cask extends Homebrew with support for quickly installing Mac applications like Google Chrome, VLC, and more. No more dragging and dropping applications!
This is an easy way to install Mac terminal utilities and graphical apps. It’s a bit like Chocolatey or OneGet on Windows, or the package managers included with Linux. It’s even a way to install many of the useful apps that aren’t in the Mac App Store.

The Basics

Homebrew is a package manager designed for installing UNIX tools and other open-source applications on Mac OS X. It will quickly download and install them, compiling them from source. Homebrew Cask extends Homebrew with support for installing binary apps — the kind you normally drag to your Applications folder from DMG files.

Install Homebrew and Homebrew Cask

First, you’ll need the command-line tools for Xcode installed. On a modern Mac OS X system, you can install these just by running the following command in a Terminal window. You could also install the full Xcode application from Apple, if you prefer — but that takes up more space on your Mac and isn’t necessary.
xcode-select --install
xcode-select install
Next, install Homebrew. You can just open a Terminal window, copy-paste the following command, and press Enter:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
This script informs you what it will do. Press Enter and then provide your password to install it. By default, it installs Homebrew so you can use the brew command without typing the sudo command and providing your password.
install homebrew
Run the following command once you’re done to ensure Homebrew is installed and working properly:
brew doctor
brew doctor
Once you’re done, run the following command to install Homebrew Cask. It uses Homebrew to install Cask:
brew install caskroom/cask/brew-cask
install homebrew cask

Install Graphical Apps With Homebrew Cask

Now you can get started installing those graphical apps you want. This involves some very simple commands. To search for one, use the following command:
brew cask search name
To install an app, run the following command. Homebrew Cask will automatically download it, extract the app, and install it to your Applications folder.
brew cask install name
To uninstall an app with Homebrew Cask, run the following command:
brew cask uninstall name
homebrew cask search install

Install Open-source Utilities With Homebrew

The Homebrew command is the underlying package manager that installs all those UNIX and open-source utilities you might want. It’s the easiest way to install them on Mac OS X, just as it is on Linux. Like Homebrew Cask, it uses simple commands.
To search for a utility:
brew search name
To download and install that package:
brew install name
To remove that package from your system later:
brew remove name
install with homebrew
For more details on using these commands, read the Homebrew Cask Usage guide or the Homebrew brew command manual on their official websites. Not every graphical application or Unix utility you’re looking for will be available, but most of them probably will be.

Unfortunately, there’s no graphical user interface for Homebrew Cask. This is a shame, because — while we geeks love easy terminal utilities — many people could benefit from easy software installation on Mac OS X. They can avoid all the downloading DMG files and clicking around. And, since Mac OS X is now home to Windows-style installer crapware, Homebrew Cask is a way around that.

Friday, September 8, 2017

Basic Git Commands

Git task
NotesGit commands
Tell Git who you areConfigure the author name and email address to be used with your commits.
Note that Git strips some characters(for example trailing periods) from user.name.
git config --global user.name "Sam Smith"
git config --global user.email sam@example.com
Create a new local repository
git init
Check out a repositoryCreate a working copy of a local repository:
git clone /path/to/repository
For a remote server, use:
git clone username@host:/path/to/repository
Add filesAdd one or more files to staging (index):
git add <filename>

git add *
CommitCommit changes to head (but not yet to the remote repository):
git commit -m "Commit message"
Commit any files you've added with git add, and also commit any files you've changed since then:
git commit -a
PushSend changes to the master branch of your remote repository:
git push origin master
StatusList the files you've changed and those you still need to add or commit:
git status
Connect to a remote repositoryIf you haven't connected your local repository to a remote server, add the server to be able to push to it:git remote add origin <server>
List all currently configured remote repositories:git remote -v
BranchesCreate a new branch and switch to it:
git checkout -b <branchname>
Switch from one branch to another:
git checkout <branchname>
List all the branches in your repo, and also tell you what branch you're currently in:
git branch
Delete the feature branch:
git branch -d <branchname>
Push the branch to your remote repository, so others can use it:
git push origin <branchname>
Push all branches to your remote repository:
git push --all origin
Delete a branch on your remote repository:
git push origin :<branchname>
Update from the remote repositoryFetch and merge changes on the remote server to your working directory:git pull
To merge a different branch into your active branch:
git merge <branchname>
View all the merge conflicts:
View the conflicts against the base file:
Preview changes, before merging:
git diff
git diff --base <filename>
git diff <sourcebranch> <targetbranch>
After you have manually resolved any conflicts, you mark the changed file:
git add <filename>
TagsYou can use tagging to mark a significant changeset, such as a release:
git tag 1.0.0 <commitID>
CommitId is the leading characters of the changeset ID, up to 10, but must be unique. Get the ID using:
git log
Push all tags to remote repository:
git push --tags origin
Undo local changesIf you mess up, you can replace the changes in your working tree with the last content in head:
Changes already added to the index, as well as new files, will be kept.
git checkout -- <filename>
Instead, to drop all your local changes and commits, fetch the latest history from the server and point your local master branch at it, do this:
git fetch origin

git reset --hard origin/master
SearchSearch the working directory for foo():git grep "foo()"


If you don't care about any local changes (including untracked or generated files or subrepositories which just happen to be here) and just want a copy from the repo:
git reset --hard HEAD
git clean -xffd
git pull

Sunday, July 30, 2017

How to update Ionic 2 cli and libraries

The old version of Ionic had the straightforward update tool, it was enough just to run ionic lib update and it was just done. But this method no more works With Ionic 2.
Learn how to update the Ionic 2 cli and libraries.
First of all, we’ll need to upgrade the cli, it’s easy:
Than we need to get the newer package versions (with already resolved dependencies) with a simple command:
It will return list like the following:
Now you’ll need to open your package.json file (in the project root) with your favorite editor and change the package versions as in the ‘Latest’ column of output.
Than everything you’ll need to do, is just to run:

Saturday, June 24, 2017

Using Storage in Ionic 3

Ionic’s LocalStorage is now called simply Storage in Ionic 3 and behind the scenes Storage decides the best method to store the data. On mobile phones for example, SQLite is the preferred storage method. IndexedDB, WebSQL or localstorage is used in browsers for Progressive Web Apps.


InstallationFirst, install the SQLite Cordova plugin with this command:$ cordova plugin add cordova-sqlite-storage --save


Then install Storage. You can skip this step if you’re using a version or Ionic 3 greater than RC0, because Storage is now included automatically: $ npm install --save @ionic/storage


Importing + InjectingImport it in the appropriate module, the app root module for example:Module: app.module.tsimport { Storage } from '@ionic/storage'; @NgModule({ ... providers: [ Storage ] }) @NgModule({ ... providers: [ Storage ]})@NgModule({ ... providers: [ Storage ]})@NgModule({ ... providers: [ Storage ]})


Then inject it in the components that need it:Component: team.tsimport { Storage } from '@ionic/storage'; export class TeamPage {  constructor(public navCtrl: NavController, public storage: Storage) { }


UsageNow you’re ready to start using Storage’s set, get and remove methods. Let’s use a simple example where we have three methods, one that sets a team as a favorite, one that removes the team from the favorites and one that checks if a team is a favorite:Component: team.ts


fav() { this.storage.set(`team ${ this.teamId }`, this.teamName);
this.favorite = true; }
removeFav() { this.storage.remove(`team ${ this.teamId }`); this.favorite = false; }
isFav() { this.storage.get('team ' + this.teamId).then((value) => { value ? this.favorite = true : this.favorite = false

}).catch(() => this.favorite = false); }In that example, the isFav method can be used in the ionViewWillEnter page lifecycle hook to determine if a team is already a favorite. 


 

Monday, May 8, 2017

Send Email Directly to a Folder (Label) in Gmail

Here are the steps to set this up:
1. Log in to your gMail account

2. Create a new label. Call it whatever you like. Note: use an underscore instead of a space when naming your labels. This label will be listed on the left-hand side of your window.
3. Now Create a filter by clicking on Settings, then on Filters
4. Place your cursor in the input box labeled To: and type in gmail_username+label@gmail.com where gmail_username is your GMail username. For instance JohnDoe+Neat_Stuff@gmail.com. Then click next.
5. Now check Apply the label and choose Neat_Stuff or whatever you named your label.
6. Check Skip the inbox to automatically send the message to that label instead of your main inbox.
7. Finally Click Create filter and you’re ready to go!


Optional Step:
8. I found that by adding the email address to my personal contact on my phone has made this even easier. Go to your specific contact in the contacts on your phone and add an additional email address to that contact that looks like this:
gmail_username+label@gmail.com
changing the default to whatever your username and label are. That way when you find something you want to forward to your email, you can start typing your email address in the To: field and the tweaked email address will show up as an option.