Skip to content

Instantly share code, notes, and snippets.

View anselmobattisti's full-sized avatar
🇧🇷
Aqui é Brasil!

Anselmo Battisti anselmobattisti

🇧🇷
Aqui é Brasil!
View GitHub Profile
@joseluisq
joseluisq / resize_disk_image.md
Last active April 30, 2024 01:07
How to resize a qcow2 disk image on Linux

How to resize a qcow2 disk image on Linux

This example takes olddisk.qcow2 and resizes it into newdisk.qcow2, extending one of the guest's partitions to fill the extra space.

1. qcow2 format

1.1. Verify the filesystems of olddisk.qcow2

@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@leowebguy
leowebguy / index.html
Last active April 10, 2024 01:21
Responsive iframe full screen. Display page without and hide original url address.
<html lang="en" class="no-js">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<style>
html body {width: 100%;height: 100%;padding: 0px;margin: 0px;overflow: hidden;font-family: arial;font-size: 10px;color: #6e6e6e;background-color: #000;} #preview-frame {width: 100%;background-color: #fff;}</style>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
//function to fix height of iframe!
var calcHeight = function() {
@javilobo8
javilobo8 / download-file.js
Last active April 9, 2024 12:01
Download files with AJAX (axios)
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);
@mmaia
mmaia / Very quick localhost kubernetes start
Last active April 4, 2024 15:22
Quick start guide to running Kubernetes localhost for development. A.K.A. -> No BS guide to local Kubernetes.
# Install the following on your machine
1. [Docker](https://docs.docker.com/get-docker/)
- Test with `docker version`
2. [kubectl](https://kubernetes.io/docs/tasks/tools/#kubectl)
- Test with: `kubectl version`
3. [kind](https://kubernetes.io/docs/tasks/tools/#kind)
- Test with: `kind version`
@danharper
danharper / background.js
Last active March 30, 2024 18:25
Bare minimum Chrome extension to inject a JS file into the given page when you click on the browser action icon. The script then inserts a new div into the DOM.
// this is the background code...
// listen for our browerAction to be clicked
chrome.browserAction.onClicked.addListener(function (tab) {
// for the current tab, inject the "inject.js" file & execute it
chrome.tabs.executeScript(tab.ib, {
file: 'inject.js'
});
});
@beeender
beeender / appsrc-udpsink.c
Last active February 27, 2024 12:57
Gstreamer appsrc streaming though udpsink
#include <gst/gst.h>
#include <gst/app/gstappsrc.h>
static GMainLoop *loop;
static void
cb_need_data (GstAppSrc *appsrc,
guint unused_size,
gpointer user_data)
{
@crearo
crearo / gstreamer-tee-recording-and-display.c
Created March 20, 2017 11:47
Example of tee in gstreamer. recording + display.
#include <string.h>
#include <gst/gst.h>
#include <signal.h>
#include <unistd.h>
#include <stdlib.h>
// v4l2src ! tee name=t t. ! x264enc ! mp4mux ! filesink location=/home/rish/Desktop/okay.264 t. ! videoconvert ! autovideosink
static GMainLoop *loop;
static GstElement *pipeline, *src, *tee, *encoder, *muxer, *filesink, *videoconvert, *videosink, *queue_record, *queue_display;
@khalidx
khalidx / simple_http_server_cors.py
Last active September 21, 2023 02:24
Python SimpleHTTPServer with CORS, supporting both Python 2 and 3
#!/usr/bin/env python
# Usage: python simple_http_server_cors.py <port>
try:
# try to use Python 3
from http.server import HTTPServer, SimpleHTTPRequestHandler, test as test_orig
import sys
def test (*args):
test_orig(*args, port=int(sys.argv[1]) if len(sys.argv) > 1 else 8000)
@ericelliott
ericelliott / .gitignore
Created November 15, 2016 19:51
Sample Node project .gitignore
node_modules
build
npm-debug.log
.env
.DS_Store