Skip to content

Instantly share code, notes, and snippets.

@daks
daks / auto.luks
Last active May 24, 2022 15:56
Autofs script to automount LUKS encrypted disks. Based on http://msqr.us/m2/archives/2009/07/configuring-automount-for-luks.html
#!/bin/bash
# This file must be executable to work! chmod 755!
#
# The LUKS key must exist as a file at /etc/.keys/${device}.key
# Protect this directory: root as user/group, 400 as permissions
#
# Edit your autofs master file to include something like
# /mnt/crypt /etc/auto.luks --timeout=600
#
# Then you can access your LUKS encrypted disk with
####### License: MIT
"""MIT License
Copyright (c) 2015 Aaron Hall
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
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@Hexcles
Hexcles / .ycm_extra_conf.py
Created May 7, 2015 22:15
YouCompleteMe extra conf for Linux kernel
# .ycm_extra_conf.py for kernel
import os
# Attention:
# File path not starting with / or = will be expanded.
flags_c = [
'-Wall',
'-Wundef',
'-Wstrict-prototypes',
@gchudnov
gchudnov / cpp_utf8_utf16.cpp
Created November 6, 2014 19:33
C++ string conversion UTF8 <-> UTF16
#include <string>
#include <locale>
#include <codecvt>
//UTF-8 to UTF-16
std::string source;
//...
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>,char16_t> convert;
std::u16string dest = convert.from_bytes(source);
@yszheda
yszheda / .ycm_extra_conf.py
Created August 29, 2014 04:10
YouCompleteMe config for cocos2d-x project on Mac
# This file is NOT licensed under the GPLv3, which is the license for the rest
# of YouCompleteMe.
#
# Here's the license text for this file:
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
@kidlj
kidlj / gentoo-infinality
Created August 3, 2014 04:45
在Gentoo上配置Infinality
Infinality[1] 是一套 Linux 平台下通用字体渲染引擎 freetype 的补丁,它为 Linux 提供了近乎于 Windows 和 Mac 的字体渲染效果,特别是很好地解决了 Linux 下中文字体发虚的问题。本 wiki 提供了在 Gentoo Linux 下将微软雅黑字体配置出 Windows 7 渲染效果的方法。
### 1. 字体准备
安装宋体(SimSun)和微软雅黑(Microsoft YaHei)作为主要中文字体。实测文泉驿微米黑和文泉驿正黑在低分辨率下渲染效果不好,建议不用,最好删除。
宋体和雅黑可以在微软系统里拷贝或者下载,具体为四个字体文件: `msyh.ttf`, `msyhbd.ttf`, `simsun.ttc`, `simsunb.ttf`. 然后将其放置在`~/.fonts/`目录下:
@PaulMaddox
PaulMaddox / decrypt.sh
Created April 4, 2014 10:38
LUKS encrypted image file
#!/bin/bash
FILENAME="private.img";
FILESIZE="100M";
# Create encrypted volume if it doesn't exist
if [ ! -f $FILENAME ]; then
echo "Creating image file...";
dd if=/dev/zero of=$FILENAME bs=$FILESIZE count=0 seek=1
@kmullin
kmullin / get_nic_speeds.c
Last active September 12, 2019 15:23
determine speed of network interfaces in linux using ioctl, and getifaddrs(3) will detect bonding interfaces, and sum speeds of slave devices. purpose for writing was to use with puppet and external facts
/*
* most of the code shamelessly stolen from:
* http://stackoverflow.com/a/2876605
*
* more code stolen from getifaddrs(3) manpage
*
* output is: interface=speed
* written by Kevin Mullin 01/07/14
*
*/
@rmcgibbo
rmcgibbo / MPI_ManualReduce.cpp
Last active August 16, 2022 23:15
Efficient MPI Parallel Reduction Without MPI_Reduce or MPI_Scan (only Send/Recv)
/*
* An efficient MPI parallel reduction without MPI_Scan or MPI_Reduce. (i.e.
* only send/recv).
*
* TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
* 0. You just DO WHAT THE FUCK YOU WANT TO.
*/
#include <mpi.h>
#include <cstdio>
#include <vector>
@hofmannsven
hofmannsven / README.md
Last active April 30, 2025 15:25
Git CLI Cheatsheet