Skip to content

Instantly share code, notes, and snippets.

@xlab
xlab / bytes_split.go
Last active April 4, 2022 17:21
Golang split byte slice in chunks sized by limit
func split(buf []byte, lim int) [][]byte {
var chunk []byte
chunks := make([][]byte, 0, len(buf)/lim+1)
for len(buf) >= lim {
chunk, buf = buf[:lim], buf[lim:]
chunks = append(chunks, chunk)
}
if len(buf) > 0 {
chunks = append(chunks, buf[:len(buf)])
}
@imjasonh
imjasonh / markdown.css
Last active February 12, 2024 17:18
Render Markdown as unrendered Markdown (see http://jsbin.com/huwosomawo)
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
@drkarl
drkarl / gist:739a864b3275e901d317
Last active October 17, 2023 10:43
Ask HN: Best Linux server backup system?

Linux Backup Solutions

I've been looking for the best Linux backup system, and also reading lots of HN comments.

Instead of putting pros and cons of every backup system I'll just list some deal-breakers which would disqualify them.

Also I would like that you, the HN community, would add more deal breakers for these or other backup systems if you know some more and at the same time, if you have data to disprove some of the deal-breakers listed here (benchmarks, info about something being true for older releases but is fixed on newer releases), please share it so that I can edit this list accordingly.

  • It has a lot of management overhead and that's a problem if you don't have time for a full time backup administrator.
@domenic
domenic / 0-github-actions.md
Last active April 8, 2024 23:35
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.
@chrisgillis
chrisgillis / ssl_smtp_example.go
Created April 16, 2014 14:48
Golang SSL SMTP Example
package main
import (
"fmt"
"log"
"net"
"net/mail"
"net/smtp"
"crypto/tls"
)
(defun extract-translation (start end)
(interactive "r")
(if (region-active-p)
(let* ((text (buffer-substring start end))
(keyname (read-string "Key name: " (extract-translation-default-key-name text)))
(short-keyname (car (last (split-string keyname "\\.") 1)))
(rails-root (if (fboundp 'ffip-project-root)
(ffip-project-root)
(projectile-project-root)))
@antespi
antespi / HowTo: Decode base64
Created November 6, 2013 17:07
HowTo: Decode/Encode base64 using OpenSSL
Decode
======
openssl enc -base64 -d <<< SGVsbG8sIFdvcmxkIQo=
Encode
======
openssl enc -base64 <<< 'Hello, World!'
@richardgv
richardgv / skippy-xd-wip.patch
Last active December 22, 2015 02:39
richardgv/skippy-xd: Work in progress (icon rendering)
diff --git a/Makefile b/Makefile
index 12fbe8e..81d25db 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@ BINDIR ?= ${PREFIX}/bin
CC ?= gcc
-SRCS_RAW = skippy wm dlist mainwin clientwin layout focus config tooltip img
+SRCS_RAW = skippy wm dlist mainwin clientwin layout focus config tooltip img img-xlib
@kates
kates / search_and_replace.sh
Last active August 31, 2019 05:22
bulk search and replace with the silver searcher, awk, sed and xargs
ag "sometext" --nogroup | awk '{print substr($1,1,index($1,":")-1);}' | xargs -I {} sed -i .bak -e 's/sometext/anothertext/g' {}
@mlapshin
mlapshin / run_tags.rb
Last active December 18, 2015 07:49
run ctags git hook
#!/usr/bin/env ruby
#-*-ruby-*-
# A script to run ctags on all .rb files in a project. Can be run on
# the current dir, called from a git callback, or install itself as a
# git post-merge and post-commit callback.
CTAGS = '/usr/bin/ctags.emacs24'
HOOKS = %w{ post-merge post-commit post-checkout }
HOOKS_DIR = '.'