Skip to content

Instantly share code, notes, and snippets.

View nufaylr's full-sized avatar
👋

Nufayl Razick nufaylr

👋
View GitHub Profile
@nufaylr
nufaylr / ep_app.js
Created June 1, 2016 09:47 — forked from focusaurus/ep_app.js
Example of how a main express app can mount sub-applications on a mount point with app.use('/mount-point', subapp); If you GET /, you'll see the main_app's '/' response. If you GET /ep_app, you'll see the ep_app's '/' response.
var express = require("express");
var app = express();
app.get('/', function (req, res) {
res.send("This is the '/' route in ep_app");
});
module.exports = app;
@nufaylr
nufaylr / sqlite.js
Last active October 26, 2015 09:52
SQLite with ngCordov Code Examples
angular.module("starter").controller('userController', [ '$rootScope', '$cordovaSQLite'
function( $rootScope, $cordovaSQLite ) {
// Opening the database
$rootScope.db = $cordovaSQLite.openDB({ name: "databaseName.db" });
// Create tabel if not existing
$cordovaSQLite.execute($rootScope.db,
"CREATE TABLE IF NOT EXISTS user_tabel (id integer primary key, user_name text, email text)",
[ "john", "john@who.com" ]).then(function(res) {
<?php
/**
* Convert a multi-dimensional array into a single-dimensional array.
* @author Sean Cannon, LitmusBox.com | seanc@litmusbox.com
* @param array $array The multi-dimensional array.
* @return array
*/
function array_flatten($array) {
if (!is_array($array)) {
@nufaylr
nufaylr / mobileOS
Created July 15, 2014 13:47
get mobile OS and version
function getOSInfo(){
var userOS;
var userOSver;
var ua = navigator.userAgent;
var uaindex;
// determine OS
if ( ua.match(/iPad/i) || ua.match(/iPhone/i) ){
userOS = 'iOS';
uaindex = ua.indexOf( 'OS ' );
@nufaylr
nufaylr / fileTransfer.js
Last active October 13, 2015 08:16 — forked from coryjthompson/0.js
var fileTransfer = new FileTransfer();
fileTransfer.onprogress = function(result){
var percent = result.loaded / result.total * 100;
percent = Math.round(percent);
console.log('Downloaded: ' + percent + '%');
};
fileTransfer.download(remoteFile, localPath, successCallback, errorCallback);
/**
* Prepare the App Folder
*/
(function(){
window.appRootDirName = ".myapp";
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
console.log("device is ready");
window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
/*
* adds "remove" event triggered when a DOMNode is removed,
* allowing to register DOM elements to be removed when a
* given other element is removed from dom.
*
* (last tested with jQuery 1.4.4)
*/
(function($,undefined){
// register node to be removed when the base node is removed
window.requestFileSystem(LocalFileSystem.TEMPORARY, 0, gotFS, fail);
function fail(error) {
console.log(error)
}
function gotFS(fileSystem) {
fileSystem.root.getDirectory("data", {create: true, exclusive: false}, gotDir, fail);
}
@nufaylr
nufaylr / JS utilities
Last active December 21, 2015 22:29
JS utilities
function removeHash(value)
{
if(value != undefined)
{
if(value.indexOf('#') != -1)
{
value = value.split('#');
value = value[1];
return value;
}
@nufaylr
nufaylr / sps-update
Created August 2, 2013 09:30
sp-updatelist
$().SPServices({
operation: "UpdateListItems",
async: false,
batchCmd: "New",
listName: '{FBD720B1-5DBB-4864-930A-5B76FE0C6D51}',
valuepairs: [["Title", title], ["Types", type]],
completefunc: function (xData, Status) {
}
});