Skip to content

Instantly share code, notes, and snippets.

View j8's full-sized avatar
💭
I may be slow to respond.

genie j8

💭
I may be slow to respond.
View GitHub Profile
@j8
j8 / clear_ie10_localstorage
Created March 27, 2014 12:39
Clear localstorage in IE10+
#Type in the JS console the following:
localStorage.clear();
sessionStorage.clear();
app.filter('bytes', function() {
return function(bytes, precision) {
if (isNaN(parseFloat(bytes)) || !isFinite(bytes)) return '-';
if (typeof precision === 'undefined') precision = 1;
var units = ['bytes', 'kB', 'MB', 'GB', 'TB', 'PB'],
number = Math.floor(Math.log(bytes) / Math.log(1024));
return (bytes / Math.pow(1024, Math.floor(number))).toFixed(precision) + ' ' + units[number];
}
});
@j8
j8 / db.js
Created May 29, 2014 09:48 — forked from anandof28/db.js
var mongoose = require('mongoose')
, Schema = mongoose.Schema;
var CloudSchema = new Schema({
'Cloud_Provider' : {type : String, required : true, trim: true},
'Lat' : {type: Number, required : true},
'Long' : {type: Number, required : true},
'Server_Type' : {type : String, required : true, trim: true},
'Memory' : {type : Number, required : true, trim: true},
[
"Afrikaans",
"Albanian",
"Amharic",
"Arabic",
"Armenian",
"Azerbaijani",
"Bangla",
"Belarusian",
"Berber",
[
{
"id": 1,
"text": "Afrikaans",
"disabled": false
},
{
"id": 2,
"text": "Albanian",
"disabled": false

Adding SFTP-only user to Ubuntu Server

To add a SFTP-only user, you'll need to make sure your SSH config settings are correct, add a new user/group and set permissions for your new user. For step-by-step directions, see below. Omit sudo if you're logged in as root.

Directions

  1. Edit /etc/ssh/sshd_config and make sure to add the following at the end of the file:

     Match group filetransfer
    

ChrootDirectory %h

@j8
j8 / gist:17898a423647669713f6
Created September 21, 2014 23:19
OpenShift existing repo deploy
As you'd do with git in general, the approach to choose here is to clone your other git repo (ex. on bitbucket) to your local machine:
git clone <bitbucket-repo-url>
Your local clone has then your other repo (bitbucket etc.) as remote repo. Your remote repo is stored with the alias "origin" (the default alias used by git if you clone). You then add the openshift repo as remote to your clone. You do that while explicitly using an alias for the remote repo you add - I'm using "openshift" as alias here:
git remote add openshift -f <openshift-git-repo-url>
In order to then be able to push the code from your local git repo to openshift you first have to merge your openshift repo with your local bitbucket clone. You do that by issuing locally:
@j8
j8 / gist:b365ef1507aae5653be7
Created September 21, 2014 23:40
Delete master branch and re-create it from existing branch
git branch -m master master-old # rename master on local
git push origin :master # delete master on remote
git push origin master-old # create master-old on remote
git checkout -b master OTHERBRANCH # create a new local master on top of OTHERBRANCH
git push origin master # create master on remote
@j8
j8 / gist:b76b4fd55dba027f23de
Created September 22, 2014 01:28
Generate CSR code on OpenShift
http://cloudhostingsource.com/setup-ssl-certificate-openshift/
@j8
j8 / OpenShift hot deployment
Created November 16, 2014 11:52
OpenShift update app without restarting
Hot Deployment
Introduction
When the git push command is run to upload code modifications, OpenShift Online stops, builds, deploys, and restarts an application. This entire process takes time to complete and is unnecessary for many types of code changes. With hot deployment the changes to application code are applied without restarting the application cartridge, resulting in increased deployment speed and minimized application downtime.
OpenShift Online provides support for hot deployment through a hot_deploy marker file. If the marker is present, supported application cartridges automatically hot deploy when the git push command is executed.
Enabling and Disabling Hot Deployment
WINDOWS
Enable hot deployment by creating the hot_deploy marker file in the application’s root directory with the following command: