Skip to content

Instantly share code, notes, and snippets.

View williamdes's full-sized avatar
🚀
Catching up on GitHub notifications

William Desportes williamdes

🚀
Catching up on GitHub notifications
View GitHub Profile
@jesseschalken
jesseschalken / format serialize.php
Last active June 22, 2024 20:44
Pretty print a PHP serialized value. Useful for finding the differences between two serialized values.
<?php
/*
MIT License
Copyright (c) 2021 Jesse Schalken
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
@phryneas
phryneas / SSH+PAM+google authentificator: publickey OR password+OTP
Last active February 25, 2023 06:31
SSH+PAM+google authentificator: publickey OR password+OTP
# at least in deb/untu
sudo apt-get install libpam-google-authenticator
# for each user
google-authenticator
@domenic
domenic / 0-github-actions.md
Last active May 26, 2024 07:43
Auto-deploying built products to gh-pages with Travis

Auto-deploying built products to gh-pages with GitHub Actions

This is a set up for projects which want to check in only their source files, but have their gh-pages branch automatically updated with some compiled output every time they push.

A file below this one contains the steps for doing this with Travis CI. However, these days I recommend GitHub Actions, for the following reasons:

  • It is much easier and requires less steps, because you are already authenticated with GitHub, so you don't need to share secret keys across services like you do when coordinate Travis CI and GitHub.
  • It is free, with no quotas.
  • Anecdotally, builds are much faster with GitHub Actions than with Travis CI, especially in terms of time spent waiting for a builder.
@luciomartinez
luciomartinez / slash.sh
Last active June 23, 2024 19:34
Add or Remove trailing slash in bash
### Add trailing slash if needed
STR="/i/am/a/path"
length=${#STR}
last_char=${STR:length-1:1}
[[ $last_char != "/" ]] && STR="$STR/"; :
echo "$STR" # => /i/am/a/path/
@nstanke
nstanke / mailinabox.mobileconfig
Created November 4, 2014 18:53
example iOS mobile config
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PayloadContent</key>
<array>
<dict>
<key>CalDAVAccountDescription</key>
<string>Mail-in-a-box Calendar</string>
<key>CalDAVHostName</key>
@macmladen
macmladen / exclude-rsync.sh
Last active December 5, 2024 07:14
rsync file exclude patterns
# /dir/ means exclude the root folder /dir
# /dir/* means get the root folder /dir but not the contents
# dir/ means exclude any folder anywhere where the name contains dir/
# Examples excluded: /dir/, /usr/share/mydir/, /var/spool/dir/
# /dir means exclude any folder anywhere where the name contains /dir
# Examples excluded: /dir/, /usr/share/directory/, /var/spool/dir/
# /var/spool/lpd//cf means skip files that start with cf within any folder within /var/spool/lpd
#
# include, +
# exclude, -
@yoavniran
yoavniran / simple-nodejs-iv-encrypt-decrypt.js
Last active January 20, 2022 08:16
nodejs crypto - simple encrypt & decrypt using IV (Initialization Vector)
"use strict";
var crypto = require("crypto");
var EncryptionHelper = (function () {
function getKeyAndIV(key, callback) {
crypto.pseudoRandomBytes(16, function (err, ivBuffer) {
var keyBuffer = (key instanceof Buffer) ? key : new Buffer(key) ;
@stefansundin
stefansundin / launchpad-download-count.user.js
Last active April 26, 2023 13:39
Userscript that shows you the download count for Launchpad packages. Be sure to go to the "View all builds" view. (Read the source code for notes!). Click the [Raw] button to install!
// ==UserScript==
// @name Launchpad Download Count
// @namespace https://gist.github.com/stefansundin/
// @homepage https://gist.github.com/stefansundin/f9df6c5e0fd184c60709
// @downloadURL https://gist.github.com/stefansundin/f9df6c5e0fd184c60709/raw/launchpad-download-count.user.js
// @version 0.3
// @author Stefan Sundin
// @description Gets the download count of your Launchpad packages.
// @icon https://launchpad.net/favicon.ico
// @match https://launchpad.net/~*/+archive/ubuntu/*
@deepankarb
deepankarb / svg-to-android.sh
Last active July 14, 2018 13:13
A script to generate android assets from a SVG file. Requires inkscape to resize and convert.
#!/bin/bash
if [[ -z "$1" ]];
then
echo "No SVG file specified. Exiting."
exit -1
fi
ispng=$(file $1)
echo $ispng | grep -q SVG
@james2doyle
james2doyle / node-base64-encode.js
Last active September 27, 2024 10:59
base64 encode a file with node.js and auto-detect the mimetype.
// to run: node node-base64-encode.js file
const mime = require('mime'); // npm install mime
const path = require('path');
const fs = require('fs');
// path to the file we passed in
const filepath = path.resolve(process.argv[2]);
// get the mimetype
const filemime = mime.getType(filepath);