Skip to content

Instantly share code, notes, and snippets.

View muhamed-didovic's full-sized avatar
😎

Muhamed muhamed-didovic

😎
View GitHub Profile
@muhamed-didovic
muhamed-didovic / error_blade_directive.php
Created March 29, 2019 12:48 — forked from calebporzio/error_blade_directive.php
A little Blade directive to make working with validation errors a bit nicer.
<?php
// Usage:
// Before
@if ($errors->has('email'))
<span>{{ $errors->first('email') }}</span>
@endif
// After:
@muhamed-didovic
muhamed-didovic / learning_resources.md
Created March 24, 2018 09:26 — forked from nathansmith/web-design-development-learning-resources.md
Resources for learning web design & front-end development
@muhamed-didovic
muhamed-didovic / timestamp.js
Created May 13, 2016 13:40 — forked from hurjas/timestamp.js
Print out a nicely formatted timestamp in JavaScript.
/**
* Return a timestamp with the format "m/d/yy h:MM:ss TT"
* @type {Date}
*/
function timeStamp() {
// Create a date object with the current time
var now = new Date();
// Create an array with the current month, day and time
@muhamed-didovic
muhamed-didovic / longPolling.js
Created February 25, 2016 23:33 — forked from jasdeepkhalsa/longPolling.js
Simple Long Polling Example with JavaScript and jQuery by Tian Davis (@tiandavis) from Techoctave.com (http://techoctave.com/c7/posts/60-simple-long-polling-example-with-javascript-and-jquery)
// Long Polling (Recommened Technique - Creates An Open Connection To Server ∴ Fast)
(function poll(){
$.ajax({ url: "server", success: function(data){
//Update your dashboard gauge
salesGauge.setValue(data.value);
}, dataType: "json", complete: poll, timeout: 30000 });
})();
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management

Here's all you have to do to add clustering to your node.js application.

  • save this code as cluster.js, and run cluster.js instead of server.js (or /bin/www, or whatever it's called for your project)
  • the only line you'll need to change is the last line - it needs to point to the location of your server.js file
var cluster = require('cluster');

if (cluster.isMaster) {
  // Count the machine's CPUs
 var cpuCount = require('os').cpus().length;
var gulp = require('gulp'),
compass = require('gulp-compass'),
gutil = require('gulp-util'),
chalk = require('chalk'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
imagemin = require('gulp-imagemin'),
pngquant = require('imagemin-pngquant'),
elixir = require('laravel-elixir'),
var base_path = __dirname.replace('resources/nodejs', '');
require('dotenv').config({
path: base_path+'.env'
});
var port = process.env.NODE_SERVER_PORT,
redis = require('redis'),
redis_client = redis.createClient(),
cookie = require('cookie'),
os = require('os'),

Note: Some of these shortcuts have been remapped for my own convenience (Preferences->Keymap). These are Mac shortcuts, just use the Windows/Linux equivalent of the Cmd/Option/Ctrl/Del keys.

####Search, Go to, Navigation ####

Cmd + P - Search file

Cmd + Shift + O - Search everywhere

(I swapped the above two recently because I use Cmd + P to search for files most of the time).

alias server='open http://localhost:8000 && python -m SimpleHTTPServer'