Tuesday, May 5, 2015

Some Git notes from my experiences

BASIC BRANCH COMMANDS

git branch -- lists off all current branches
git brach -- creates a new branch bases upon the currently checkedout branch
git checkout -- switches to that branch name
git branch -d -- deletes a branch by name

To Merge BranchB into BranchA (or master)
1. git checkout BranchA
2. git merge BranchB
3. git branch -d BranchB

CLONE does checkout too
git clone <{name}>

git branch

CHECKS OUT EXISTING BRANCH
git checkout

CREATES A NEW BRANCH AND CHECKS IT OUT
git checkout -b

DELETES A BRANCH
git branch -d

DELETES A BRANCH (forcefully)
git branch -D

DELETE REMOTE BRANCH
git push origin :shopping_cart


MERGES THE INTO CURRENT BRANCH
git merge

MARKING A CONFLICT AS RESOLVED
git add

MAKING A BRANCH FOLLOW (or TRACK) A REMOTE BRANCH
git branch --track branch-name origin/branch-name

DIFF

CodeSchool GitReal DIFF

git diff HEAD^
git diff HEAD^^
git diff HEAD~5
git diff HEAD^^..HEAD

git log --oneline
git log --oneline -p

CodeSchool GitReal DIFF

git rm
git status
git commit -m "stuff"

TO UNTRACK A FILE (only deleted from the repo not from the file system)

git rm --cached development.log

COMMITS

ADDING A COMMIT

git add .
git commit -m "My Message"

SAME AS ABOVE WITH ONE COMMAND

git commit -am "My Message"

APPENDING A COMMIT

git commit --append -am "My Message"


