Skip to content

Instantly share code, notes, and snippets.

View dresende's full-sized avatar
🇺🇦
Free Ukraine

Diogo Resende dresende

🇺🇦
Free Ukraine
View GitHub Profile
@ajumalp
ajumalp / Install Mosquitto MQTT on Synology NAS Server.txt
Last active March 29, 2024 04:36
Install Mosquitto MQTT on Synology NAS Server
From https://synocommunity.com add http://packages.synocommunity.com to your NAS package sources.
For that, go to NAS->Package Cnter->Click Settings->Package Sources tab.
Then from the community, you can see Mosquitto. Install it.
After installing, please stop the Mosquitto service before updating configuration. You can start service after changes.
Enable Admin login for Synology
Enable SSH in NAS
Download putty and connect to NAS Server
Login using admin
Change to root user [sudo -i, {use admin password}]
Find mosquitto.conf file [find / -name mosquitto.conf]
@jvenator
jvenator / gist:9672772a631c117da151
Last active April 28, 2024 01:09
PDFtk Server Install Workaround for Mac OS X

Installing PDFtk Server edittion on your Mac

This workaround install is necessary because PDFtk was pulled from homebrew-cask due to issues with it aggressively overwriting file permissions that could impact other installed libraries. See this homebrew-cask issue.
The following steps worked on Mac OS X 10.10.1 with a standard brew installation for the PDFtk Mac OS X server libary version 2.02.
All Terminal commands separated by a full line space. Some commands wrap into multiple lines.

Download and extract the Mac OS X server install pacakge

@dergachev
dergachev / ubuntu-eol.md
Last active December 7, 2023 22:26
What to do when your ubuntu distro is End-of-Life

Let's say you're using Ubuntu 13.04 (Raring Ringtail, released in April 2013) and it just went End-of-Life on you, because it's supported for only 6 months, and the deprecated packages are taken down after 12 months.

You'll probably figure this out the hard way. When you run sudo apt-get update, it will eventually report these errors:

Ign http://archive.ubuntu.com raring-updates/universe Sources/DiffIndex
Err http://security.ubuntu.com raring-security/main Sources
  404  Not Found [IP: 91.189.91.15 80]
Err http://security.ubuntu.com raring-security/universe Sources
  404  Not Found [IP: 91.189.91.15 80]
@betamos
betamos / readable-duration.js
Last active August 6, 2020 20:50
Tiny JS utility to print duration in a human readable fashion
/* Author: Didrik Nordström, didrik@betamos.se */
/**
* Format a duration in milliseconds to a human readable format, e.g.
* "4y 2d 3h 10m 10s 255ms". Negative durations are formatted like "- 8h 30s".
* Granularity is always ms.
*
* @param t Duration in milliseconds
* @return A formatted string containing the duration or "" if t=0
*/

Recipe for customizing a SmartoOS image and cloning it

1. Create base image

1.1. Download and install the base image:

[root@00-0c-29-aa-24-ba ~]# imgadm list
UUID                                  NAME             VERSION  OS       PUBLISHED
9eac5c0c-a941-11e2-a7dc-57a6b041988f  base64           13.1.0   smartos  2013-04-26T15:17:57Z
@dresende
dresende / fetch_pull_request.sh
Created June 5, 2013 09:28
Fetch a single github pull request
# fetch pull request N to (new) localbranch
git fetch origin pull/N/head:localbranch
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@nijikokun
nijikokun / example-user.js
Created May 3, 2012 20:46
Beautiful Validation... Why have I never thought of this before?!
var user = {
validateCredentials: function (username, password) {
return (
(!(username += '') || username === '') ? { error: "No Username Given.", field: 'name' }
: (!(username += '') || password === '') ? { error: "No Password Given.", field: 'pass' }
: (username.length < 3) ? { error: "Username is less than 3 Characters.", field: 'name' }
: (password.length < 4) ? { error: "Password is less than 4 Characters.", field: 'pass' }
: (!/^([a-z0-9_-]+)$/i.test(username)) ? { error: "Username contains invalid characters.", field: 'name' }
: false
);
@Thinkscape
Thinkscape / smstools-utf8-to-ucs2.sh
Created March 27, 2012 11:28
SMSTools support for sending UTF-8 SMS messages.
#!/bin/bash
#
# This script converts SMS encoded with UTF-8 to UCS2 format expected by smsd.
# To use it, edit your /etc/smsd.conf and add the following line:
#
# checkhandler = /path/to/smstools-utf8-to-ucs2.sh
#
# When creating a new message in /var/spool/outgoing/, add the following header line:
#
# Alphabet: UTF-8
@dresende
dresende / ldapjs-addrbook.js
Created August 26, 2011 18:06
LDAP Addressbook using ldapjs
// MySQL test: (create on database 'abook' with username 'abook' and password 'abook')
//
// CREATE TABLE IF NOT EXISTS `users` (
// `id` int(5) unsigned NOT NULL AUTO_INCREMENT,
// `username` varchar(50) NOT NULL,
// `password` varchar(50) NOT NULL,
// PRIMARY KEY (`id`),
// KEY `username` (`username`)
// ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
// INSERT INTO `users` (`username`, `password`) VALUES