Skip to content

Instantly share code, notes, and snippets.

@redanium
redanium / compress-pdf-with-gs.md
Created January 21, 2018 11:47 — forked from drawveloper/compress-pdf-with-gs.md
Compress PDF files with ghostscript

This can reduce files to ~15% of their size (2.3M to 345K, in one case) with no obvious degradation of quality.

ghostscript -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf

Other options for PDFSETTINGS:

  • /screen selects low-resolution output similar to the Acrobat Distiller "Screen Optimized" setting.
  • /ebook selects medium-resolution output similar to the Acrobat Distiller "eBook" setting.
  • /printer selects output similar to the Acrobat Distiller "Print Optimized" setting.
  • /prepress selects output similar to Acrobat Distiller "Prepress Optimized" setting.
@redanium
redanium / gist:09c2779a8d45b20ab500d9349ecabbd3
Created January 31, 2018 18:41 — forked from stucka/gist:5342652
Tabula installation instructions for Ubuntu 12.04. Tabula turns PDFs into CSVs! http://source.mozillaopennews.org/en-US/articles/introducing-tabula/
Yeah, this all got outmoded when serious dependency problems with Tabula were removed.
No need to use this. Get Tabula directly. http://tabula.nerdpower.org/
from selenium import webdriver
from selenium.webdriver.common.proxy import Proxy
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import zipfile
@redanium
redanium / mongo_backup.sh
Created April 3, 2018 20:33 — forked from sheharyarn/mongo_backup.sh
Mongodump Shell Script for Cronjob
#!/bin/bash
MONGO_DATABASE="your_db_name"
APP_NAME="your_app_name"
MONGO_HOST="127.0.0.1"
MONGO_PORT="27017"
TIMESTAMP=`date +%F-%H%M`
MONGODUMP_PATH="/usr/bin/mongodump"
BACKUPS_DIR="/home/username/backups/$APP_NAME"
@redanium
redanium / nginxproxy.md
Created May 3, 2019 22:50 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@redanium
redanium / Toast.qml
Created June 26, 2020 22:02 — forked from jonmcclung/Toast.qml
Toast in QML. This implementation creates black toast with white text that appears at the bottom of the screen. It also supports adding multiple toast at a time using ToastManager with the newest toast at the bottom.
import QtQuick 2.0
/**
* adapted from StackOverflow:
* http://stackoverflow.com/questions/26879266/make-toast-in-android-by-qml
*/
/**
* @brief An Android-like timed message text in a box that self-destroys when finished if desired
*/
@redanium
redanium / electron-main.js
Created December 10, 2021 22:37 — forked from dannvix/electron-main.js
Create Electron's BrowserWindow with dynamic HTML content
// main.js for Electron
var app = require("app"),
BrowserWindow = require("browser-window");
app.on("window-all-closed", function() {
app.quit();
})
var mainWindow = null;
app.on("ready", function() {
@redanium
redanium / client-socket-reconnect.js
Created December 30, 2021 10:39 — forked from sio2boss/client-socket-reconnect.js
Node.js Re-connecting Socket
//
// Simple example of using net.Socket but here we capture the
// right events and attempt to re-establish the connection when
// is is closed either because of an error establishing a
// connection or when the server closes the connection.
//
// Requires
var net = require('net');
@redanium
redanium / WiX service installation
Created February 9, 2022 20:13 — forked from rowlandwatkins/WiX service installation
WiX Service Installation
http://plainoldstan.blogspot.hk/2010/11/wix-installing-and-uninstalling-windows.html:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="9c78f041-c29e-4d80-8d23-e4839e74038c" Name="StansApp"
Language="1033" Version="1.0.0.0"
Manufacturer="Standa" UpgradeCode="b1adfc21-927f-470a-ac87-a5019c84a253">
<Package InstallerVersion="200" Compressed="yes" />
<Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />
<Directory Id="TARGETDIR" Name="SourceDir">
@redanium
redanium / Huawei WWAN.md
Created February 22, 2022 08:37 — forked from jfstenuit/Huawei WWAN.md
Using a Huawei WWAN dongle on Linux

Introduction

Installing Huawei E3531 Surf Stick on Linux

May be a valuable insight for more modern surf sticks like Huawei E8231 and the likes ...

Linux is currently Ubuntu, Debian or Raspbian should be similar

The problem

This Huawei Surf stick has several USB mode. It appears first as CD-ROM-like device, so that Windows users can install their driver, then switches mode to appear as "something else". By defaut, this is a network card (virtually connected to a router),