Skip to content

Instantly share code, notes, and snippets.

@sanjayabc1234
sanjayabc1234 / pip.md
Created April 29, 2021 05:26 — forked from saurabhshri/pip.md
Install and use pip in a local directory without root/sudo access.

Install and use pip in a local directory without root/sudo access.

Why?

Many users when are given server access, do not have root (or sudo) privileges and can not simply do sudo apt-get install python-pip . Here's an easy way you can install and use pip without root (or sudo) access in a local directory. Note : This works without easy_install too.

How?

emit(name, data) {
if (!this._events[name]) {
throw new Error(`Can't emit an event. Event "${name}" doesn't exits.`);
}
const fireCallbacks = (callback) => {
callback(data);
};
this._events[name].forEach(fireCallbacks);
class MyEventEmitter {
constructor() {
this._events = {};
}
on(name, listener) {
if (!this._events[name]) {
this._events[name] = [];
}
constructor() {
this._events = {};
}
removeListener(name, listenerToRemove) {
if (!this._events[name]) {
throw new Error(`Can't remove a listener. Event "${name}" doesn't exits.`);
}
const filterListeners = (listener) => listener !== listenerToRemove;
this._events[name] = this._events[name].filter(filterListeners);
}
on(name, listener) {
if (!this._events[name]) {
this._events[name] = [];
}
this._events[name].push(listener);
}
@sanjayabc1234
sanjayabc1234 / console.js
Created September 25, 2020 16:47 — forked from stinoga/console.js
Save console output to a file
(function(console){
console.save = function(data, filename){
if(!data) {
console.error('Console.save: No data')
return;
}
if(!filename) filename = 'console.json'