Skip to content

Instantly share code, notes, and snippets.

View czmole's full-sized avatar
🚀
Working on a dream

Catalin Zmole czmole

🚀
Working on a dream
View GitHub Profile
@czmole
czmole / covertToHierarchy.php
Created April 21, 2021 14:28 — forked from ubermaniac/covertToHierarchy.php
Convert a DB result of parent/child items into a hierarchical array
<?php
// -- Only one caveat : The results must be ordered so that an item's parent will be processed first.
// -- Simulate a DB result
$results = array();
$results[] = array('id' => 'a', 'parent' => '', 'name' => 'Johnny');
$results[] = array('id' => 'b', 'parent' => 'a', 'name' => 'Bobby');
$results[] = array('id' => 'c', 'parent' => 'b', 'name' => 'Marky');
$results[] = array('id' => 'd', 'parent' => 'a', 'name' => 'Ricky');
@czmole
czmole / upload.js
Created April 1, 2021 12:28 — forked from virolea/upload.js
Tracking file upload progress using axios
upload(files) {
const config = {
onUploadProgress: function(progressEvent) {
var percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total)
console.log(percentCompleted)
}
}
let data = new FormData()
data.append('file', files[0])
@czmole
czmole / README.md
Created January 21, 2021 14:16 — forked from joyrexus/README.md
Vanilla JS equivalents of jQuery methods

Sans jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@czmole
czmole / s3.sh
Created August 1, 2019 13:24 — forked from chrismdp/s3.sh
Uploading to S3 in 18 lines of Shell (used to upload builds for http://soltrader.net)
# You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine
# This is how I upload my new Sol Trader builds (http://soltrader.net)
# Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash
S3KEY="my aws key"
S3SECRET="my aws secret" # pass these in
function putS3
{
path=$1
@czmole
czmole / gist:590f49482d8270bbc7c7d0181a950c7e
Created August 1, 2019 09:33 — forked from adamstac/gist:7462202
Install and configure Sendmail on Ubuntu

Install and configure Sendmail on Ubuntu

This should help you get Sendmail installed with basic configuration on Ubuntu.

  1. If sendmail isn't installed, install it: sudo apt-get install sendmail
  2. Configure /etc/hosts file: nano /etc/hosts
  3. Make sure the line looks like this: 127.0.0.1 localhost yourhostname
  4. Run Sendmail's config and answer 'Y' to everything: sudo sendmailconfig
  5. Restart apache sudo service apache2 restart
@czmole
czmole / nginx-cert.sh
Created July 4, 2019 13:18 — forked from frengky/nginx-cert.sh
Nginx dynamic document root folder and sub-domain configuration
#!/bin/sh
# Self signed certificate for Nginx HTTPS
#
openssl req -x509 -nodes -days 1825 -newkey rsa:2048 -keyout /etc/nginx/ssl/my-domain.key -out /etc/nginx/ssl/my-domain.crt
<html>
<body>
<div id="graph_container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
<script src="socket.io/socket.io.min.js"></script>
<script src="jquery/1.9.1/jquery-1.9.1.js"></script>
<script src="highcharts/js/highcharts.js"></script>
<script>
/*
* Fun with node.js, socket.io and highcharts! The trifecta of javascript libraries :)
* This tutorial is pretty simple yet neat and good for getting your feet wet with some newer
@czmole
czmole / gist:67f43af15d14c2d604cde5e178c57d3f
Created April 11, 2019 08:11
Check TLS version - enforce usage of TLS 1.2
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.howsmyssl.com/a/check");
curl_setopt($ch, CURLOPT_SSLVERSION, 6); // This enforces TLS 1.2
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$tlsVer = json_decode($response, true);
echo "<h1>Your TSL version is: <u>" . ( $tlsVer['tls_version'] ? $tlsVer['tls_version'] : 'no TLS support' ) . "</u></h1>";
@czmole
czmole / gist:545fb67a2532c293d1acd18bf3fb0a11
Created February 6, 2019 15:54 — forked from lttlrck/gist:9628955
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote