Skip to content

Instantly share code, notes, and snippets.

View tomchavakis's full-sized avatar

Thomas Chavakis tomchavakis

View GitHub Profile
@ryanmcgary
ryanmcgary / readme.html
Last active November 6, 2024 20:35 — forked from allewun/remove-watermark.sh
Remove a textual watermark from a PDF file.
zngguvnf's Blog
Processing multiple PDFs using the command line
:linux:
<2017-12-01>
Update [2018-04-17 Tue]
Remove password from pdf
Remove string from pdf
Update [2018-03-30 Fri]:
<?xml version="1.0" encoding="UTF-8"?>
<Indexer>
<coverages>
<coverage>
<schema name="Temperature_surface">
<attributes>the_geom:Polygon,location:String,imageindex:Integer,time:java.util.Date</attributes>
</schema>
<origName>Temperature_surface</origName>
<name>Temperature_surface</name>
</coverage>
@Iman
Iman / clean.sh
Last active November 29, 2025 04:06
Free up disk space on Ubuntu - clean log, cache, archive packages/apt archives, orphaned packages, old kernel and remove the trash
#!/usr/bin/env bash
# Ubuntu Server or VM Cleaner. Safe by default; aggressive when asked.
# Example safe: sudo ./clean.sh
# Example aggressive: sudo JOURNAL_DAYS=3 AGGRESSIVE=1 ./clean.sh
# Enable Docker image prune (images only): sudo ./clean.sh --docker-images
# Tested on Ubuntu 20.04, 22.04, 24.04 (server/VM images).
set -Eeuo pipefail
trap 'rc=$?; echo "Error on line $LINENO: $BASH_COMMAND (exit $rc)"; exit $rc' ERR
IFS=$'\n\t'
@flaub
flaub / SqliteContext.cs
Created March 16, 2015 08:21
SQLite EF 6 Database Initializer
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
using System.Data.SQLite;
using System.Linq;
namespace SQliteEF6
{
class SqliteContext : DbContext
@garystafford
garystafford / helpful-docker-commands.sh
Last active April 20, 2025 11:08
My list of helpful docker commands
###############################################################################
# Helpful Docker commands and code snippets
###############################################################################
### CONTAINERS ###
docker stop $(docker ps -a -q) #stop ALL containers
docker rm -f $(docker ps -a -q) # remove ALL containers
docker rm -f $(sudo docker ps --before="container_id_here" -q) # can also filter
# exec into container
@benbalter
benbalter / geojson-conversion.sh
Last active April 23, 2024 13:16
Bulk convert shapefiles to geojson using ogr2ogr
# Bulk convert shapefiles to geojson using ogr2ogr
# For more information, see http://ben.balter.com/2013/06/26/how-to-convert-shapefiles-to-geojson-for-use-on-github/
# Note: Assumes you're in a folder with one or more zip files containing shape files
# and Outputs as geojson with the crs:84 SRS (for use on GitHub or elsewhere)
#geojson conversion
function shp2geojson() {
ogr2ogr -f GeoJSON -t_srs crs:84 "$1.geojson" "$1.shp"
}
@johnnyreilly
johnnyreilly / DemoAreaRegistration.cs
Last active October 29, 2019 13:43
What you need to unit test MVC controllers using MOQ.
using System.Web.Mvc;
namespace DemoApp.Areas.Demo
{
public class DemoAreaRegistration : AreaRegistration
{
public override string AreaName
{
get
{
@joeriks
joeriks / FileAttachmentController.cs
Created September 13, 2012 12:46
Use webapi to download file as attachment (using AttributeRouting)
[RoutePrefix("files")]
public class FilesController : ApiController
{
[GET("somepdf/{id}")]
public HttpResponseMessage GetSomePdf(string id)
{
var path = MyApp.PathToSomePdf(id);
if (path!= null)
return FileAsAttachment(path, "somepdf.pdf");
@maxp
maxp / NMEA_checksum
Created September 4, 2011 17:44
Calculating an NMEA Checksum (C#)
// Calculates the checksum for a sentence
// Calculates the checksum for a sentence
static string getChecksum(string sentence) {
//Start with first Item
int checksum= Convert.ToByte(sentence[sentence.IndexOf('$')+1]);
// Loop through all chars to get a checksum
for (int i=sentence.IndexOf('$')+2 ; i<sentence.IndexOf('*') ; i++){
// No. XOR the checksum with this character's value
checksum^=Convert.ToByte(sentence[i]);