$ docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
##Device = Desktops | |
##Screen = 1281px to higher resolution desktops | |
*/ | |
@media (min-width: 1281px) { | |
//CSS | |
Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt
If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a
I will be using the root user, but would suggest creating a new user
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers; | |
use Laravel\Lumen\Routing\Controller as BaseController; | |
class Controller extends BaseController | |
{ | |
public function __construct() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upload(files) { | |
const config = { | |
onUploadProgress: function(progressEvent) { | |
var percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total) | |
console.log(percentCompleted) | |
} | |
} | |
let data = new FormData() | |
data.append('file', files[0]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var CryptoJS = require('crypto-js'); | |
function uploadImage(uri) { | |
let timestamp = (Date.now() / 1000 | 0).toString(); | |
let api_key = 'your api key' | |
let api_secret = 'your api secret' | |
let cloud = 'your cloud name' | |
let hash_string = 'timestamp=' + timestamp + api_secret | |
let signature = CryptoJS.SHA1(hash_string).toString(); | |
let upload_url = 'https://api.cloudinary.com/v1_1/' + cloud + '/image/upload' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//How to use it | |
//Just call timthumb.php with appropriate arguments, For example: | |
<img src="/script/timthumb.php?src=/some/path/myimage.png&w=100&h=80" alt="resized image" /> | |
/* http://viralpatel.net/blogs/resize-image-dynamically-php/ */ | |
?> |
Here's all you have to do to add clustering to your node.js application.
- save this code as
cluster.js
, and runcluster.js
instead ofserver.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;
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Summary: Useful Kubectl commands for deploying & managing apps in a Kubernetes cluster (Minikube as example) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Money Formatting | |
Number.prototype.formatMoney = function (c, d, t) { | |
var n = this, | |
c = isNaN(c = Math.abs(c)) ? 2 : c, | |
d = d == undefined ? "," : d, | |
t = t == undefined ? "." : t, | |
s = n < 0 ? "-" : "", | |
i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", | |
j = (j = i.length) > 3 ? j % 3 : 0; | |
return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : ""); |
OlderNewer