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 / 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: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:

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

[
{
"id": 1,
"text": "Afrikaans",
"disabled": false
},
{
"id": 2,
"text": "Albanian",
"disabled": false
[
"Afrikaans",
"Albanian",
"Amharic",
"Arabic",
"Armenian",
"Azerbaijani",
"Bangla",
"Belarusian",
"Berber",
@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},
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 / clear_ie10_localstorage
Created March 27, 2014 12:39
Clear localstorage in IE10+
#Type in the JS console the following:
localStorage.clear();
sessionStorage.clear();
@j8
j8 / git_empty_branch
Created February 14, 2014 08:32
Create new branch with empty folder structure
You can create a new empty branch like this:
$ git checkout --orphan NEWBRANCH
--orphan creates a new branch, but it starts without any commit. After running the above command you are on a new branch "NEWBRANCH", and the first commit you create from this state will start a new history without any ancestry.
The --orphan command keeps the index and the working tree files intact in order to make it convenient for creating a new history whose trees resemble the ones from the original branch.
Since you want to create a new empty branch that has nothing to do with the original branch, you can delete all files in the new working directory:
@j8
j8 / Auto rotation slider
Last active December 19, 2015 15:09
Auto rotation slider
// Front page slider
$(document).ready(function() {
$('ul#frontpageslider li a').click(function(e) {
var headingAppending = $(this).children('.headingToMove').text();
var textAppending = $(this).children('.firstCharsToMove').html();
var imageAppending = $(this).children('.newsImageToMove').html();
var linkAppending = $(this).children('.linkToMove').text();