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 / ubuntu_sublime_text_launcher.txt
Last active May 22, 2021 21:05
Sublime Text 3 Ubuntu Sidebar Icon Launcher
# Create new file trough vim in the following directory
sudo vim /usr/share/applications/sublime.desktop
#Put the following file contents and replace with the path to your Sublime Text
[Desktop Entry]
Version=1.0
Name=Sublime Text 2
# Only KDE 4 seems to use GenericName, so we reuse the KDE strings.
# From Ubuntu's language-pack-kde-XX-base packages, version 9.04-20090413.
GenericName=Text Editor
@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();
@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 / 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: