Skip to content

Instantly share code, notes, and snippets.

View SharkFourSix's full-sized avatar
💭
I may be slow to respond.

SharkFourSix

💭
I may be slow to respond.
View GitHub Profile
@sirbrillig
sirbrillig / pgsql_backup.sh
Last active November 15, 2024 14:57 — forked from dangerousbeans/pgsql_backup.sh
Postgresql daily backup script.
#!/bin/bash
#
# Backup a Postgresql database into a daily file.
#
BACKUP_DIR=/pg_backup
DAYS_TO_KEEP=14
FILE_SUFFIX=_pg_backup.sql
DATABASE=
USER=postgres
@bjoernQ
bjoernQ / AndroidManifest.xml
Created October 14, 2013 13:02
Creating a System Overlay (Always on Top over all Apps) in Android
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.mobilej.overlay"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="14" />
<application android:label="SystemOverlay" >
<activity
@mikeapr4
mikeapr4 / CertificateUtils.java
Created February 12, 2016 15:48
Convenient In-Memory Self-signed Certificate and Keystore creation for Java 8
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sun.security.tools.keytool.CertAndKeyGen;
import sun.security.x509.X500Name;
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
@timsavage
timsavage / websocket_server.py
Last active June 27, 2023 16:58
Simple example of a websocket server with Tornado
# While this code still works, I would recommend using Fast API for websockets in modern applications.
# See: https://fastapi.tiangolo.com/advanced/websockets/
# Note this is targeted at python 3
import tornado.web
import tornado.httpserver
import tornado.ioloop
import tornado.websocket
import tornado.options
@Kalimaha
Kalimaha / proxy.py
Last active August 2, 2024 05:15
Simple Proxy server in Python
import time
from threading import Thread
try:
import socketserver as SocketServer
import http.server as SimpleHTTPServer
except ImportError:
import SocketServer
import SimpleHTTPServer
@nelaaro
nelaaro / gist:9ac6fee4e8fdac9ee8fdd25aeb5456f8
Last active February 1, 2022 08:59
12d1:14dc Huawei Technologies Co., Ltd. E33372 LTE/UMTS/GSM HiLink Modem/Networkcard, Huawei Technologies Co., Ltd. E353/E3131 (Mass storage mode)
sudo usb_modeswitch -v 12d1 -p 1f01 -V 12d1 -P 14DC -J
# Bus 001 Device 028: ID 12d1:14dc Huawei Technologies Co., Ltd. E33372 LTE/UMTS/GSM HiLink Modem/Networkcard
# Bus 001 Device 027: ID 12d1:1f01 Huawei Technologies Co., Ltd. E353/E3131 (Mass storage mode)
sudo usb_modeswitch -h 15s  Thu 23 Nov 2017 00:13:05 SAST
* usb_modeswitch: handle USB devices with multiple modes
* Version 2.5.1 (C) Josua Dietze 2017
* Based on libusb1/libusbx
@ezhov-da
ezhov-da / java-Spark download random file.java
Last active June 7, 2021 12:48
java spark download random file
get("/file", ((request, response) -> {
response.header("Content-disposition", "attachment; filename=file.txt;");
File file = new File("E:\\_file-test.txt");
OutputStream outputStream = response.raw().getOutputStream();
outputStream.write(Files.readAllBytes(file.toPath()));
outputStream.flush();
return response;
}));
@fernandoaleman
fernandoaleman / install-rabbitmq-centos-7.md
Last active October 13, 2024 13:37
Install RabbitMQ on CentOS 7

Install RabbitMQ on CentOS 7

sudo yum -y install epel-release
sudo yum -y update

Install Erlang

Download repository

@SharkFourSix
SharkFourSix / UrlUtil.java
Created August 11, 2021 15:04
URL Query Parameter Manipulator: Add/Remove Query Parameters
import java.net.MalformedURLException;
import java.net.URL;
import java.util.*;
public class UrlUtil {
private final URL url;
private final Map<String, List<String>> parameters;
public UrlUtil(String url) throws MalformedURLException {
this.url = new URL(url);
package main
import (
"fmt"
"io/ioutil"
"net/http"
"sync"
"time"
"go.uber.org/ratelimit"