Skip to content

Instantly share code, notes, and snippets.

View k0d3d's full-sized avatar
🎯
Focusing

Rhema k0d3d

🎯
Focusing
View GitHub Profile
@k0d3d
k0d3d / appCtrl.jade
Last active August 29, 2015 14:04
Simple Angular JS Paging / Pagination Directive
// this is an example . A simple function that
// calls a service that loads users from an ajax source
//@params {Number} page the number of the page to load
//@param {Number} limit the amount of items / results to load
//@param {Function} cb a callback function that gets called when
// and if results are returned.
$scope.load_users = function (page, limit, cb) {
adminService.loadUsers({
page: page,
<!DOCTYPE html>
<html>
<head>
<title></title>
<script type="text/javascript" src="angular.min.js"></script>
<script type="text/javascript" src="angular-ui-router.js"></script>
</head>
<body>
<nav id="mainmenu" class="mainmenu" ng-app="demoApp">
@k0d3d
k0d3d / File.js
Last active August 29, 2015 14:17
The first code snippet is from: /plugins/org.apache.cordova.file/www/File.js
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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
*
@k0d3d
k0d3d / app.html
Created August 17, 2015 02:19
Step 1, OfflineApps
<body ng-app="offline-app">
//include pouchdb js file
<script src="js/pouchdb.js"></script>
//bootstrap your angularjs main module
<script>
var app = angular.module('offlineApp', []);
app.factory('PouchDB', [function () {
return new PouchDB('offline');
}]);
@k0d3d
k0d3d / appdb.js
Created August 17, 2015 02:26
the Service
app.factory('appDBBridge', [
'$q',
'$injector',
'PouchDB',
function (Q, $injector, PouchDB) {
return {
/**
* returns a document saved in the db
* @param {[type]} query [description]
* @param {[type]} collectionName Usually a string which should be a dot-notation representation
@k0d3d
k0d3d / app.js
Last active August 29, 2015 14:27
sample service
//app.config(function($stateProvider, $urlRouterProvider.......
//........
.state('files', {
url: '/files',
views: {
//adapt to fit your application
'cabinetContent' :{
templateUrl: 'templates/files.html',
controller: 'FilerCtrl',
resolve: {
@k0d3d
k0d3d / index.html
Last active December 10, 2015 21:11
<!DOCTYPE html>
<html>
<head>
<title>Lean Canvas by Koded</title>
<link rel="stylesheet" type="text/css" href="semantic.min.css">
<script type="text/javascript" src="bower_components/angular/angular.min.js"></script>
<script type="text/javascript" src="semantic.min.js"></script>
</head>
<body>
<div class="ui stackable celled grid container">
<ul>
<li ng-repeat="place in places_list">
<span city-state="place">
{{place.formatted_address}}
</span>
</li>
</ul>
@k0d3d
k0d3d / maps.js
Last active December 18, 2015 14:26
var MapApp = angular.module('GoogleMapsInitializer', []);
MapApp.factory('Initializer', function($window, $q){
//Google's url for async maps initialization accepting callback function
var asyncUrl = 'https://maps.googleapis.com/maps/api/js?key=AIzaSyCOt9IYHpYN22m7alw_HKi5y5WBgu57p4s&v=3.exp&sensor=true&callback=googleMapsInitialized',
mapsDefer = $q.defer();
function init () {
var gMapsLoader = $.getScript(asyncUrl);
gMapsLoader.fail(function (err) {
@k0d3d
k0d3d / coditlity.js
Last active December 31, 2015 01:59
function getRandomArbitrary(min, max) {
return Math.random() * (max - min) + min;
}
function solution(A, B) {
var startA = 0;
var startB = 0;
var a_move = 0;
while (startA <= A && startB <= B) {
//add our steps
startA += Math.round(getRandomArbitrary(1,2));