Skip to content

Instantly share code, notes, and snippets.

View nufaylr's full-sized avatar
👋

Nufayl Razick nufaylr

👋
View GitHub Profile
@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 ' );
<?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 / 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) {
@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 / app.js
Created July 15, 2017 10:20 — forked from morontt/app.js
twig.js inline template
var html = twig({ ref: "user-profile" }).render({
list: ["a", "b", "c"]
});
@nufaylr
nufaylr / postgres-cheatsheet.md
Created October 5, 2017 08:37 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@nufaylr
nufaylr / SCSS.md
Created November 15, 2017 18:13 — forked from jareware/SCSS.md
Advanced SCSS, or, 16 cool things you may not have known your stylesheets could do

⇐ back to the gist-blog at jrw.fi

Advanced SCSS

Or, 16 cool things you may not have known your stylesheets could do. I'd rather have kept it to a nice round number like 10, but they just kept coming. Sorry.

I've been using SCSS/SASS for most of my styling work since 2009, and I'm a huge fan of Compass (by the great @chriseppstein). It really helped many of us through the darkest cross-browser crap. Even though browsers are increasingly playing nice with CSS, another problem has become very topical: managing the complexity in stylesheets as our in-browser apps get larger and larger. SCSS is an indispensable tool for dealing with this.

This isn't an introduction to the language by a long shot; many things probably won't make sense unless you have some SCSS under your belt already. That said, if you're not yet comfy with the basics, check out the aweso

@nufaylr
nufaylr / GitCommitEmoji.md
Created March 1, 2018 10:45 — forked from parmentf/GitCommitEmoji.md
Git Commit message Emoji
@nufaylr
nufaylr / iterm2.md
Created June 18, 2018 13:51 — forked from squarism/iterm2.md
iterm2 cheatsheet

Tabs and Windows

Function Shortcut
Fullscreen + Enter
Previous Tab + Left Arrow
Next Tab + Right Arrow
Go to Tab + Number
Go to Window + Option + Number
Go to Split Pane by Direction + Option + Arrow

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name: