Skip to content

Instantly share code, notes, and snippets.

View w3cj's full-sized avatar
🌱

CJ w3cj

🌱
View GitHub Profile
// Node Constructor function
function Node(value) {
this.value = value;
this.next = null;
}
// A linked list with no name using only nodes
// 23 -> 17 -> 13 -> 42 -> 99
var head = new Node(23);
head.next = new Node(17);
// By Alex https://github.com/AlexVotry
// reverse the string
// temp variable
// split - turns the string into an array
// reverse - built in function on array
// join - turns an array into a string with a given delimiter ''
// compare to original string
// if equal return True else return false

Own your Editor:

A guide to Essential Atom Plugins


Don't work for your editor...


'use strict';
angular
.module('CameraShop')
.factory('CameraService', CameraService);
function CameraService() {
let self = this;
this.cameras = [
{
@w3cj
w3cj / arrow_vs_function_iife.js
Last active May 11, 2016 17:13
When creating an iife, use a function, NOT a fat arrow. With a fat arrow, this is bound to the this of the surrounding code (in this case Window or Global), negating the use of an iife (to prevent polluting global scope).
// When creating an iife, use a function, NOT a fat arrow.
// With a fat arrow, this is bound to the this of the surrounding code (in this case Window or Global).
// Therefore, using a fat arrow negates the use of an iife (to prevent polluting global scope).
(() => {
'use strict';
console.log('fat arrow', this)
})();
@w3cj
w3cj / app.js
Last active May 10, 2016 17:43
When to call $scope.$apply()
angular.module('RedditApp', [])
.controller('RedditController', RedditController);
function RedditController($scope){
// Example of async with jQuery here
// You should really use $http instead which will call $apply for you
$.get('https://www.reddit.com/.json')
.done(function(result){
console.log(result);
$scope.redditPosts = result.data.children;
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Reveal.js</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/reveal.js/3.3.0/css/reveal.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/reveal.js/3.3.0/css/theme/night.min.css" id="theme">
<!-- For syntax highlighting -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.3.0/styles/hybrid.min.css">
@w3cj
w3cj / formatted.html
Last active July 31, 2020 05:35
Make your angular HTML templates more readable. If line gets too long to read, place attributes on new line. For directives such as ng-class and ng-style, indent the object like a proper JSON object.
<!DOCTYPE html>
<html lang="en" ng-app="firstFormValidation" ng-controller="mainController">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
</head>
<body class="container">
<h1>Here are our users

When to use {{}}, {} and neither in Angular attribute directives

AngularJS Docs


{{}}


<!DOCTYPE html>
<html ng-app="TodoApp">
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="https://bootswatch.com/paper/bootstrap.css" media="screen" title="no title" charset="utf-8">
<style media="screen">
.finished {
text-decoration: line-through;
}