Skip to content

Instantly share code, notes, and snippets.

@drmalex07
drmalex07 / README-oneshot-systemd-service.md
Last active April 26, 2024 09:25
An example with an oneshot service on systemd. #systemd #systemd.service #oneshot

README

Services declared as oneshot are expected to take some action and exit immediatelly (thus, they are not really services, no running processes remain). A common pattern for these type of service is to be defined by a setup and a teardown action.

Let's create a example foo service that when started creates a file, and when stopped it deletes it.

Define setup/teardown actions

Create executable file /opt/foo/setup-foo.sh:

@Chaser324
Chaser324 / GitHub-Forking.md
Last active April 25, 2024 04:57
GitHub Standard Fork & Pull Request Workflow

Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, it's quite easy to make mistakes or not know what you should do when you're initially learning the process. I know that I certainly had considerable initial trouble with it, and I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.

In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

Creating a Fork

Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your repo or j

@troyfontaine
troyfontaine / 1-setup.md
Last active April 24, 2024 14:19
Signing your Git Commits on MacOS

Methods of Signing Git Commits on MacOS

Last updated March 13, 2024

This Gist explains how to sign commits using gpg in a step-by-step fashion. Previously, krypt.co was heavily mentioned, but I've only recently learned they were acquired by Akamai and no longer update their previous free products. Those mentions have been removed.

Additionally, 1Password now supports signing Git commits with SSH keys and makes it pretty easy-plus you can easily configure Git Tower to use it for both signing and ssh.

For using a GUI-based GIT tool such as Tower or Github Desktop, follow the steps here for signing your commits with GPG.

@gre
gre / easing.js
Last active April 23, 2024 04:20
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
/*
* This work is free. You can redistribute it and/or modify it under the
* terms of the Do What The Fuck You Want To Public License, Version 2,
* as published by Sam Hocevar. See the COPYING file for more details.
*/
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {
@perky
perky / ProFi.lua
Created May 30, 2012 20:32
ProFi, a simple lua profiler that works with LuaJIT and prints a pretty report file in columns.
--[[
ProFi v1.3, by Luke Perkin 2012. MIT Licence http://www.opensource.org/licenses/mit-license.php.
Example:
ProFi = require 'ProFi'
ProFi:start()
some_function()
another_function()
coroutine.resume( some_coroutine )
ProFi:stop()
@shunchu
shunchu / convert-seconds-into-hh-mm-ss-in-ruby.rb
Created July 25, 2012 07:58
Convert seconds into HH:MM:SS in Ruby
t = 236 # seconds
Time.at(t).utc.strftime("%H:%M:%S")
=> "00:03:56"
# Reference
# http://stackoverflow.com/questions/3963930/ruby-rails-how-to-convert-seconds-to-time
@djmnz
djmnz / gist:8190656
Last active December 19, 2023 09:56
Getting object size from C# AWS SDK without downloading it
using (var amazonClient = new AmazonS3Client())
{
var getObjectMetadataRequest = new GetObjectMetadataRequest() { BucketName = RawBucketName, Key = fileName };
var meta = amazonClient.GetObjectMetadata(getObjectMetadataRequest);
var fileSize = meta.Headers.ContentLength;
}

This content is now available at https://wiki.unvanquished.net/wiki/Breakpad

Getting a stack trace from a minidump

(1) Getting the tools

The Breakpad repo for Daemon Engine is at https://github.com/DaemonEngine/breakpad. If you have already checked out Daemon, then it is located in the libs/breakpad/ submodule there. cd into this repo.

Daemon's Breakpad fork is based on https://github.com/jon-turney/google-breakpad, with only minor changes. Jon Turney's version adds MinGW support. It is in turn a fork of Chromium's Breakpad https://chromium.googlesource.com/breakpad/breakpad.

@j127
j127 / auth_controller.rb
Last active October 28, 2019 15:10
Rails 5.2 with Discourse SSO Authentication
# This is just a sketch. Please leave a comment if you have suggestions.
class AuthController < ApplicationController
# Generate and SSO URL and redirect the user to Discourse
def authenticate
# Save the ?destination=some_url parameter if it exists
destination = request.query_parameters['destination'] || root_url
session[:destination] = destination
# `nonce` here will have `:value` and `:created_at` keys
nonce = generate_nonce