Skip to content

Instantly share code, notes, and snippets.

View minmaxdata's full-sized avatar
🐕

Ke McAdams minmaxdata

🐕
  • DTN
  • Seattle, WA
View GitHub Profile
// ************************************************************************************************
// What Javascript methods would convert the string "20" to an integer (on the fly) so "20" + 20 = 40?
"20"+20 = "2020"
parseInt('20') + 20;
"20"*1
+"20"+20
Douglas Crockford has been teaching a useful singleton pattern for achieving this discipline, and I thought his pattern might be of interest to those of you building on top of YUI. Douglas calls this the “module pattern.” Here’s how it works:
1. Create a namespace object: If you’re using YUI, you can use the YAHOO.namespace() method:
YAHOO.namespace("myProject");
This assigns an empty object myProject as a member of YAHOO (but doesn’t overwrite myProject if it already exists). Now we can begin adding members to YAHOO.myProject.
2. Assign the return value of an anonymous function to your namespace object:
YAHOO.myProject.myModule = function () {
An understanding of algorithms is necessary to pass interviews and write scalable code.
Work on programming projects, the larger the better.
Get your code reviewed by others, the more experienced the better.
Become very good at one programming language. If it's Java, study Effective Java. For C++, Effective C++ and its sequel, etc.
Take a Programming Languages course to get exposed to different programming paradigms. Ideas will carry over. (Google's map-reduce came from the Lisp world.)
Learn about the memory hierarchy, from registers to secondary storage, and how to optimize performance.
Learn about concurrency and synchronization.
Study an interview prep book, such as Programming Interviews Exposed orCracking the Coding Interview.
When you apply, especially if you're not from a top 5 school, find a Google/FB employee who can refer you. That gets you to the top of the stack, and that person will be motivated to help you, including making sure you don't get lost in the shuffle. Don't apply through the
// Readable javascript...
for (var i = 1; i <= 100; i++) {
var isDividibleByThree = i % 3 === 0;
var isDivisibleByFive = i % 5 === 0;
if (isDividibleByThree && isDivisibleByFive) {
console.log('FizzBuzz');
}
else if (isDividibleByThree) {
console.log('Fizz');
<div ng-repeat="roleFeature in (sortedRoles = (item.role.roleFeatures | orderBy: 'feature.featureCategory.name'))">
<div class="privilegesRoleFeatures">
<div class="profile-hd" ng-if="(sortedRoles[$index].feature.featureCategory.id !== sortedRoles[$index -1].feature.featureCategory.id) && sortedRoles[$index].feature.featureCategory.id != 1" ng-bind="roleFeature.feature.featureCategory.name"></div>
<div class="privilegesFeatureName" ng-bind="roleFeature.feature.name"></div>
</div>
</div>
@minmaxdata
minmaxdata / SpreadOperator.js
Created April 3, 2018 20:34 — forked from iHani/SpreadOperator.js
Spread Operator
/*
* Array spread operator
*/
const arr = [1, 3, 5]
arr.concat(7)
// [1, 3, 5, 7] // returns a new array, doesn't change arr
arr.push(11)
// [1, 3, 5, 11] // actually changes arr
@minmaxdata
minmaxdata / settingstate.js
Created August 4, 2018 22:13
different ways to set state
this.setState(state => {
showAnswer: !state.showAnswer
})
this.setState(state => ({
showAnswer: !state.showAnswer
}))
this.setState(state => {
return { ...state,
showAnswer: !state.showAnswer };
});
@minmaxdata
minmaxdata / spread.js
Last active August 4, 2018 22:38
examples of the use of the spread operator
case TOGGLE_TWEET:
return {
...state,
[action.id]: {
...state[action.id],
likes: action.hasLiked === true
? state[action.id].likes.filter( (uid) => uid !== action.authedUser )
: state[action.id].likes.concat([action.authedUser])
}
}
@minmaxdata
minmaxdata / alert.js
Created August 4, 2018 22:19
ReactAlertExample
onPressHandle() {
Alert.alert(
'Alert Title',
'My Alert Msg',
[
{
text: 'Ask me later',
onPress: () => console.log('Ask me later pressed')
},
@minmaxdata
minmaxdata / arraymap.js
Last active August 4, 2018 22:37
An example using array .map()
{questions.map((question, index) => (
<Card
key={index}
question={question.question}
answer={question.answer}
index={index}
/>
))}
{Object.keys(decks).map(key => {