Skip to content

Instantly share code, notes, and snippets.

View tojibon's full-sized avatar
:octocat:
Finalizing

Juyal Ahmed tojibon

:octocat:
Finalizing
View GitHub Profile
@tojibon
tojibon / gruntfile.js
Created September 12, 2015 20:21
Concating multiple JS file into a single JS file via Grunt Optional others
module.exports = function(grunt){
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
options: {
seperator: ";",
stripBanners: true,
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' + '<%= grunt.template.today("yyyy-mm-dd") %> */ \n',
},
@tojibon
tojibon / .bowerrc
Created October 3, 2015 14:09
Adding Bower Components / Bootstrap on SailsJS Application
{
"directory": "assets/vendor"
}
@tojibon
tojibon / Vagrantfile
Last active October 8, 2015 09:36
Sailsjs ready Vagrant setup
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
@tojibon
tojibon / vagrant.bat
Created October 8, 2015 05:05
Creating Virtual Machines using Vagrant
visit and install: https://www.vagrantup.com/
visit and install: https://www.virtualbox.org/
CMD:
vagrant -v
mkdir vagrant-centos
cd vagrant-centos
vagrant init osname [image-link from http://www.vagrantbox.es/]
ls
vim Vagrantfile
:wq! [Save and come out]
@tojibon
tojibon / BookingStatus.php
Last active October 15, 2015 20:21
Creating a dropdown lists array by CakePHP Model with virtual fields
<?php
App::uses('AppModel', 'Model');
class BookingStatus extends AppModel {
public $useTable = 'lc_booking_statuses';
public $displayField = 'title';
public $virtualFields = array(
'vtitle' => "CONCAT(UCASE(BookingStatus.status_type), ' / ', BookingStatus.title)"
);
@tojibon
tojibon / sails-dot-tmp.md
Created October 16, 2015 06:01
Sails application run time grunt error .tmp Fix

##Sails application run time grunt error .tmp Fix

When you first time install a sailsjs application in server (My case: Amazon Linux AMI) you may have to face trouble with creating and write permission of .tmp/public directory by grunt.

Here is the steps to fix this issue:

cd /var/www/html/nodejs/codeatomic
sudo mkdir /.tmp
cd /.tmp
@tojibon
tojibon / SessionController.js
Last active October 20, 2015 08:44
SailsJS socket.io JS
/**
* Admin/SessionController
*
* @description :: Server-side logic for managing admin/sessions
* @help :: See http://sailsjs.org/#!/documentation/concepts/Controllers
*/
module.exports = {
'create': function(req, res, next) {
@tojibon
tojibon / ng-controller.js
Last active November 6, 2015 09:22
AngularJS Updating ng-repeat data and firing view Without using ng-service!
io.socket.on('message', function onServerSentEvent (data) {
if(data && data.body) {
$timeout(function(){
$scope.active_conversation_messages.push(data);
$scope.$apply();
}, 2000);
} else {
console.log("There is a problem:", data);
}
});
@tojibon
tojibon / fix.md
Created November 8, 2015 15:10
cURL error 60: SSL certificate problem: unable to get local issuer certificate

Save this file https://gist.github.com/VersatilityWerks/5719158 to a directory like D:\php\cacert.pem Now open and edit php.ini as below:

[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
curl.cainfo = D:\php\cacert.pem

Now save it and restart apache.

@tojibon
tojibon / app.md
Created November 9, 2015 10:39
jQuery Throttling Example

Using jQuery throttle / debounce, you can pass a delay and function to $.throttle to get a new function, that when called repetitively, executes the original function (in the same context and with all arguments passed through) no more than once every delay milliseconds.

Throttle Example

function log( event ) {
  console.log( $(window).scrollTop(), event.timeStamp );
};

// Console logging happens on window scroll, WAAAY more often
// than you want it to.