Skip to content

Instantly share code, notes, and snippets.

@rcrowley
rcrowley / rxvt-unicode.sh
Created June 15, 2010 06:39
Mac rxvt-unicode setup.
# Mac rxvt-unicode setup.
# http://rcrowley.org/articles/rxvt-unicode.html
# Install dependencies from MacPorts and CPAN.
sudo port install rxvt-unicode +xterm_colors_256
sudo port install terminus-font
sudo cpan install Mac::Pasteboard
# Run urxvt at X11 startup.
defaults write org.x.X11 app_to_run /opt/local/bin/urxvt
@thibautsacreste
thibautsacreste / rack_show_session.rb
Last active March 12, 2021 13:43
Ruby: decode rack session cookie
require 'base64'
require 'cgi'
def show_session(cookie)
Marshal.load(Base64.decode64(CGI.unescape(cookie.split("\n").join).split('--').first))
end
@hofmannsven
hofmannsven / README.md
Last active July 16, 2024 01:30
Git CLI Cheatsheet
@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>
@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
*
*/
@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
@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/`目录下:
@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
@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);
@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',