Skip to content

Instantly share code, notes, and snippets.

View ozzi-'s full-sized avatar
🎯
On point

ozzi-

🎯
On point
View GitHub Profile
var selfNameTopOffset;
var navbarCollapsed;
$(function() {
. . .
normalNavBarHeight = $('#pnavbar').height();
selfNameTopOffset = $("#selfName").offset().top;
$(window).on('resize', debounce(handleWindowResize, 50));
handleWindowResize();
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
@ozzi-
ozzi- / a.bat
Created February 13, 2024 17:18
start taskmgr
@ozzi-
ozzi- / a.html
Created February 13, 2024 17:13
<input type="file" id="avatar" name="avatar" />
@ozzi-
ozzi- / a.js
Last active February 13, 2024 17:05
var oShell = new ActiveXObject("WScript.Shell");
oShell.Run("cmd.exe /C start microsoft-edge:http://www.microsoft.com");
import java.util.Collections;
public class RingBuffer<T> {
int length;
int currentPos = 0;
int firstPos = 0;
int lastPos;
private T[] buffer;
@ozzi-
ozzi- / index.html
Last active July 22, 2024 18:36
JavaScript form submit timeout handling
<html>
Form being submitted
<!-- longresponse.phg will take 30 seconds to respons, in order to simulate a timeout -->
<form id="response" method="GET" action="https://oz-web.com/longresponse.php">
<input type="hidden" name="status" id="status" value="*empty*" />
</form>
<script>
const form = document.getElementById("response");
function handleFail(){
// replace this with whatever code you have to handle the timeout
@ozzi-
ozzi- / binaryDownload.js
Last active March 29, 2021 13:11
JS - Download a binary file via XHR then prompt the save file dialog
<html>
<a id="downloadBinaryLink"></a>
<script>
// file.php here serves as a pseudo API that returns a binary as octect stream (and according Access-Control-Allow-Origin header)
doBinaryDownload("http://oz-web.com/file.php", loadBinaryScriptEdit);
function loadBinaryScriptEdit(blob){
var dataUri = window.URL.createObjectURL(blob);
var anchor = document.getElementById("downloadBinaryLink");
anchor.setAttribute('href', dataUri);
anchor.setAttribute('download', "pingsender.exe");
@ozzi-
ozzi- / equivRedirectBash.sh
Created January 28, 2021 14:01
follow meta equiv redirect with bash and curl
equiv=$(curl $YOURURL -sS | grep -i "http-equiv")
shopt -s nocasematch
regexp='\<meta http-equiv=\"*refresh\"* content=\"*[0-9]*\"*;\s*url=([a-zA-Z0-9\/\.\?=#&.]*)'
path=""
if [[ $equiv =~ $regexp ]]; then
echo "${BASH_REMATCH[1]}"
# curl $YOURURL${BASH_REMATCH[1]}
else
echo "Could not parse equiv!"
exit 3
@ozzi-
ozzi- / JSON - Remove Trailing Comma
Created December 3, 2020 09:09
removes trailing commas in JSON strings
// Input:
// [
// {
// "f00" : "bar",
// "info" : "this comma to my right is wrong",
// },
// {
// "f00" : "bar",
// "info" : "the comma on the line below is wrong too!"
// },