Skip to content

Instantly share code, notes, and snippets.

View johannesjo's full-sized avatar
🌈
bam boom bamdadam

Johannes Millan johannesjo

🌈
bam boom bamdadam
View GitHub Profile
@johannesjo
johannesjo / table-to-json.js
Last active December 21, 2022 11:44
Snippet to convert html table to json (to be used with google chrome or similiar)
function tableToJson(table) {
var data = [];
// first row needs to be headers
var headers = [];
for (var i=0; i<table.rows[0].cells.length; i++) {
headers[i] = table.rows[0].cells[i].innerHTML.toLowerCase().replace(/ /gi,'');
}
// go through cells
@johannesjo
johannesjo / get-geo-center.ts
Last active January 19, 2021 15:30
Get the center of two or more geo coordinates
function getGeoCenter(data) {
const coordLength = data.length;
let x = 0;
let y = 0;
let z = 0;
for (const item of data) {
const lat = item.lat * Math.PI / 180;
const lon = item.lng * Math.PI / 180;
@johannesjo
johannesjo / draw-rectangle-here-maps.ts
Created December 8, 2020 13:51
Draw a rectangle in here maps.
const boundingREct = new H.geo.Rect(boundingBox.northEast.lat, boundingBox.northEast.lng, boundingBox.southWest.lat, boundingBox.southWest.lng);
this.map.addObject(
new H.map.Rect(boundingREct, {
style: {
// fillColor: '#FFFFCC',
strokeColor: '#E8FA75',
lineWidth: 2
},
})
);
@johannesjo
johannesjo / pre-push
Last active November 18, 2019 14:32
Prevent git push to master locally
#!/bin/bash
protected_branch='master'
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
if [ $protected_branch = $current_branch ]
then
read -p "You're about to push $protected_branch, is that what you intended? [y|n] " -n 1 -r < /dev/tty
echo
if echo $REPLY | grep -E '^[Yy]$' > /dev/null
@johannesjo
johannesjo / rowMachineCalc
Created April 9, 2015 19:04
A row machine mixin that uses css calc to ease your rowing
@mixin rowMachineCalc($numPerRow, $margin) {
@include clearfix();
display: block;
> * {
width: calc(#{(100% / $numPerRow)} - #{(($numPerRow - 1) * $margin)/$numPerRow});
float: left;
&:nth-child(n) {
margin-bottom: $margin;
margin-right: $margin;
}
Inorder to change default document root for a domain hosted in a plesk control panel we need to create vhost.conf file in the directory in which http.include for the domain resides. Directly changing the document root entry in httpd.include causes the modification to be overwritten with default entry since plesk overwrites entries in configuration files with database entries
Entries to be put in the vhost.conf follows
DocumentRoot /path/to/your/new/root
<Directory /path/to/your/new/root>
# Put this if you really need all options?
Options Indexes ExecCGI FollowSymLinks MultiViews
AddHandler cgi-script .cgi
# are you using .htaccess files? if not, set it from all to none
AllowOverride all