Skip to content

Instantly share code, notes, and snippets.

View collingo's full-sized avatar

Nick Collings collingo

View GitHub Profile
@collingo
collingo / file1.js
Created February 9, 2012 23:05
Delay removal of splash screen in PhoneGap
// remove splash screen
navigator.splashscreen.hide();
@collingo
collingo / file1.css
Created February 9, 2012 23:09
LESS Transition Mixin
.transition-all (@time: 0.5s, @property: all, @function: ease-in-out) {
-webkit-transition:@property @time @function;
-moz-transition:@property @time @function;
-o-transition:@property @time @function;
transition:@property @time @function;
}
@collingo
collingo / file1.css
Created February 9, 2012 23:14
LESS Animation Mixin
.animate (@name, @duration: 1s, @count: infinite, @direction: normal, @function: ease-in-out) {
-moz-animation-name: @name;
-moz-animation-duration: @duration;
-moz-animation-iteration-count: @count;
-moz-animation-direction: @direction;
-moz-animation-timing-function: @function;
-webkit-animation-name: @name;
-webkit-animation-duration: @duration;
-webkit-animation-iteration-count: @count;
-webkit-animation-direction: @direction;
@collingo
collingo / file1.css
Created February 9, 2012 23:16
LESS Gradient Mixin
.twoStopGrad(@one, @two) {
background: @one; /* Old browsers */
background: -moz-linear-gradient(top, @one 0%, @two 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,@one), color-stop(100%,@two)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, @one 0%,@two 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, @one 0%,@two 100%); /* Opera11.10+ */
background: -ms-linear-gradient(top, @one 0%,@two 100%); /* IE10+ */
filter: ~"progid:DXImageTransform.Microsoft.gradient( startColorstr='@one', endColorstr='@two',GradientType=0 )"; /* IE6-9 */
background: linear-gradient(top, @one 0%,@two 100%); /* W3C */
}
@collingo
collingo / file1.css
Created March 11, 2012 20:24
Touch screen webpage CSS
* {
/* hides the cursor */
cursor:none !important;
/* prevent content selection */
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-o-user-select: none;
@collingo
collingo / file1.js
Created March 11, 2012 20:44
Touch screen InactivityTimer
function InactivityTimer() {
this.timer = 0;
this.threshold = 5000;
window.addEventListener('click', this.resetTimer.bind(this), true); // binding to capture phase
this.startTimer.call(this);
}
InactivityTimer.prototype = {
startTimer: function() {
@collingo
collingo / viewsSolution.js
Created February 26, 2013 11:04
Backbone Month, Week 3, Views - completed code
var TodoListView = Backbone.View.extend({
tagName: "ul",
id: "todolist",
initialize: function() {
_.bindAll(this, "appendTodo");
},
render: function() {
this.$el.empty();
this.collection.each(this.appendTodo);
return this;
@collingo
collingo / modelsSolution.js
Created February 26, 2013 11:06
Backbone Month, Week 1, Models - completed code
var Todo = Backbone.Model.extend({
defaults: {
completed: false,
priority: 0
},
initialize: function() {
this.on('change', function() {
window.changed = true;
});
@collingo
collingo / writeJsonToFile.js
Last active February 2, 2024 13:22
Save pretty printed json to file in node
var outputLocation = require('path').resolve(__dirname, 'file.json');
require('fs').writeFile(outputLocation, JSON.stringify(data, null, 4), function(err) {
if(err) {
console.log(err);
} else {
console.log("JSON saved to "+outputLocation);
}
});
@collingo
collingo / style.scss
Last active December 26, 2015 07:39
Example mapping of preprocessed CSS to semantic HTML
nav#primary {
ul {
li {
a {
&:hover {
}
}
// context
&.home {