Skip to content

Instantly share code, notes, and snippets.

View danielchikaka's full-sized avatar

Daniel Chikaka danielchikaka

View GitHub Profile
@danielchikaka
danielchikaka / jquery-element-visible
Created February 20, 2015 10:26
This gist will help detect if an element is visible on the viewport. For example, if the footer is visible, do something ...
$.fn.is_on_screen = function(){
var win = $(window);
var viewport = {
top : win.scrollTop(),
left : win.scrollLeft()
};
viewport.right = viewport.left + win.width();
viewport.bottom = viewport.top + win.height();
Function.prototype.compose = function(argFunction) {
var invokingFunction = this;
return function() {
return invokingFunction.call(this, argFunction.apply(this,arguments));
}
}
@danielchikaka
danielchikaka / angular-remove-white-space-filter.js
Last active August 29, 2015 14:25 — forked from builtbylane/angular-remove-white-space-filter.js
AngularJS – filter: removes white space from text. useful for html values that cannot have spaces
/**
* Description:
* removes white space from text. useful for html values that cannot have spaces
* Usage:
* {{some_text | nospace}}
*/
app.filter('nospace', function () {
return function (value) {
return (!value) ? '' : value.replace(/ /g, '');
function toCurrency(price) {
return price.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
@danielchikaka
danielchikaka / 01_Laravel 5 Simple ACL manager_Readme.md
Created March 8, 2016 07:01 — forked from amochohan/01_Laravel 5 Simple ACL manager_Readme.md
Laravel 5 Simple ACL - Protect routes by an account / role type

#Laravel 5 Simple ACL manager

Protect your routes with user roles. Simply add a 'role_id' to the User model, install the roles table and seed if you need some example roles to get going.

If the user has a 'Root' role, then they can perform any actions.

Installation

Simply copy the files across into the appropriate directories, and register the middleware in App\Http\Kernel.php

@danielchikaka
danielchikaka / post.md
Created June 7, 2016 08:39 — forked from kbond/post.md
Ubuntu LAMP Development Environment Setup

Install git:

sudo apt-get install git

Configure Git:

touch ~/.gitignore_global
git config --global core.excludesfile ~/.gitignore_global
git config --global user.name "Your Name"

git config --global user.email "Your Email"

@danielchikaka
danielchikaka / laravel-query-many-to-many-relationship.md
Created June 15, 2017 07:44 — forked from aquasmit/laravel-query-many-to-many-relationship.md
Laravel - Eloquent - query many to many relationship

Laravel - Eloquent - query many to many relationship

Example:

Table 1: posts

Table 2: categories

Pivot Table: category_post with foreign keys category_id, post_id

@danielchikaka
danielchikaka / global-variables-are-bad.js
Created August 2, 2017 05:18 — forked from hallettj/global-variables-are-bad.js
How and why to avoid global variables in JavaScript
// It is important to declare your variables.
(function() {
var foo = 'Hello, world!';
print(foo); //=> Hello, world!
})();
// Because if you don't, the become global variables.
(function() {
@danielchikaka
danielchikaka / jsbin.gewozekoxi.js
Last active January 17, 2018 08:47
Getting Date and Time source https://jsbin.com/gewozekoxi
function todayDate(){
var day;
switch(new Date().getDay()){
case 0:
day = "Sunday";
break;
case 1:
day = "Monday";
break;
case 2:
var defaults = {
number: 1,
bool: true,
magic: 'real',
animal: 'whale',
croutons: 'delicious'
};
var options = {
number: 2,