Skip to content

Instantly share code, notes, and snippets.

View sztosz's full-sized avatar

Bartosz Nowak sztosz

View GitHub Profile
@dginev
dginev / utf8_truncate.rs
Created September 29, 2015 04:10
UTF8 safe truncate for Rust strings
fn utf8_truncate(input : &mut String, maxsize: usize) {
let mut utf8_maxsize = input.len();
if utf8_maxsize >= maxsize {
{ let mut char_iter = input.char_indices();
while utf8_maxsize >= maxsize {
utf8_maxsize = match char_iter.next_back() {
Some((index, _)) => index,
_ => 0
};
} } // Extra {} wrap to limit the immutable borrow of char_indices()
@exAspArk
exAspArk / friday_deploy_cap2.rb
Last active November 14, 2020 23:13
Friday deploy script for Capistrano
# Capistrano 2
before "deploy", "friday:good_luck"
namespace :friday do
friday_jumper = %{
┓┏┓┏┓┃
┛┗┛┗┛┃⟍ ○⟋
┓┏┓┏┓┃ ∕ Friday
┛┗┛┗┛┃ノ)
@unhammer
unhammer / merlin-init.sh
Last active February 12, 2023 05:40
Create .merlin file for a project with all your ocamlfind packages and .opam sources in there
#!/bin/sh
if test -f .merlin; then
echo ".merlin already exists, bailing out ..." >&2
exit 1
else
# You could add your default EXT's and such to this list: