Skip to content

Instantly share code, notes, and snippets.

@aonurdemir
aonurdemir / spark master refresher.js
Created July 26, 2024 07:42
Spark Master Refresher
// Add the progress output div to the top of the body
const progressOutputDiv = document.createElement('div');
progressOutputDiv.id = 'progress-output';
document.body.insertBefore(progressOutputDiv, document.body.firstChild);
// Add CSS to position the output div to the right
const style = document.createElement('style');
style.innerHTML = `
#progress-output {
margin-left: auto;
@aonurdemir
aonurdemir / gist:b58171094f7bc3872b17d225c285bfe7
Created February 13, 2023 12:43
Creating SSL Certificate and Root Certificate Authority key
#Reference: https://deliciousbrains.com/ssl-certificate-authority-for-local-https-development/
To request an SSL certificate from a CA like Verisign or GoDaddy, you send them a Certificate Signing Request (CSR), and they give you an SSL certificate in return that they have signed using their root certificate and private key. All browsers have a copy (or access to a copy from the operating system) of the root certificate from the various CAs, so the browser can verify that your certificate was signed by a trusted CA.
That’s why when you generate a self-signed certificate the browser doesn’t trust it. It hasn’t been signed by a CA. The way to get around this is to generate our own root certificate and private key. We then add the root certificate to all the devices we own just once, and then all the self-signed certificates we generate will be inherently trusted.
# Generating the Private Key and Root Certificate
brew install openssl
mkdir ~/certs
cd ~/certs
@aonurdemir
aonurdemir / docker-compose.yml
Last active May 20, 2021 08:45
mysql 8 docker-compose up
version: '3'
services:
db:
image: mysql:8.0
container_name: test_db
restart: "no"
ports:
- "33006:3306"
environment:
@aonurdemir
aonurdemir / .bashrc
Last active May 5, 2021 08:22
Ubuntu .bashrc file
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
@aonurdemir
aonurdemir / page.html
Last active June 28, 2020 15:59 — forked from ismasan/sse.go
Example Server Sent Events (SSE) server in Golang
<html>
<head>
<meta charset="UTF-8">
<title>Server-sent events demo</title>
</head>
<body>
<button>Close the connection</button>
<ul>
</ul>
@aonurdemir
aonurdemir / op.py
Last active June 24, 2020 22:26
Python file operations
import os
from os import listdir
from os.path import isfile, join
from shutil import copy2
if __name__ == '__main__':
mypath = u'C:\\Users\\Onur\\Downloads\\Twitch Sesler-20200624T185904Z-001\\Twitch Sesler\\lowercase'
onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))]
# try:
@aonurdemir
aonurdemir / mongodbquery
Created June 17, 2020 08:07
Join and aggregate mongo db query
db.getCollection("LOG_Android_Voided_Purchases").aggregate(
[
{
"$match" : {
"voidedTime" : {
"$gte" : ISODate("2020-06-10T00:00:00.000+0000")
}
}
},
{
@aonurdemir
aonurdemir / download.php
Created June 5, 2020 08:08
Download File php
<?php
/*db connectors*/
include('dbconfig.php');
/*function to set your files*/
function output_file($file, $name, $mime_type='')
{
if(!is_readable($file)) die('File not found or inaccessible!');
$size = filesize($file);
$name = rawurldecode($name);
@aonurdemir
aonurdemir / server.py
Created March 5, 2020 07:18
Simple TCP Server for microcontrollers which should not use HTTP/json
##########TCP SERVER #######################
#If you are already familiar with django, and your microcontroller supports sending HTTP (REST) requests and can parse Json , you can just add a regular django based view that returns json:
# views.py
from django.http import JsonResponse
def my_view(request):
# handle input here, probably using request.GET / request.POST
return JsonResponse({'status': 'OK'})
#However, if your microcontroller is very simple and cannot do HTTP/json, you can use a simple SocketServer from python's standard library instead:
@aonurdemir
aonurdemir / snippet.js
Created March 5, 2020 07:14
Find modify and remove elements in javascript
$( ".container" )
.contents()
.filter(function() {
return this.nodeType === 3;
})
.wrap( "<p></p>" )
.end()
.filter( "br" )
.remove();