DELETE THE LAST COMMIT (don't do this after a PUSH!!!)

git reset --hard HEAD^
DELETE MORE THAN ONE COMMIT add more ^ to the end


UNDO THE LAST COMMIT BACK INTO STAGE (don't do this after a PUSH!!!)

git reset --soft HEAD^
KINDA LIKE git commit --amend -m "commit message"

BLOWS AWAY ALL CHANGES SINCE LAST COMMIT

git checkout -- file.txt

REMOVING ITEMS FROM THE STAGE


git reset HEAD file.txt

REMOTES

git remote add
git remote rm

LINKING LOCAL BRANCH TO REMOTE BRANCH
git push origin shopping_cart

VIEWING REMOTE BRANCHES
git branch -r

REMOTE SHOW
git remote show origin

DELETE REMOTE BRANCH
git push origin :shopping_cart

CLEANUP STALE BRANCHES
git remote prune
git remote prune origin

TAGS

GETTING CODE FROM A TAG

git checkout

TO CREATE A TAG

git tag -a -m "comment"

TO PUSH A TAG

git push --tags

UNDOING CHANGES

Undoes all changes in current branch
git checkout -- .

Unstage a file
git reset HEAD -- path/filename.ext

Undo a specific file that has been staged
git reset HEAD -- path/filename.ext
git checkout -- path/filename.ext

Undo a specific unstaged file
git checkout -- path/filename.ext
git clean -df path/filename.ext

Undoing an unstaged folder
Just delete the folder from the file structure

Monday, June 18, 2012

Getting an App Access Token using the C# Facebook SDK

Getting an App Access Token using the C# Facebook SDK version 6.0

So there I was trying to figure out how to get the app access token using the C# Facebook SDK. I read about how to get one from Facebook's documentation, but it said something about extracting the value from the query string. But that didn't make too much sense. So I played around with some code and got it to work.


var fb = new Facebook.FacebookClient();

dynamic tokenInfo = 
  fb.Get(
    String.Format(
      "/oauth/access_token?client_id={0}&client_secret={1}&grant_type=client_credentials", 
      appId, 
      appSecret));

var appAccessToken = (string)tokenInfo.access_token;


Yes, that simple. :)

Now with this app access token, I'm able to post on the each user's behalf if they granted me publish stream permissions. But what about if you want to post to a user's page? Well that is something that Facebook didn't make standard.

Here's what Facebook would like you to do.

1. Get a user access token
2. Extend that token to a 60-day token
3. Call /me/accounts and grab the access token from the page

This will be the non-expiring token you can use to publish with to the user's wall.


Happy coding!

Thursday, May 24, 2012

A cypher toes width tune min inning lush woulds flow tuna rounding taryn adds


This one I did quickly so don't punish me!

"A site for those with too many English words floating around in their heads." would translate to "A cypher toes width tune min inning lush woulds flow tuna rounding taryn adds."

For this crazy homophonic fun see: http://www.crockford.com/wrrrld/anguish.html

Some strange sentences!

Just found these sentences (well kinda of in some cases).

My two favorites are the one about Alex Trebek and the one about jukeboxes.

  • DJs flock by when MTV ax quiz prog.
  • Junk MTV quiz graced by fox whelps.
  • Bawds jog, flick quartz, vex nymphs.
  • Waltz, bad nymph, for quick jigs vex!
  • Fox nymphs grab quick-jived waltz.
  • Brick quiz whangs jumpy veldt fox.
  • Bright vixens jump; dozy fowl quack.
  • Quick wafting zephyrs vex bold Jim.
  • Quick zephyrs blow, vexing daft Jim.
  • Sex-charged fop blew my junk TV quiz.
  • How quickly daft jumping zebras vex.
  • Two driven jocks help fax my big quiz.
  • Quick, Baz, get my woven flax jodhpurs!
  • "Now fax quiz Jack! " my brave ghost pled.
  • Five quacking zephyrs jolt my wax bed.
  • Flummoxed by job, kvetching W. zaps Iraq.
  • Cozy sphinx waves quart jug of bad milk.
  • A very bad quack might jinx zippy fowls.
  • Few quips galvanized the mock jury box.
  • Quick brown dogs jump over the lazy fox.
  • The jay, pig, fox, zebra, and my wolves quack!
  • Blowzy red vixens fight for a quick jump.
  • Joaquin Phoenix was gazed by MTV for luck.
  • The quick, brown fox jumps over a lazy dog.
  • A wizard’s job is to vex chumps quickly in fog.
  • Watch "Jeopardy! ", Alex Trebek's fun TV quiz game.
  • Woven silk pyjamas exchanged for blue quartz.
  • Brawny gods just flocked up to quiz and vex him.
  • Adjusting quiver and bow, Zompyc[1] killed the fox.
  • My faxed joke won a pager in the cable TV quiz show.
  • Amazingly few discotheques provide jukeboxes.
  • My girl wove six dozen plaid jackets before she quit.
  • Six big devils from Japan quickly forgot how to waltz.
  • Big July earthquakes confound zany experimental vow.
  • Foxy parsons quiz and cajole the lovably dim wiki-girl.
  • Have a pick: twenty six letters - no forcing a jumbled quiz!
  • Crazy Fredericka bought many very exquisite opal jewels.
  • Sixty zippers were quickly picked from the woven jute bag.
  • A quick movement of the enemy will jeopardize six gunboats.
  • All questions asked by five watch experts amazed the judge.
  • Jack quietly moved up front and seized the big ball of wax.

Can you tell me what these sentences have in common with each other?

Thanks to this lorem ipsum generator tool that led me to this.

Monday, April 23, 2012

12 Miles of Terror! and A MiNi Vacation In Vegas


12 Miles of Terror and AMVIV?

A MiNi Vacation In Vegas (AMVIV) is going to have a fun run to the 12 Miles of Terror in 2012.

The location


Hwy 97 runs between Hwy 93 and Hwy 96 in the western part of Arizona, USA. It's actually just 11 miles long, but 12 sounded more fun when we coined the term.


View Larger Map

Some history


I still remember my first run in my 2003 MINI on that road back in 2003, followed by a MiNi fun-run I organized to incredibly fun (and dangerous as some have found) stretch of pure motoring bliss! It's nice to see both of these events/runs that I started are still going strong.


Here's some threads on some other people organizing their own runs on it after I had introduced them to the 12 miles of terror.


Have fun and be safe everyone!!

Tuesday, April 17, 2012

Facebook login, I don't get session when in IE

The symptoms


I've implemented Facebook login on my website using one of the Facebook Graph API SDKs, all browsers seem to work other than Internet Explorer (IE). In IE, the session doesn't seem to work. Why is that?

The problem


Internet Explorer is very twitchy about storing cookies from 3rd parties. This is what is happening with your site and how Facebook logs in. Since the user is on your domain, IE is simply ignoring your session cookie.

The solution


Simply implement P3P headers in your server's responses. This way IE will think your site is alright and then allow this 3rd party cookie to be stored allowing session to be maintained for the SDK to use.

Here's a couple of articles on how to implement a P3P header.

Happy Coding!

Knowing when someone shared your page

Three major players


I usually focus on the three major players in the social media arena. Facebook, Twitter, and Google+. Sorry to all of the other players like LinkedIn, etc.

How to track who shared your page(s)


On each page where you have the Facebook like, Twitter tweetbox, and Google Plus's +1 button, simply subscribe to the callbacks specific to each environment.




Then in your callback functions, just AJAX whatever you want back to your server for it to store. :)



Happy Coding!