Skip to content

Instantly share code, notes, and snippets.

View mekicha's full-sized avatar
🎯
Focusing

Emeka Icha mekicha

🎯
Focusing
  • Sennder GmbH
  • Germany
View GitHub Profile
@mekicha
mekicha / rot13.js
Last active May 9, 2023 09:32
Caesars Cipher FREE CODE CAMP Write a function which takes a ROT13 encoded string as input and returns a decoded string. All letters will be uppercase. Do not transform any non-alphabetic character (i.e. spaces, punctuation), but do pass them on.
function rot13(str) {
var arr = [];
for(var i = 0; i < str.length; i++){
var code = 0;
code = str.charCodeAt(i);
if(code < 65){
arr.push(String.fromCharCode(code));
} else{
code = code + 13;
if(code > 90){
@mekicha
mekicha / destroyer.js
Created July 22, 2016 20:57
FREE CODE CAMP You will be provided with an initial array (the first argument in the destroyer function), followed by one or more arguments. Remove all elements from the initial array that are of the same value as these arguments.
function destroyer(arr) {
// Remove all the values
var args = Array.from(arguments);
args = args.slice(1);
return arr.filter(function(val){
return args.indexOf(val) == -1;
});
}
@mekicha
mekicha / gzip.js
Created May 28, 2017 10:53
Gzip a file. To gzip, pass the filename as an argument.
const fs = require('fs');
const zlib = require('zlib');
const file = process.argv[2];
fs.createReadStream(file)
.pipe(zlib.createGzip())
.pipe(fs.createWriteStream(file + '.gz'));
@mekicha
mekicha / decrypt.js
Created May 28, 2017 10:57
Compress and encrypt the file. To decrypt, see decrypt.js
fs.createReadStream(file)
.pipe(crypto.createDecipher('aes192', 'a_secret'))
.pipe(zlib.createGunzip())
.pipe(reportProgress)
.pipe(fs.createWriteStream(file.slice(0, -3)))
.on('finish', () => console.log('Done'));
@mekicha
mekicha / layout.pug
Last active December 10, 2023 16:59
Add bootstrap and font awesome libraries to a pug project. Add this to your layout.pug file in the views directory, generated by running `express --view=pug`
doctype html
html
head
title= title
link(rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css'
integrity='sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u' crossorigin='anonymous')
link(rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css')
@mekicha
mekicha / ya_layout.pug
Last active December 11, 2017 19:51
Add bootstrap and jquery to a pug/jade project via Yandex CDN
doctype html
html
head
title= title
link(rel='stylesheet' href='https://yastatic.net/bootstrap/3.3.6/css/bootstrap.min.css')
link(rel='stylesheet', href='/stylesheets/style.css')
body
block content
@mekicha
mekicha / Hello_World_with_raw_React_APIs.html
Last active December 19, 2017 13:59
The Beginner's Guide to ReactJS by Kent C. Dodds
<div id="root"></div>
<script src="unpkg.com/react@16.0.0/umd/react.production.min.js"></script>
<script src="unpkg.com/react-dom@16.0.0/umd/react-dom.production.min.js
"></script>
<script type="text/javascript">
// const rootElement = document.getElementById('root');
// const element = document.createElement('div');
// element.textContent = 'Hello World';
// element.className = 'container';
@mekicha
mekicha / gist:c7fae674d073b3395db45a4a67b7670b
Last active December 29, 2017 07:44
psql: could not connect to server: No such file or directory
$ sudo service postgresql start
$ pg_lsclusters
$ sudo pg_ctlcluster 9.6 main start
$sudo rabbitmqctl add_user myuser mypassword
$ sudo rabbitmqctl add_vhost myvhost
$ sudo rabbitmqctl set_user_tags myuser mytag
$ sudo rabbitmqctl set_permissions -p myvhost myuser ".*" ".*" ".*"
@mekicha
mekicha / reverse_it.py
Created January 26, 2018 17:39
A simple python function to reverse a list in place.
def reverse_it(arr):
if not arr:
return
high, low = len(arr) - 1 , 0
while high > low:
arr[low], arr[high] = arr[high], arr[low]
high, low = high - 1, low + 1
@mekicha
mekicha / setup.md
Created February 14, 2018 09:29 — forked from harisibrahimkv/setup.md
Virtualenv, Django & PostgreSQL setup instructions for the Django beginner level workshop.

Setup (Linux)

Virtualenv

It is always recommened to use virtualenv while you are doing development. virtualenv lets you create isolated development environments. It will help you not to mixup dependencies when working on more than one project on your machine.