Skip to content

Instantly share code, notes, and snippets.

View Donmclean's full-sized avatar
🎧
Building a fleet of the world's first AI DJs 👨‍💻

Don Mclean Donmclean

🎧
Building a fleet of the world's first AI DJs 👨‍💻
View GitHub Profile
@Donmclean
Donmclean / Shell_bash-commands.sh
Last active December 16, 2017 21:33
SHELL COMMANDS TO REMEMBER!!!! (BASH)
#SHELL COMMANDS TO REMEMBER!!!! (BASH)
# Find content in files
grep --color -irn CONTENT_STRING PATH //https://www.computerhope.com/unix/ugrep.htm
# Find file on drive
find PATH -name FILENAME
# -i ignore case
# -n add line number to output
@Donmclean
Donmclean / Ruby_quicksort.rb
Created September 19, 2015 13:27
Ruby quicksort code.
# Ruby Quick Sort function
class QuickSort
def self.sort!(keys)
quick(keys,0,keys.size-1)
end
private
def self.quick(keys, left, right)
@Donmclean
Donmclean / Shell_python-simple-server.sh
Last active October 7, 2015 21:27
Run a simple server in your working directory. eg: "python -m SimpleHTTPServer [port]"
python -m SimpleHTTPServer 8000
@Donmclean
Donmclean / Javascript_ISO-date-time-parsing.js
Created September 19, 2015 15:08
This snippet parses Timestamp to readable Date ISO
var startTimeISOString = "2013-03-10T02:00:00Z";
var startTime = new Date(startTimeISOString );
startTime = new Date( startTime.getTime() + ( startTime.getTimezoneOffset() * 60000 ) );
@Donmclean
Donmclean / CSS_select-alter-placeholder-element.css
Created September 19, 2015 15:36
This Code selects and alters html5 Placeholder elements. You can now style them to whatever you want.
::-webkit-input-placeholder { color: #000; font-family: sans-serif; }
::-moz-placeholder { color: #000; font-family: sans-serif; }
:-ms-input-placeholder { color: #000; font-family: sans-serif; }
input:-moz-placeholder { color: #000; font-family: sans-serif; }
.required::-webkit-input-placeholder:after { content: "*"; color: red; }
.required::-moz-placeholder:after { content: "*"; color: red; }
.required:-ms-input-placeholder:after { content: "*"; color: red; }
.requiredinput:-moz-placeholder:after { content: "*"; color: red; }
@Donmclean
Donmclean / angularjs_watch.md
Created September 20, 2015 16:14
using angular js $watch.

You need to be aware about how Angular works in order to understand it.

Digest cycle and $scope

First and foremost, Angular defines a concept of a so called digest cycle. This cycle can be considered as a loop, during which Angular checks if there are any changes to all the variables watched by all the $scopes. So if you have $scope.myVar defined in your controller and this variable was marked for being watched, then you are implicitly telling Angular to monitor the changes on myVar in each iteration of the loop.

A natural follow up question would be: is everything attached to $scope being watched? Fortunately, no. If you would watch for changes to every object in your $scope, then quickly digest loop would take ages to evaluate and you would quickly run into performance issues. That is why Angular team gave us two ways of declaring some $scope variable as being watched (read below).

$watch helps to listen for $scope changes

@Donmclean
Donmclean / Javascript_angular_watch.js
Created September 20, 2015 16:24
Using Angular Watch Function
function MyController($scope) {
$scope.myVar = 1;
$scope.$watch('myVar', function() {
alert('hey, myVar has changed!');
});
$scope.buttonClicked = function() {
$scope.myVar = 2; // This will trigger $watch expression to kick in
@Donmclean
Donmclean / CSS_links.md
Last active September 20, 2015 18:13
CSS Resources Here
@Donmclean
Donmclean / Git_.gitignore.md
Last active September 20, 2015 20:00
.gitignore Resources

Untrack file from Git

Run this code in terminal to remove file that's already tracked by git. (allows .gitignore to do it's job).

git rm --cached [file name goes here]

Add this in .gitignore file