Skip to content

Instantly share code, notes, and snippets.

View Teino1978-Corp's full-sized avatar

Teino Boswell Teino1978-Corp

  • Ocho Rios, Jamaica
View GitHub Profile
# Copyright 2011 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@Teino1978-Corp
Teino1978-Corp / entry.js
Created November 23, 2015 04:38
webpack intro
var webpack = require('webpack');
module.exports = {
entry: {
app: './entry.js'
},
output: {
path: __dirname,
publicPath: '/assets/',
filename: "[name].bundle.js"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><title>Static Positioning</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body class="element">
<ul>
<li data-selector="element" class="selected">h2</li>
# Copyright 2011 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@Teino1978-Corp
Teino1978-Corp / SortClass.m
Created November 23, 2015 01:53
Sort array class
+ (NSArray *) sortArray: (NSArray *) sortingArray withValuesInArray: (NSArray *) sorterArray{
//We will create a NSDictionary using the second array as keys and the first array as values
NSDictionary *sortingDictionary = [NSDictionary dictionaryWithObjects:sorterArray forKeys:sortingArray];
//Then we just create a new array sorted by the keys of the dictionary
NSArray *sortedArray = [sortingDictionary keysSortedByValueUsingComparator: ^(id value1, id value2) {
NSInteger number1 = [value1 integerValue];
NSInteger number2 = [value2 integerValue];
if (number1 > number2) {
@Teino1978-Corp
Teino1978-Corp / All about Javascript Object Creation
Created November 23, 2015 01:03
Different ways to create javascript object
// Each of the following options will create a new empty object:
var newObject = {}; // or
var newObject = Object.create(null); // or
var newObject = new Object();
// four ways in which keys and values can then be assigned to an object
// ECMAScript 3 compatible approaches
// 1. Dot syntax
newObject.someKey = 'Hello World'; // Write properties
@Teino1978-Corp
Teino1978-Corp / chaining.js
Created November 22, 2015 21:34
javascript: Chaining Pattern and Java-like Class method adding
/**
* Constants Construction
* @description 可以直接用全大寫的naming convention來模擬,此處實際建立一個指定常數的實作
* @return {[type]} [description]
*/
// Using naming convention directly
var Widget = function() {
// implement......
};
// HTML5 DOCTYPE
<!DOCTYPE html>
<html>
....
@Teino1978-Corp
Teino1978-Corp / Synchronize.js
Created November 22, 2015 18:57
Javascript data synchronization
/**
Used to synchronize multiple types of storage and their timestamps.
options{
data : {}, the state that all storage should take.
date: int, the modified date that all storage should take
interval : int, sync interval in milliseconds.
callbacks : [], an ARRAY of callback functions which are to each be executed with data
and date as params. Each callback should be used to update a single storage medium.
}
@Teino1978-Corp
Teino1978-Corp / app.js
Created November 22, 2015 18:30
Bootstrap Modal with Remote Source
$(document).ready(function() {
$(document).on('.ajaxModal', 'click', function(event) {
$.get($(this).attr('href'), function(response) {
$('<div class="modal hide fade">' + response + '</div>').modal();
});
event.preventDefault();
});
});